* [RFC PATCH v2 0/2] drm/dsi-mipi: 16-bit Brightness Endianness Fix @ 2023-01-14 1:00 Richard Acayan 2023-01-14 1:00 ` [RFC PATCH v2 1/2] drm/dsi-mipi: Fix byte order of DCS set/get brightness Richard Acayan 2023-01-14 1:00 ` [RFC PATCH v2 2/2] drm/panel: sofef00: Use 16-bit panel brightness Richard Acayan 0 siblings, 2 replies; 5+ messages in thread From: Richard Acayan @ 2023-01-14 1:00 UTC (permalink / raw) To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter, Thierry Reding, Sam Ravnborg, Emil Velikov, Vinay Simha BN, dri-devel, linux-kernel Cc: Daniel Mentz, Caleb Connolly, Richard Acayan Changes since v1: - move 16-bit brightness handling to new functions and revert API change (1/2) - remove Change-Id in compliance with checkpatch.pl (1/2) - separate panel driver changes (2/2) This series adds proper support for 16-bit MIPI DSI brightness and cleans up existing panel drivers. I cannot test the SOFEF00 change, although I tested an equivalent change to an external S6E3FA7 driver generated with the same generator. Both setting and getting works on S6E3FA7. Daniel Mentz (1): drm/dsi-mipi: Fix byte order of DCS set/get brightness Richard Acayan (1): drm/panel: sofef00: Use 16-bit panel brightness drivers/gpu/drm/drm_mipi_dsi.c | 52 +++++++++++++++++++ drivers/gpu/drm/panel/panel-samsung-sofef00.c | 9 +--- include/drm/drm_mipi_dsi.h | 4 ++ 3 files changed, 58 insertions(+), 7 deletions(-) -- 2.39.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v2 1/2] drm/dsi-mipi: Fix byte order of DCS set/get brightness 2023-01-14 1:00 [RFC PATCH v2 0/2] drm/dsi-mipi: 16-bit Brightness Endianness Fix Richard Acayan @ 2023-01-14 1:00 ` Richard Acayan 2023-01-14 1:36 ` Richard Acayan 2023-01-14 1:00 ` [RFC PATCH v2 2/2] drm/panel: sofef00: Use 16-bit panel brightness Richard Acayan 1 sibling, 1 reply; 5+ messages in thread From: Richard Acayan @ 2023-01-14 1:00 UTC (permalink / raw) To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter, Thierry Reding, Sam Ravnborg, Emil Velikov, Vinay Simha BN, dri-devel, linux-kernel Cc: Daniel Mentz, Caleb Connolly, Richard Acayan From: Daniel Mentz <danielmentz@google.com> The MIPI DCS specification demands that brightness values are sent in big endian byte order. It also states that one parameter (i.e. one byte) shall be sent/received for 8 bit wide values, and two parameters shall be used for values that are between 9 and 16 bits wide. Fixes: 1a9d759331b8 ("drm/dsi: Implement DCS set/get display brightness") Signed-off-by: Daniel Mentz <danielmentz@google.com> Change-Id: I24306e21ec6a5ff48ea121d977419a81d5b44152 Link: https://android.googlesource.com/kernel/msm/+/754affd62d0ee268c686c53169b1dbb7deac8550 [richard: fix 16-bit brightness_get] [richard: use separate functions instead of switch/case] Signed-off-by: Richard Acayan <mailingradian@gmail.com> --- drivers/gpu/drm/drm_mipi_dsi.c | 52 ++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 +++ 2 files changed, 56 insertions(+) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 497ef4b6a90a..4bc15fbd009d 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -1224,6 +1224,58 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, } EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness); +/** + * mipi_dsi_dcs_set_display_brightness_large() - sets the 16-bit brightness value + * of the display + * @dsi: DSI peripheral device + * @brightness: brightness value + * + * Return: 0 on success or a negative error code on failure. + */ +int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi, + u16 brightness) +{ + u8 payload[2] = { brightness >> 8, brightness & 0xff }; + ssize_t err; + + err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, + payload, sizeof(payload)); + if (err < 0) + return err; + + return 0; +} +EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness_large); + +/** + * mipi_dsi_dcs_get_display_brightness_large() - gets the current 16-bit + * brightness value of the display + * @dsi: DSI peripheral device + * @brightness: brightness value + * + * Return: 0 on success or a negative error code on failure. + */ +int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi, + u16 *brightness) +{ + u8 brightness_be[2]; + ssize_t err; + + err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, + brightness_be, sizeof(brightness_be)); + if (err <= 0) { + if (err == 0) + err = -ENODATA; + + return err; + } + + *brightness = (brightness_be[0] << 8) | brightness_be[1]; + + return 0; +} +EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness_large); + 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 4f503d99f668..16f30975b22b 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -296,6 +296,10 @@ int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, u16 brightness); int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, u16 *brightness); +int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi, + u16 brightness); +int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi, + u16 *brightness); /** * mipi_dsi_generic_write_seq - transmit data using a generic write packet -- 2.39.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH v2 1/2] drm/dsi-mipi: Fix byte order of DCS set/get brightness 2023-01-14 1:00 ` [RFC PATCH v2 1/2] drm/dsi-mipi: Fix byte order of DCS set/get brightness Richard Acayan @ 2023-01-14 1:36 ` Richard Acayan 0 siblings, 0 replies; 5+ messages in thread From: Richard Acayan @ 2023-01-14 1:36 UTC (permalink / raw) To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter, Thierry Reding, Sam Ravnborg, Emil Velikov, Vinay Simha BN, dri-devel, linux-kernel Cc: Daniel Mentz, Caleb Connolly, Richard Acayan On Fri, Jan 13, 2023 at 08:00:05PM -0500, Richard Acayan wrote: > From: Daniel Mentz <danielmentz@google.com> > > The MIPI DCS specification demands that brightness values are sent in > big endian byte order. It also states that one parameter (i.e. one byte) > shall be sent/received for 8 bit wide values, and two parameters shall > be used for values that are between 9 and 16 bits wide. > > Fixes: 1a9d759331b8 ("drm/dsi: Implement DCS set/get display brightness") > Signed-off-by: Daniel Mentz <danielmentz@google.com> > Change-Id: I24306e21ec6a5ff48ea121d977419a81d5b44152 I need to check which local commits I'm actually emailing... This line will be removed in v3. > Link: https://android.googlesource.com/kernel/msm/+/754affd62d0ee268c686c53169b1dbb7deac8550 > [richard: fix 16-bit brightness_get] > [richard: use separate functions instead of switch/case] > Signed-off-by: Richard Acayan <mailingradian@gmail.com> > --- > drivers/gpu/drm/drm_mipi_dsi.c | 52 ++++++++++++++++++++++++++++++++++ > include/drm/drm_mipi_dsi.h | 4 +++ > 2 files changed, 56 insertions(+) > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c > index 497ef4b6a90a..4bc15fbd009d 100644 > --- a/drivers/gpu/drm/drm_mipi_dsi.c > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > @@ -1224,6 +1224,58 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, > } > EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness); > > +/** > + * mipi_dsi_dcs_set_display_brightness_large() - sets the 16-bit brightness value > + * of the display > + * @dsi: DSI peripheral device > + * @brightness: brightness value > + * > + * Return: 0 on success or a negative error code on failure. > + */ > +int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi, > + u16 brightness) > +{ > + u8 payload[2] = { brightness >> 8, brightness & 0xff }; > + ssize_t err; > + > + err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, > + payload, sizeof(payload)); > + if (err < 0) > + return err; > + > + return 0; > +} > +EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness_large); > + > +/** > + * mipi_dsi_dcs_get_display_brightness_large() - gets the current 16-bit > + * brightness value of the display > + * @dsi: DSI peripheral device > + * @brightness: brightness value > + * > + * Return: 0 on success or a negative error code on failure. > + */ > +int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi, > + u16 *brightness) > +{ > + u8 brightness_be[2]; > + ssize_t err; > + > + err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, > + brightness_be, sizeof(brightness_be)); > + if (err <= 0) { > + if (err == 0) > + err = -ENODATA; > + > + return err; > + } > + > + *brightness = (brightness_be[0] << 8) | brightness_be[1]; > + > + return 0; > +} > +EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness_large); > + > 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 4f503d99f668..16f30975b22b 100644 > --- a/include/drm/drm_mipi_dsi.h > +++ b/include/drm/drm_mipi_dsi.h > @@ -296,6 +296,10 @@ int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, > u16 brightness); > int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, > u16 *brightness); > +int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi, > + u16 brightness); > +int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi, > + u16 *brightness); > > /** > * mipi_dsi_generic_write_seq - transmit data using a generic write packet > -- > 2.39.0 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v2 2/2] drm/panel: sofef00: Use 16-bit panel brightness 2023-01-14 1:00 [RFC PATCH v2 0/2] drm/dsi-mipi: 16-bit Brightness Endianness Fix Richard Acayan 2023-01-14 1:00 ` [RFC PATCH v2 1/2] drm/dsi-mipi: Fix byte order of DCS set/get brightness Richard Acayan @ 2023-01-14 1:00 ` Richard Acayan 2023-01-14 1:30 ` Caleb Connolly 1 sibling, 1 reply; 5+ messages in thread From: Richard Acayan @ 2023-01-14 1:00 UTC (permalink / raw) To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter, Thierry Reding, Sam Ravnborg, Emil Velikov, Vinay Simha BN, dri-devel, linux-kernel Cc: Daniel Mentz, Caleb Connolly, Richard Acayan These panels communicate brightness in big endian. This is not a quirk of the panels themselves, but rather, a part of the MIPI standard. Use the new mipi_dsi_dcs_set_display_brightness_wide() function that properly handles 16-bit brightness instead of doing special processing of the brightness values. Signed-off-by: Richard Acayan <mailingradian@gmail.com> --- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-sofef00.c b/drivers/gpu/drm/panel/panel-samsung-sofef00.c index 1a0d24595faa..014fe350bc59 100644 --- a/drivers/gpu/drm/panel/panel-samsung-sofef00.c +++ b/drivers/gpu/drm/panel/panel-samsung-sofef00.c @@ -10,7 +10,6 @@ #include <linux/of.h> #include <linux/of_device.h> #include <linux/regulator/consumer.h> -#include <linux/swab.h> #include <linux/backlight.h> #include <video/mipi_display.h> @@ -221,13 +220,9 @@ static int sofef00_panel_bl_update_status(struct backlight_device *bl) { struct mipi_dsi_device *dsi = bl_get_data(bl); int err; - u16 brightness; + u16 brightness = (u16)backlight_get_brightness(bl); - brightness = (u16)backlight_get_brightness(bl); - // This panel needs the high and low bytes swapped for the brightness value - brightness = __swab16(brightness); - - err = mipi_dsi_dcs_set_display_brightness(dsi, brightness); + err = mipi_dsi_dcs_set_display_brightness_large(dsi, brightness); if (err < 0) return err; -- 2.39.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH v2 2/2] drm/panel: sofef00: Use 16-bit panel brightness 2023-01-14 1:00 ` [RFC PATCH v2 2/2] drm/panel: sofef00: Use 16-bit panel brightness Richard Acayan @ 2023-01-14 1:30 ` Caleb Connolly 0 siblings, 0 replies; 5+ messages in thread From: Caleb Connolly @ 2023-01-14 1:30 UTC (permalink / raw) To: Richard Acayan, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter, Thierry Reding, Sam Ravnborg, Emil Velikov, Vinay Simha BN, dri-devel, linux-kernel Cc: Daniel Mentz On 14/01/2023 01:00, Richard Acayan wrote: > These panels communicate brightness in big endian. This is not a quirk > of the panels themselves, but rather, a part of the MIPI standard. Use > the new mipi_dsi_dcs_set_display_brightness_wide() function that > properly handles 16-bit brightness instead of doing special processing > of the brightness values. > > Signed-off-by: Richard Acayan <mailingradian@gmail.com> Awesome! Thanks for this series, glad to know this isn't a weird panel quirk aha. This works fine on the OnePlus 6 (the user of this panel), so for both patches: Tested-by: Caleb Connolly <caleb@connolly.tech> > --- > drivers/gpu/drm/panel/panel-samsung-sofef00.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/panel/panel-samsung-sofef00.c b/drivers/gpu/drm/panel/panel-samsung-sofef00.c > index 1a0d24595faa..014fe350bc59 100644 > --- a/drivers/gpu/drm/panel/panel-samsung-sofef00.c > +++ b/drivers/gpu/drm/panel/panel-samsung-sofef00.c > @@ -10,7 +10,6 @@ > #include <linux/of.h> > #include <linux/of_device.h> > #include <linux/regulator/consumer.h> > -#include <linux/swab.h> > #include <linux/backlight.h> > > #include <video/mipi_display.h> > @@ -221,13 +220,9 @@ static int sofef00_panel_bl_update_status(struct backlight_device *bl) > { > struct mipi_dsi_device *dsi = bl_get_data(bl); > int err; > - u16 brightness; > + u16 brightness = (u16)backlight_get_brightness(bl); > > - brightness = (u16)backlight_get_brightness(bl); > - // This panel needs the high and low bytes swapped for the brightness value > - brightness = __swab16(brightness); > - > - err = mipi_dsi_dcs_set_display_brightness(dsi, brightness); > + err = mipi_dsi_dcs_set_display_brightness_large(dsi, brightness); > if (err < 0) > return err; > > -- > 2.39.0 > -- Kind Regards, Caleb ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-14 1:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-01-14 1:00 [RFC PATCH v2 0/2] drm/dsi-mipi: 16-bit Brightness Endianness Fix Richard Acayan 2023-01-14 1:00 ` [RFC PATCH v2 1/2] drm/dsi-mipi: Fix byte order of DCS set/get brightness Richard Acayan 2023-01-14 1:36 ` Richard Acayan 2023-01-14 1:00 ` [RFC PATCH v2 2/2] drm/panel: sofef00: Use 16-bit panel brightness Richard Acayan 2023-01-14 1:30 ` Caleb Connolly
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®