drm/bridge: it6505: improve AUX operation for edid read
authorHermes Wu <hermes.wu@ite.com.tw>
Mon, 30 Dec 2024 10:51:20 +0000 (18:51 +0800)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fri, 3 Jan 2025 18:24:31 +0000 (20:24 +0200)
The original AUX operation using data registers is limited to 4 bytes.
The AUX operation command CMD_AUX_I2C_EDID_READ uses AUX FIFO and
is capable of reading 16 bytes.
This improves the speed of EDID read.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Hermes Wu <hermes.wu@ite.com.tw>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241230-v7-upstream-v7-2-e0fdd4844703@ite.corp-partner.google.com
drivers/gpu/drm/bridge/ite-it6505.c

index 6a3f764986321903533ac0600b0b2b3d70c5f397..8241a5f94dfb31214b0fead00d11c2faeb7775ff 100644 (file)
@@ -1076,10 +1076,13 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505,
                                      size_t size, enum aux_cmd_reply *reply)
 {
        int i, ret_size, ret = 0, request_size;
+       int fifo_max_size = (cmd == CMD_AUX_I2C_EDID_READ) ? AUX_FIFO_MAX_SIZE : 4;
 
        mutex_lock(&it6505->aux_lock);
-       for (i = 0; i < size; i += 4) {
-               request_size = min((int)size - i, 4);
+       i = 0;
+       do {
+               request_size = min_t(int, (int)size - i, fifo_max_size);
+
                ret_size = it6505_aux_operation(it6505, cmd, address + i,
                                                buffer + i, request_size,
                                                reply);
@@ -1088,8 +1091,9 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505,
                        goto aux_op_err;
                }
 
+               i += request_size;
                ret += ret_size;
-       }
+       } while (i < size);
 
 aux_op_err:
        mutex_unlock(&it6505->aux_lock);