Message ID | 20240628182428.171031-2-tejasvipin76@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | add more multi functions to streamline error handling | expand |
Hi, On Fri, Jun 28, 2024 at 11:25 AM Tejas Vipin <tejasvipin76@gmail.com> wrote: > > +/** > + * mipi_dsi_dcs_set_page_address_multi() - define the column extent of the > + * frame memory accessed by the host processor > + * @ctx: Context for multiple DSI transactions > + * @start: first column of frame memory > + * @end: last column of frame memory nit: "start" and "end" comments should say "first page" and "last page", not "first column" and "last column". The previous function was the one about columns. > + * > + * Like mipi_dsi_dcs_set_page_address() but deals with errors in a way that > + * makes it convenient to make several calls in a row. > + */ > +void mipi_dsi_dcs_set_page_address_multi(struct mipi_dsi_multi_context *ctx, > + u16 start, u16 end) nit: indentation of the above line isn't _quite_ right. Other than the two nits, this looks fine to me, but I'd prefer if someone else provides an "Ack" in addition to me that they're OK adding these extra "multi" functions. Both Dmitry and Linus W were involved in the original "multi" functions, so maybe they'd be willing to offer their opinions?
On 7/9/24 5:50 AM, Doug Anderson wrote: > Hi, > > On Fri, Jun 28, 2024 at 11:25 AM Tejas Vipin <tejasvipin76@gmail.com> wrote: >> >> +/** >> + * mipi_dsi_dcs_set_page_address_multi() - define the column extent of the >> + * frame memory accessed by the host processor >> + * @ctx: Context for multiple DSI transactions >> + * @start: first column of frame memory >> + * @end: last column of frame memory > > nit: "start" and "end" comments should say "first page" and "last > page", not "first column" and "last column". The previous function was > the one about columns. > >> + * >> + * Like mipi_dsi_dcs_set_page_address() but deals with errors in a way that >> + * makes it convenient to make several calls in a row. >> + */ >> +void mipi_dsi_dcs_set_page_address_multi(struct mipi_dsi_multi_context *ctx, >> + u16 start, u16 end) > > nit: indentation of the above line isn't _quite_ right. > > > Other than the two nits, this looks fine to me, but I'd prefer if > someone else provides an "Ack" in addition to me that they're OK > adding these extra "multi" functions. Both Dmitry and Linus W were > involved in the original "multi" functions, so maybe they'd be willing > to offer their opinions? I think a better way to go forward with multi style functions is to use macros. All the multi style functions are basically exactly the same with the only difference being the function called internally and the dev_err. This can be represented in the form of a macro, and would save on a ton of otherwise redundant code, while also allowing us to "convert" any function to multi style as and when we please. We would ideally have 2 macros, one for the main functions where we desire to modify accum_err on an error arising, and another macro that just checks accum_err to see if the function should be a no op. If you guys think this is a good idea, I'll work on the macros and do the multi conversions in this new way.
Hi, On Tue, Jul 9, 2024 at 4:18 AM Tejas Vipin <tejasvipin76@gmail.com> wrote: > > On 7/9/24 5:50 AM, Doug Anderson wrote: > > Hi, > > > > On Fri, Jun 28, 2024 at 11:25 AM Tejas Vipin <tejasvipin76@gmail.com> wrote: > >> > >> +/** > >> + * mipi_dsi_dcs_set_page_address_multi() - define the column extent of the > >> + * frame memory accessed by the host processor > >> + * @ctx: Context for multiple DSI transactions > >> + * @start: first column of frame memory > >> + * @end: last column of frame memory > > > > nit: "start" and "end" comments should say "first page" and "last > > page", not "first column" and "last column". The previous function was > > the one about columns. > > > >> + * > >> + * Like mipi_dsi_dcs_set_page_address() but deals with errors in a way that > >> + * makes it convenient to make several calls in a row. > >> + */ > >> +void mipi_dsi_dcs_set_page_address_multi(struct mipi_dsi_multi_context *ctx, > >> + u16 start, u16 end) > > > > nit: indentation of the above line isn't _quite_ right. > > > > > > Other than the two nits, this looks fine to me, but I'd prefer if > > someone else provides an "Ack" in addition to me that they're OK > > adding these extra "multi" functions. Both Dmitry and Linus W were > > involved in the original "multi" functions, so maybe they'd be willing > > to offer their opinions? > > I think a better way to go forward with multi style functions is to > use macros. All the multi style functions are basically exactly the > same with the only difference being the function called internally > and the dev_err. This can be represented in the form of a macro, and > would save on a ton of otherwise redundant code, while also allowing > us to "convert" any function to multi style as and when we please. > > We would ideally have 2 macros, one for the main functions where we > desire to modify accum_err on an error arising, and another macro that > just checks accum_err to see if the function should be a no op. > > If you guys think this is a good idea, I'll work on the macros and > do the multi conversions in this new way. I had a similar thought but I wasn't sure how easy it would be. If you want to prototype it out and send out patches if they look good then that'd be nice. We'd want to make sure that we actually generate functions for the "multi" variants since we don't want all that inline code on every caller, but generating those functions with a macro does seem like it would work. I guess you'd also need to include some sort of string for use in the error messages. -Doug
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index a471c46f5ca6..3f7fe734b684 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -1639,6 +1639,170 @@ void mipi_dsi_dcs_set_tear_on_multi(struct mipi_dsi_multi_context *ctx, } EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on_multi); +/** + * mipi_dsi_turn_on_peripheral_multi() - sends a Turn On Peripheral command + * @ctx: Context for multiple DSI transactions + * + * Like mipi_dsi_turn_on_peripheral() but deals with errors in a way that + * makes it convenient to make several calls in a row. + */ +void mipi_dsi_turn_on_peripheral_multi(struct mipi_dsi_multi_context *ctx) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + ssize_t ret; + + if (ctx->accum_err) + return; + + ret = mipi_dsi_turn_on_peripheral(dsi); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "Failed to turn on peripheral: %d\n", + ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dsi_turn_on_peripheral_multi); + +/** + * mipi_dsi_dcs_soft_reset_multi() - perform a software reset of the display module + * @ctx: Context for multiple DSI transactions + * + * Like mipi_dsi_dcs_soft_reset() but deals with errors in a way that + * makes it convenient to make several calls in a row. + */ +void mipi_dsi_dcs_soft_reset_multi(struct mipi_dsi_multi_context *ctx) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + ssize_t ret; + + if (ctx->accum_err) + return; + + ret = mipi_dsi_dcs_soft_reset(dsi); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "Failed to mipi_dsi_dcs_soft_reset: %d\n", + ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset_multi); + +/** + * mipi_dsi_dcs_set_display_brightness_multi() - sets the brightness value of + * the display + * @ctx: Context for multiple DSI transactions + * @brightness: brightness value + * + * Like mipi_dsi_dcs_set_display_brightness() but deals with errors in a way that + * makes it convenient to make several calls in a row. + */ +void mipi_dsi_dcs_set_display_brightness_multi(struct mipi_dsi_multi_context *ctx, + u16 brightness) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + ssize_t ret; + + if (ctx->accum_err) + return; + + ret = mipi_dsi_dcs_set_display_brightness(dsi, brightness); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "Failed to write display brightness: %d\n", + ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness_multi); + +/** + * mipi_dsi_dcs_set_pixel_format_multi() - sets the pixel format for the RGB image + * data used by the interface + * @ctx: Context for multiple DSI transactions + * @format: pixel format + * + * Like mipi_dsi_dcs_set_pixel_format() but deals with errors in a way that + * makes it convenient to make several calls in a row. + */ +void mipi_dsi_dcs_set_pixel_format_multi(struct mipi_dsi_multi_context *ctx, + u8 format) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + ssize_t ret; + + if (ctx->accum_err) + return; + + ret = mipi_dsi_dcs_set_pixel_format(dsi, format); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "Failed to set pixel format: %d\n", + ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format_multi); + +/** + * mipi_dsi_dcs_set_column_address_multi() - define the column extent of the + * frame memory accessed by the host processor + * @ctx: Context for multiple DSI transactions + * @start: first column of frame memory + * @end: last column of frame memory + * + * Like mipi_dsi_dcs_set_column_address() but deals with errors in a way that + * makes it convenient to make several calls in a row. + */ +void mipi_dsi_dcs_set_column_address_multi(struct mipi_dsi_multi_context *ctx, + u16 start, u16 end) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + ssize_t ret; + + if (ctx->accum_err) + return; + + ret = mipi_dsi_dcs_set_column_address(dsi, start, end); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "Failed to set column address: %d\n", + ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address_multi); + +/** + * mipi_dsi_dcs_set_page_address_multi() - define the column extent of the + * frame memory accessed by the host processor + * @ctx: Context for multiple DSI transactions + * @start: first column of frame memory + * @end: last column of frame memory + * + * Like mipi_dsi_dcs_set_page_address() but deals with errors in a way that + * makes it convenient to make several calls in a row. + */ +void mipi_dsi_dcs_set_page_address_multi(struct mipi_dsi_multi_context *ctx, + u16 start, u16 end) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + ssize_t ret; + + if (ctx->accum_err) + return; + + ret = mipi_dsi_dcs_set_page_address(dsi, start, end); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "Failed to set page address: %d\n", + ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address_multi); + static int mipi_dsi_drv_probe(struct device *dev) { struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver); diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 71d121aeef24..203b5d53d58f 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -358,6 +358,16 @@ void mipi_dsi_dcs_set_display_off_multi(struct mipi_dsi_multi_context *ctx); void mipi_dsi_dcs_set_display_on_multi(struct mipi_dsi_multi_context *ctx); void mipi_dsi_dcs_set_tear_on_multi(struct mipi_dsi_multi_context *ctx, enum mipi_dsi_dcs_tear_mode mode); +void mipi_dsi_turn_on_peripheral_multi(struct mipi_dsi_multi_context *ctx); +void mipi_dsi_dcs_soft_reset_multi(struct mipi_dsi_multi_context *ctx); +void mipi_dsi_dcs_set_display_brightness_multi(struct mipi_dsi_multi_context *ctx, + u16 brightness); +void mipi_dsi_dcs_set_pixel_format_multi(struct mipi_dsi_multi_context *ctx, + u8 format); +void mipi_dsi_dcs_set_column_address_multi(struct mipi_dsi_multi_context *ctx, + u16 start, u16 end); +void mipi_dsi_dcs_set_page_address_multi(struct mipi_dsi_multi_context *ctx, + u16 start, u16 end); /** * mipi_dsi_generic_write_seq - transmit data using a generic write packet
Add more functions that can benefit from being multi style, which reduces code size in panels where they appear. Signed-off-by: Tejas Vipin <tejasvipin76@gmail.com> --- drivers/gpu/drm/drm_mipi_dsi.c | 164 +++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 10 ++ 2 files changed, 174 insertions(+)