[PATCH v2 4/8] drm: mipi: add mipi_dsi_generic_write_multi_type()

Caleb Connolly caleb at postmarketos.org
Tue Jul 16 23:37:08 UTC 2024


Hi Jessica,

On 12/07/2024 23:39, Jessica Zhang wrote:
> 
> 
> On 6/30/2024 11:36 AM, Caleb Connolly wrote:
>> Some panels like the Samsung AMB655X use long write commands for all
>> non-standard messages and do not work when trying to use the appropriate
>> command type.
>>
>> Support these panels by introducing a new helper to send commands of a
>> specific type, overriding the normal rules.
>>
>> Signed-off-by: Caleb Connolly <caleb at postmarketos.org>
>> ---
>>   drivers/gpu/drm/drm_mipi_dsi.c | 40 
>> ++++++++++++++++++++++++++++++++++++++++
>>   include/drm/drm_mipi_dsi.h     | 16 ++++++++++++++++
>>   2 files changed, 56 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c 
>> b/drivers/gpu/drm/drm_mipi_dsi.c
>> index a471c46f5ca6..f2c7f3f23a6e 100644
>> --- a/drivers/gpu/drm/drm_mipi_dsi.c
>> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
>> @@ -819,8 +819,48 @@ void mipi_dsi_generic_write_multi(struct 
>> mipi_dsi_multi_context *ctx,
>>       }
>>   }
>>   EXPORT_SYMBOL(mipi_dsi_generic_write_multi);
>> +/**
>> + * mipi_dsi_generic_write_raw_multi() - transmit data using a generic 
>> write packet of
>> + * a specific type
>> + * @ctx: Context for multiple DSI transactions
>> + * @type: data type of the packet
>> + * @payload: buffer containing the payload
>> + * @size: size of payload buffer
>> + *
>> + * This function will automatically choose the right data type 
>> depending on
>> + * the payload length.
> 
> Hi Caleb,
> 
> I'm a bit confused by the wording here. By "automatically", do you mean 
> the chosen by the macro calling this function?

Hmm, nope, looks like i either got this description totally wrong or 
copied it from somewhere and forgot to change it. I'll fix this in the 
next revision.

Kind regards,
> 
> Thanks,
> 
> Jessica Zhang
> 
>> + *
>> + * Return: The number of bytes transmitted on success or a negative 
>> error code
>> + * on failure.
>> + */
>> +ssize_t mipi_dsi_generic_write_raw_multi(struct 
>> mipi_dsi_multi_context *ctx,
>> +                      u8 type, const void *payload, size_t size)
>> +{
>> +    struct mipi_dsi_device *dsi = ctx->dsi;
>> +    struct mipi_dsi_msg msg = {
>> +        .channel = dsi->channel,
>> +        .tx_buf = payload,
>> +        .tx_len = size,
>> +        .type = type,
>> +    };
>> +    ssize_t ret;
>> +
>> +    if (ctx->accum_err)
>> +        return 0;
>> +
>> +    ret = mipi_dsi_device_transfer(dsi, &msg);
>> +    if (ret < 0) {
>> +        ctx->accum_err = ret;
>> +        dev_err(&dsi->dev, "sending generic data %*ph failed: %zd\n",
>> +            (int)size, payload, ret);
>> +    }
>> +
>> +    return ret;
>> +}
>> +EXPORT_SYMBOL(mipi_dsi_generic_write_raw_multi);
>> +
>>   /**
>>    * mipi_dsi_generic_read() - receive data using a generic read packet
>>    * @dsi: DSI peripheral device
>>    * @params: buffer containing the request parameters
>> diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
>> index 71d121aeef24..fb23f4e3b94e 100644
>> --- a/include/drm/drm_mipi_dsi.h
>> +++ b/include/drm/drm_mipi_dsi.h
>> @@ -287,8 +287,10 @@ ssize_t mipi_dsi_generic_write(struct 
>> mipi_dsi_device *dsi, const void *payload,
>>   int mipi_dsi_generic_write_chatty(struct mipi_dsi_device *dsi,
>>                     const void *payload, size_t size);
>>   void mipi_dsi_generic_write_multi(struct mipi_dsi_multi_context *ctx,
>>                     const void *payload, size_t size);
>> +ssize_t mipi_dsi_generic_write_raw_multi(struct 
>> mipi_dsi_multi_context *ctx, u8 type,
>> +                    const void *payload, size_t size);
>>   ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const 
>> void *params,
>>                     size_t num_params, void *data, size_t size);
>>   #define mipi_dsi_msleep(ctx, delay)    \
>> @@ -432,8 +434,22 @@ void mipi_dsi_dcs_set_tear_on_multi(struct 
>> mipi_dsi_multi_context *ctx,
>>           static const u8 d[] = { cmd, seq };                     \
>>           mipi_dsi_dcs_write_buffer_multi(ctx, d, ARRAY_SIZE(d)); \
>>       } while (0)
>> +/**
>> + * mipi_dsi_dcs_write_long_multi - transmit a DCS long command with 
>> payload
>> + * @ctx: Context for multiple DSI transactions
>> + * @cmd: Commands
>> + * @seq: buffer containing data to be transmitted
>> + */
>> +#define mipi_dsi_dcs_write_long_multi(ctx, cmd, 
>> seq...)                    \
>> +    do {                                                               \
>> +        static const u8 d[] = { cmd, seq };                        \
>> +        mipi_dsi_generic_write_raw_multi(ctx,                      \
>> +                          MIPI_DSI_DCS_LONG_WRITE, \
>> +                          d, ARRAY_SIZE(d));       \
>> +    } while (0)
>> +
>>   /**
>>    * struct mipi_dsi_driver - DSI driver
>>    * @driver: device driver model driver
>>    * @probe: callback for device binding
>>
>> -- 
>> 2.45.0
>>


More information about the dri-devel mailing list