drm: Add driver for Solomon SSD130X OLED displays
Subsystems (6)
Javier Martinez Canillas
maintainerv3 cover drm: Add driver for Solomon SSD130X OLED displays
This patch series adds a DRM driver for the Solomon OLED SSD1305, SSD1306, SSD1307 and SSD1309 displays. It is a port of the ssd1307fb fbdev driver.
Using the DRM fb emulation, all the tests from Geert Uytterhoeven's fbtest
(https://git.kernel.org/pub/scm/linux/kernel/git/geert/fbtest.git) passes.
I've also tested it using the display as a VT output and even though fbcon seems to work, it is mostly unusable on a 128x64 SSD1306 display.
This is a v3 that addresses all the issues pointed in v2. Thanks a lot to everyone that gave me feedback and reviews.
Patch #1 splits per-line conversion logic in drm_fb_xrgb8888_to_gray8() to a separate drm_fb_xrgb8888_to_gray8_line() helper function.
Patch #2 adds two new helpers, drm_fb_gray8_to_mono_reversed() to convert from grayscale to monochrome and a drm_fb_xrgb8888_to_mono_reversed() to convert from XR24 to monochrome. The latter internally converts each line first to gray8 and then to reversed monochrome.
Patch #3 adds the driver. This only has the core support but doesn't have any bus specific code, separate drivers are needed for the transport used.
Patch #4 adds a driver to use the I2C bus to communicate with the device and patch #5 adds a similar driver for SPI. This one is a WIP and wasn't tested. I'm including for people to test and modify for their displays.
Patch #6 just adds a MAINTAINERS entry for the DRM driver and patch #7 adds myself as a co-maintainer of the existing Device Tree binding for ssd1307fb, since the same is shared between the fbdev and DRM drivers.
Best regards,
Javier
Changes in v3:
- Add a drm_fb_xrgb8888_to_gray8_line() helper function (Thomas Zimmermann)
- Also add a drm_fb_xrgb8888_to_mono_reversed() helper (Thomas Zimmermann)
- Split lines copy to drm_fb_gray8_to_mono_reversed_line() (Thomas Zimmermann)
- Handle case where the source buffer is not aligned to 8 (Thomas Zimmermann)
- Move driver from tiny sub-dir to drivers/gpu/drm/solomon (Sam Ravnborg)
- Split driver in a bus agnostic core and bus specific (Andy Shevchenko)
- Use regmap to access the chip registers (Andy Shevchenko)
- Remove unnecessary blank lines (Andy Shevchenko)
- Remove unneeded inline specifier in functions (Andy Shevchenko)
- Add a comment about always returning a single mode (Andy Shevchenko)
- Change write command logic to use do while loop (Andy Shevchenko)
- Use "firmware description" instead of "device tree" (Andy Shevchenko)
- Use return foo() instead of returning the return value (Andy Shevchenko)
- Don't split lines longer than 80 chars if makes less readable (Andy Shevchenko)
- Remove redundant else statements in .mode_valid callback (Andy Shevchenko)
- Rename powero{n,ff}() functions to power_o{n,ff)() (Andy Shevchenko)
- Use dev_err_probe() to prevent spam logs on probe deferral (Andy Shevchenko)
- Remove ',' after sentinel terminator in array (Andy Shevchenko)
- Fix a bug when doing partial updates (Geert Uytterhoeven)
- Add a separate driver for SSD130X chips I2C support (Andy Shevchenko)
- Add a separate driver for SSD130X chips SPI support (Andy Shevchenko)
- Adapt MAINTAINERS entry to point to the new drivers/gpu/drm/solomon directory.
Changes in v2:
- Drop patch that was adding a DRM_MODE_CONNECTOR_I2C type.
- Invert order of backlight {en,dis}able and display {on,off} (Sam Ravnborg)
- Don't clear the screen and turn on display on probe (Sam Ravnborg)
- Use backlight_get_brightness() macro to get BL brightness (Sam Ravnborg)
- Use dev managed version of devm_backlight_device_register() (Sam Ravnborg)
- Use dev_name(dev) for backlight name instead of an array (Sam Ravnborg)
- Drop the .get_brightness callback since isn't needed (Sam Ravnborg)
- Rename driver to ssd130x since supports a display family (Thomas Zimmermann)
- Drop the TINY prefix from the Kconfig symbol (Thomas Zimmermann)
- Sort the Kconfig symbol dependencies alphabetically (Thomas Zimmermann)
- Rename struct ssd130x_array to struct ssd130x_i2c_msg (Thomas Zimmermann)
- Rename struct ssd130x_i2c_msg .type member to .cmd (Thomas Zimmermann)
- Use sizeof(*foo) instead of sizeof(struct foo) (Thomas Zimmermann)
- Use struct_size() macro to calculate sizeof(*foo) + len (Thomas Zimmermann)
- Use kcalloc() instead of kmalloc_array() + memset() (Thomas Zimmermann)
- Use shadow plane helpers virtual screen support (Thomas Zimmermann)
- Remove unused goto label in ssd1307_fb_blit_rect() (Thomas Zimmermann)
- Use drm_set_preferred_mode() inset of manually set (Thomas Zimmermann)
- Use shadow plane helpers virtual screen support (Thomas Zimmermann)
- Remove unused goto label in ssd1307_fb_blit_rect() (Thomas Zimmermann)
- Use drm_set_preferred_mode() inset of manually set (Thomas Zimmermann)
- Reorganize code in probe to make it more legible (Thomas Zimmermann)
- ssd130x_write_cmd() uses varargs to simplify I2C code (Thomas Zimmermann)
- Move regulator/pwm init logic to display pipe enable callback.
- Add Sam Ravnborg's acked-by to patch adding a MAINTAINERS entry (Sam Ravnborg)
- Add myself as co-maintainer of the ssd1370fb DT binding (Sam Ravnborg).
Javier Martinez Canillas (7):
drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line() drm/format-helper: Add drm_fb_{xrgb8888,gray8}_to_mono_reversed()
drm: Add driver for Solomon SSD130X OLED displays drm/solomon: Add SSD130X OLED displays I2C support
(WIP) drm/solomon: Add SSD130X OLED displays SPI support
MAINTAINERS: Add entry for Solomon SSD130X OLED displays DRM driver
dt-bindings: display: ssd1307fb: Add myself as binding co-maintainer
.../bindings/display/solomon,ssd1307fb.yaml | 1 + MAINTAINERS | 7 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_format_helper.c | 188 +++- drivers/gpu/drm/solomon/Kconfig | 30 + drivers/gpu/drm/solomon/Makefile | 3 + drivers/gpu/drm/solomon/ssd130x-i2c.c | 117 +++ drivers/gpu/drm/solomon/ssd130x-spi.c | 114 +++ drivers/gpu/drm/solomon/ssd130x.c | 823 ++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.h | 76 ++ include/drm/drm_format_helper.h | 8 + 12 files changed, 1358 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/solomon/Kconfig create mode 100644 drivers/gpu/drm/solomon/Makefile create mode 100644 drivers/gpu/drm/solomon/ssd130x-i2c.c create mode 100644 drivers/gpu/drm/solomon/ssd130x-spi.c create mode 100644 drivers/gpu/drm/solomon/ssd130x.c create mode 100644 drivers/gpu/drm/solomon/ssd130x.h
Signature · 1 line
2.34.1
Javier Martinez Canillas
maintainerPATCH v3 1/7 drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line()
Pull the per-line conversion logic into a separate helper function.
This will allow to do line-by-line conversion in other helpers that convert to a gray8 format.
---
Changes in v3:
- Add a drm_fb_xrgb8888_to_gray8_line() helper function (Thomas Zimmermann)
drivers/gpu/drm/drm_format_helper.c | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_format_helper.c +19 -12
@@ -464,6 +464,21 @@ void drm_fb_xrgb8888_to_xrgb2101010_toio(void __iomem *dst, }EXPORT_SYMBOL (drm_fb_xrgb8888_to_xrgb2101010_toio); +static void drm_fb_xrgb8888_to_gray8_line (u8 *dst,const u32 *src,unsigned int pixels) +{ +unsigned int x; + +for (x =0 ; x < pixels; x++) { +u8 r = (*src &0x00ff0000 ) >>16 ; +u8 g = (*src &0x0000ff00 ) >>8 ; +u8 b = *src &0x000000ff ; + +/* ITU BT.601: Y = 0.299 R + 0.587 G + 0.114 B */ + *dst++ = (3 * r +6 * g + b) /10 ; + src++; + } +} +/** * drm_fb_xrgb8888_to_gray8 - Convert XRGB8888 to grayscale * @dst: 8-bit grayscale destination buffer
@@ -484,8 +499,9 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010_toio);void drm_fb_xrgb8888_to_gray8 (void *dst,unsigned int dst_pitch,const void *vaddr,const struct drm_framebuffer *fb,const struct drm_rect *clip) { -unsigned int len = (clip->x2 - clip->x1) *sizeof (u32); -unsigned int x, y; +unsigned int linepixels = clip->x2 - clip->x1; +unsigned int len = linepixels *sizeof (u32); +unsigned int y;void *buf;u8 *dst8;u32 *src32;
@@ -508,16 +524,7 @@ void drm_fb_xrgb8888_to_gray8(void *dst, unsigned int dst_pitch, const void *vadfor (y = clip->y1; y < clip->y2; y++) { dst8 = dst; src32 =memcpy (buf, vaddr, len); -for (x = clip->x1; x < clip->x2; x++) { -u8 r = (*src32 &0x00ff0000 ) >>16 ; -u8 g = (*src32 &0x0000ff00 ) >>8 ; -u8 b = *src32 &0x000000ff ; - -/* ITU BT.601: Y = 0.299 R + 0.587 G + 0.114 B */ - *dst8++ = (3 * r +6 * g + b) /10 ; - src32++; - } - +drm_fb_xrgb8888_to_gray8_line (dst8, src32, linepixels); vaddr += fb->pitches[0 ]; dst += dst_pitch; }
Signature · 1 line
2.34.1
Javier Martinez Canillas
maintainerPATCH v3 2/7 drm/format-helper: Add drm_fb_{xrgb8888,gray8}_to_mono_reversed()
In reply to Javier Martinez CanillasAdd support to convert XR24 and 8-bit grayscale to reversed monochrome for drivers that control monochromatic panels, that only have 1 bit per pixel.
The drm_fb_gray8_to_mono_reversed() helper was based on the function that does the same in the drivers/gpu/drm/tiny/repaper.c driver.
---
Changes in v3:
- Also add a drm_fb_xrgb8888_to_mono_reversed() helper (Thomas Zimmermann)
- Split lines copy to drm_fb_gray8_to_mono_reversed_line() (Thomas Zimmermann)
- Handle case where the source buffer is not aligned to 8 (Thomas Zimmermann)
drivers/gpu/drm/drm_format_helper.c | 157 ++++++++++++++++++++++++++++ include/drm/drm_format_helper.h | 8 ++ 2 files changed, 165 insertions(+)
drivers/gpu/drm/drm_format_helper.c +157 -0
@@ -591,3 +591,160 @@ int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_forreturn -EINVAL ; }EXPORT_SYMBOL (drm_fb_blit_toio); + +static void drm_fb_gray8_to_mono_reversed_line (u8 *dst,const u8 *src,unsigned int pixels, +unsigned int start_offset,unsigned int end_offset) +{ +unsigned int xb, i; + +for (xb =0 ; xb < pixels; xb++) { +unsigned int start =0 , end =8 ; +u8 byte =0x00 ; + +if (xb ==0 && start_offset) + start = start_offset; + +if (xb == pixels -1 && end_offset) + end = end_offset; + +for (i = start; i < end; i++) { +unsigned int x = xb *8 + i; + + byte >>=1 ; +if (src[x] >>7 ) + byte |=BIT (7 ); + } + *dst++ = byte; + } +} + +/** +* drm_fb_gray8_to_mono_reversed - Convert grayscale to reversed monochrome +* @dst: reversed monochrome destination buffer +* @dst_pitch: Number of bytes between two consecutive scanlines within dst +* @src: 8-bit grayscale source buffer +* @fb: DRM framebuffer +* @clip: Clip rectangle area to copy +* +* DRM doesn't have native monochrome or grayscale support. +* Such drivers can announce the commonly supported XR24 format to userspace +* and use drm_fb_xrgb8888_to_gray8() to convert to grayscale and then this +* helper function to convert to the native format. +*/ +void drm_fb_gray8_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *vaddr, +const struct drm_framebuffer *fb, +const struct drm_rect *clip) +{ + +unsigned int linepixels =drm_rect_width (clip); +unsigned int lines =drm_rect_height (clip); +unsigned int start_offset, end_offset; +unsigned int y; +const u8 *gray8 = vaddr; +u8 *mono = dst; + +/* +* The reversed mono destination buffer contains 1 bit per pixel +* and destination scanlines have to be in multiple of 8 pixels. +*/ +if (!dst_pitch) + dst_pitch =DIV_ROUND_UP (linepixels,8 ); + +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +* +* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/ + start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ; + +for (y =0 ; y < lines; y++) { +drm_fb_gray8_to_mono_reversed_line (mono, gray8, dst_pitch, + start_offset, end_offset); + gray8 += fb->pitches[0 ]; + mono += dst_pitch; + } +} + +/** +* drm_fb_xrgb8888_to_mono_reversed - Convert XRGB8888 to reversed monochrome +* @dst: reversed monochrome destination buffer +* @dst_pitch: Number of bytes between two consecutive scanlines within dst +* @src: XRGB8888 source buffer +* @fb: DRM framebuffer +* @clip: Clip rectangle area to copy +* +* DRM doesn't have native monochrome support. +* Such drivers can announce the commonly supported XR24 format to userspace +* and use this function to convert to the native format. +* +* This function uses drm_fb_xrgb8888_to_gray8() to convert to grayscale and +* then the result is converted from grayscale to reversed monohrome. +*/ +void drm_fb_xrgb8888_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *vaddr, +const struct drm_framebuffer *fb,const struct drm_rect *clip) +{ +unsigned int linepixels =drm_rect_width (clip); +unsigned int lines = clip->y2 - clip->y1; +unsigned int cpp = fb->format->cpp[0 ]; +unsigned int len_src32 = linepixels * cpp; +unsigned int start_offset, end_offset; +unsigned int y; +u8 *mono = dst, *gray8; +u32 *src32; + +if (WARN_ON (fb->format->format !=DRM_FORMAT_XRGB8888 )) +return ; + +/* +* The reversed mono destination buffer contains 1 bit per pixel +* and destination scanlines have to be in multiple of 8 pixels. +*/ +if (!dst_pitch) + dst_pitch =DIV_ROUND_UP (linepixels,8 ); + +/* +* The cma memory is write-combined so reads are uncached. +* Speed up by fetching one line at a time. +*/ + src32 =kmalloc (len_src32,GFP_KERNEL ); +if (!src32) +return ; + +/* +* Copies are done line-by-line, allocate an intermediate +* buffer to copy the gray8 lines and then convert to mono. +*/ + gray8 =kmalloc (linepixels,GFP_KERNEL ); +if (!gray8) + goto free_src32; + +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +* +* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/ + start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ; + + vaddr +=clip_offset (clip, fb->pitches[0 ], cpp); +for (y =0 ; y < lines; y++) { + src32 =memcpy (src32, vaddr, len_src32); +drm_fb_xrgb8888_to_gray8_line (gray8, src32, linepixels); +drm_fb_gray8_to_mono_reversed_line (mono, gray8, dst_pitch, + start_offset, end_offset); + vaddr += fb->pitches[0 ]; + mono += dst_pitch; + } + +kfree (gray8); +free_src32: +kfree (src32); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_mono_reversed);
include/drm/drm_format_helper.h +8 -0
@@ -43,4 +43,12 @@ int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for const void *vmap, const struct drm_framebuffer *fb, const struct drm_rect *rect); +void drm_fb_gray8_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *src, +const struct drm_framebuffer *fb, +const struct drm_rect *clip); + +void drm_fb_xrgb8888_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *src, +const struct drm_framebuffer *fb, +const struct drm_rect *clip); +#endif /* __LINUX_DRM_FORMAT_HELPER_H */
Signature · 1 line
2.34.1
Thomas Zimmermann
maintainerRe: [PATCH v3 2/7] drm/format-helper: Add drm_fb_{xrgb8888, gray8}_to_mono_reversed()
Hi
Am 09.02.22 um 10:03 schrieb Javier Martinez Canillas:
Quoted 31 lines
Add support to convert XR24 and 8-bit grayscale to reversed monochrome for drivers that control monochromatic panels, that only have 1 bit per pixel.
The
drm_fb_gray8_to_mono_reversed()helper was based on the function that does the same in thedrivers/gpu/drm/tiny/repaper.cdriver.Signed-off-by Javier Martinez Canillas <[email protected]>---
Changes in v3:
- Also add adrm_fb_xrgb8888_to_mono_reversed()helper (Thomas Zimmermann)
- Split lines copy todrm_fb_gray8_to_mono_reversed_line()(Thomas Zimmermann)
- Handle case where the source buffer is not aligned to 8 (Thomas Zimmermann)drivers/gpu/drm/drm_format_helper.c | 157 ++++++++++++++++++++++++++++ include/drm/drm_format_helper.h | 8 ++ 2 files changed, 165 insertions(+)drivers/gpu/drm/drm_format_helper.c +5
-0@@ -591,3 +591,160 @@ int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_forreturn -EINVAL ; }EXPORT_SYMBOL (drm_fb_blit_toio); + +static void drm_fb_gray8_to_mono_reversed_line (u8 *dst,const u8 *src,unsigned int pixels, +unsigned int start_offset,unsigned int end_offset) +{ +unsigned int xb, i;
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 608
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+ +for (xb =0 ; xb < pixels; xb++) { +unsigned int start =0 , end =8 ; +u8 byte =0x00 ; + +if (xb ==0 && start_offset) + start = start_offset; + +if (xb == pixels -1 && end_offset) + end = end_offset;
end_offset should be called end_len, because it is the number of bits in the final byte; but not the offset of the final bit.
Quoted 52 lines
drivers/gpu/drm/drm_format_helper.c +52
-0+ +for (i = start; i < end; i++) { +unsigned int x = xb *8 + i; + + byte >>=1 ; +if (src[x] >>7 ) + byte |=BIT (7 ); + } + *dst++ = byte; + } +} + +/** +* drm_fb_gray8_to_mono_reversed - Convert grayscale to reversed monochrome +* @dst: reversed monochrome destination buffer +* @dst_pitch: Number of bytes between two consecutive scanlines within dst +* @src: 8-bit grayscale source buffer +* @fb: DRM framebuffer +* @clip: Clip rectangle area to copy +* +* DRM doesn't have native monochrome or grayscale support. +* Such drivers can announce the commonly supported XR24 format to userspace +* and use drm_fb_xrgb8888_to_gray8() to convert to grayscale and then this +* helper function to convert to the native format. +*/ +void drm_fb_gray8_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *vaddr, +const struct drm_framebuffer *fb, +const struct drm_rect *clip) +{ + +unsigned int linepixels =drm_rect_width (clip); +unsigned int lines =drm_rect_height (clip); +unsigned int start_offset, end_offset; +unsigned int y; +const u8 *gray8 = vaddr; +u8 *mono = dst; + +/* +* The reversed mono destination buffer contains 1 bit per pixel +* and destination scanlines have to be in multiple of 8 pixels. +*/ +if (!dst_pitch) + dst_pitch =DIV_ROUND_UP (linepixels,8 ); + +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +* +* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 670
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+ start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ; + +for (y =0 ; y < lines; y++) { +drm_fb_gray8_to_mono_reversed_line (mono, gray8, dst_pitch, + start_offset, end_offset); + gray8 += fb->pitches[0 ]; + mono += dst_pitch; + } +}
Do you really need that function. It's not exported and if it's not otherwise used, I'd just remove it. We don't keep unused interfaces around.
Quoted 27 lines
drivers/gpu/drm/drm_format_helper.c +27
-0+ +/** +* drm_fb_xrgb8888_to_mono_reversed - Convert XRGB8888 to reversed monochrome +* @dst: reversed monochrome destination buffer +* @dst_pitch: Number of bytes between two consecutive scanlines within dst +* @src: XRGB8888 source buffer +* @fb: DRM framebuffer +* @clip: Clip rectangle area to copy +* +* DRM doesn't have native monochrome support. +* Such drivers can announce the commonly supported XR24 format to userspace +* and use this function to convert to the native format. +* +* This function uses drm_fb_xrgb8888_to_gray8() to convert to grayscale and +* then the result is converted from grayscale to reversed monohrome. +*/ +void drm_fb_xrgb8888_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *vaddr, +const struct drm_framebuffer *fb,const struct drm_rect *clip) +{ +unsigned int linepixels =drm_rect_width (clip); +unsigned int lines = clip->y2 - clip->y1; +unsigned int cpp = fb->format->cpp[0 ]; +unsigned int len_src32 = linepixels * cpp; +unsigned int start_offset, end_offset; +unsigned int y; +u8 *mono = dst, *gray8; +u32 *src32;
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 707
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+ +if (WARN_ON (fb->format->format !=DRM_FORMAT_XRGB8888 )) +return ; + +/* +* The reversed mono destination buffer contains 1 bit per pixel +* and destination scanlines have to be in multiple of 8 pixels. +*/ +if (!dst_pitch) + dst_pitch =DIV_ROUND_UP (linepixels,8 );
I'd do a warn_once if (dst_pitch % 8 != 0).
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 711
Quoted 4 lines
drivers/gpu/drm/drm_format_helper.c +4
-0+ +/* +* The cma memory is write-combined so reads are uncached. +* Speed up by fetching one line at a time.
I once had a patchset that adds caching information to struct dma_buf_map (soon to be named struct iosys_map). Blitting helpers would be able to enable/disable this optimization as needed.
However, your driver doesn't use CMA. It's backed by SHMEM. Do you really want to keep that code in?
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 723
Quoted 12 lines
drivers/gpu/drm/drm_format_helper.c +12
-0+*/ + src32 =kmalloc (len_src32,GFP_KERNEL ); +if (!src32) +return ; + +/* +* Copies are done line-by-line, allocate an intermediate +* buffer to copy the gray8 lines and then convert to mono. +*/ + gray8 =kmalloc (linepixels,GFP_KERNEL ); +if (!gray8) + goto free_src32;
If might be faster to allocate both buffers in one step and set the pointers into the allocated buffer.
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 662
Quoted 11 lines
drivers/gpu/drm/drm_format_helper.c +11
-0+ +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +* +* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/ + start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ;
end_len, again. If you have 1 single bit set in the final byte, the offset is 0, but the length is 1.
Best regards
Thomas
Quoted 33 lines
drivers/gpu/drm/drm_format_helper.c +16
-0+ + vaddr +=clip_offset (clip, fb->pitches[0 ], cpp); +for (y =0 ; y < lines; y++) { + src32 =memcpy (src32, vaddr, len_src32); +drm_fb_xrgb8888_to_gray8_line (gray8, src32, linepixels); +drm_fb_gray8_to_mono_reversed_line (mono, gray8, dst_pitch, + start_offset, end_offset); + vaddr += fb->pitches[0 ]; + mono += dst_pitch; + } + +kfree (gray8); +free_src32: +kfree (src32); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_mono_reversed);include/drm/drm_format_helper.h +8
-0@@ -43,4 +43,12 @@ int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for const void *vmap, const struct drm_framebuffer *fb, const struct drm_rect *rect); +void drm_fb_gray8_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *src, +const struct drm_framebuffer *fb, +const struct drm_rect *clip); + +void drm_fb_xrgb8888_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *src, +const struct drm_framebuffer *fb, +const struct drm_rect *clip); +#endif /* __LINUX_DRM_FORMAT_HELPER_H */
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Javier Martinez Canillas
maintainerRe: [PATCH v3 2/7] drm/format-helper: Add drm_fb_{xrgb8888, gray8}_to_mono_reversed()
Hello Thomas,
Thanks a lot for your feedback.
Quoted 2 lines · Thomas Zimmermann
Hi
[snip]
Quoted 7 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 608
Quoted 3 lines
drivers/gpu/drm/drm_format_helper.c +3
-0+ +if (xb == pixels -1 && end_offset) + end = end_offset;
end_offsetshould be calledend_len, because it is the number of bits in the final byte; but not the offset of the final bit.
Indeed.
[snip]
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/drm_format_helper.c +3
-0+void drm_fb_gray8_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *vaddr, +const struct drm_framebuffer *fb, +const struct drm_rect *clip)
[snip]
Quoted 4 lines
Do you really need that function. It's not exported and if it's not otherwise used, I'd just remove it. We don't keep unused interfaces around.
At the end after your suggestion of doing line-per-line conversions it is not needed, but since I already typed it and we were talking about adding other formats besides the fake XRGB8888 as an optimization (R8 for grayscale and Dx or something like that for reversed mono), I thought that would be useful to have it as a helper.
Also other drivers that want to advertise a R8 format could just use it and not having to add their own helper. But I'm happy to drop it in v4 if you think that's better to not have unused helpers.
It could be taken from this patch-set anyways if someone wants to wire the needed support for R8.
[snip]
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 651
Quoted 7 lines
drivers/gpu/drm/drm_format_helper.c +7
-0+ +/* +* The reversed mono destination buffer contains 1 bit per pixel +* and destination scanlines have to be in multiple of 8 pixels. +*/ +if (!dst_pitch) + dst_pitch =DIV_ROUND_UP (linepixels,8 );I'd do a
warn_onceif (dst_pitch% 8 != 0).
Agreed. I'll add a warning an mention that will be rounded up.
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 711
Quoted 5 lines
drivers/gpu/drm/drm_format_helper.c +4
-0+ +/* +* The cma memory is write-combined so reads are uncached. +* Speed up by fetching one line at a time. I once had a patchset that adds caching information to struct
dma_buf_map(soon to be named structiosys_map). Blitting helpers would be able to enable/disable this optimization as needed.
Quoted 3 lines
However, your driver doesn't use CMA. It's backed by SHMEM. Do you really want to keep that code in?
It doesn't but the repaper does. And since the plan was to make that driver to use the helper instead of having their own, I wanted to also make sure that would work well with CMA.
Quoted 17 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 723
Quoted 13 lines
drivers/gpu/drm/drm_format_helper.c +12
-0+*/ + src32 =kmalloc (len_src32,GFP_KERNEL ); +if (!src32) +return ; + +/* +* Copies are done line-by-line, allocate an intermediate +* buffer to copy the gray8 lines and then convert to mono. +*/ + gray8 =kmalloc (linepixels,GFP_KERNEL ); +if (!gray8) + goto free_src32;If might be faster to allocate both buffers in one step and set the pointers into the allocated buffer.
Not sure I got this. Do you mean to have a single buffer with length linepixels + len_src32 and point src32 and gray8 to the same buffer ?
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/drm_format_helper.c +6
-0+ +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +*
Quoted 9 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 662
Quoted 5 lines
drivers/gpu/drm/drm_format_helper.c +5
-0+* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/ + start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ;
end_len, again. If you have 1 single bit set in the final byte, the offset is 0, but the length is 1.
Agreed, will change it too.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Re: [PATCH v3 2/7] drm/format-helper: Add drm_fb_{xrgb8888, gray8}_to_mono_reversed()
Hi
Am 09.02.22 um 14:26 schrieb Javier Martinez Canillas:
Quoted 39 lines
Hello Thomas,
Thanks a lot for your feedback.
Quoted 2 lines · Thomas Zimmermann
Hi
[snip]
Quoted 7 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 608
Quoted 3 lines
drivers/gpu/drm/drm_format_helper.c +3
-0+ +if (xb == pixels -1 && end_offset) + end = end_offset;
end_offsetshould be calledend_len, because it is the number of bits in the final byte; but not the offset of the final bit.Indeed.
[snip]
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/drm_format_helper.c +3
-0+void drm_fb_gray8_to_mono_reversed (void *dst,unsigned int dst_pitch,const void *vaddr, +const struct drm_framebuffer *fb, +const struct drm_rect *clip)[snip]
Quoted 4 lines
Do you really need that function. It's not exported and if it's not otherwise used, I'd just remove it. We don't keep unused interfaces around.
At the end after your suggestion of doing line-per-line conversions it is not needed, but since I already typed it and we were talking about adding other formats besides the fake XRGB8888 as an optimization (R8 for grayscale and Dx or something like that for reversed mono), I thought that would be useful to have it as a helper.
Quoted 6 lines
Also other drivers that want to advertise a R8 format could just use it and not having to add their own helper. But I'm happy to drop it in v4 if you think that's better to not have unused helpers.
It could be taken from this patch-set anyways if someone wants to wire the needed support for R8.
I think, policy is to not keep unused code around.
Quoted 26 lines
[snip]
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 651
Quoted 7 lines
drivers/gpu/drm/drm_format_helper.c +7
-0+ +/* +* The reversed mono destination buffer contains 1 bit per pixel +* and destination scanlines have to be in multiple of 8 pixels. +*/ +if (!dst_pitch) + dst_pitch =DIV_ROUND_UP (linepixels,8 );I'd do a
warn_onceif (dst_pitch% 8 != 0).Agreed. I'll add a warning an mention that will be rounded up.
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 711
Quoted 5 lines
drivers/gpu/drm/drm_format_helper.c +4
-0+ +/* +* The cma memory is write-combined so reads are uncached. +* Speed up by fetching one line at a time. I once had a patchset that adds caching information to struct
dma_buf_map(soon to be named structiosys_map). Blitting helpers would be able to enable/disable this optimization as needed.
Quoted 7 lines
Quoted 3 lines
However, your driver doesn't use CMA. It's backed by SHMEM. Do you really want to keep that code in?
It doesn't but the repaper does. And since the plan was to make that driver to use the helper instead of having their own, I wanted to also make sure that would work well with CMA.
That makes sense then.
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
drivers/gpu/drm/drm_format_helper.c +2
-0+*/ + src32 =kmalloc (len_src32,GFP_KERNEL );drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 723
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+if (!src32) +return ; + +/* +* Copies are done line-by-line, allocate an intermediate +* buffer to copy the gray8 lines and then convert to mono. +*/ + gray8 =kmalloc (linepixels,GFP_KERNEL ); +if (!gray8) + goto free_src32;If might be faster to allocate both buffers in one step and set the pointers into the allocated buffer.
Quoted 2 lines
Not sure I got this. Do you mean to have a single buffer with length linepixels +
len_src32and point src32 and gray8 to the same buffer ?
That's the idea. I don't know the exact overhead for kalloc(), but at least the in userspace, malloc() in hot code paths is not a good idea. There's usually some searching for free space involved.
In the long term, we could add a field in struct drm_framebuffer to keep such buffers around for reuse.
Quoted 17 lines
Quoted 16 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 662
Quoted 12 lines
drivers/gpu/drm/drm_format_helper.c +11
-0+ +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +* +* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/ + start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ;
end_len, again. If you have 1 single bit set in the final byte, the offset is 0, but the length is 1.
Quoted 1 line
Agreed, will change it too.
Feel free to add my
to the next version.
Best regards
Thomas
Quoted 2 lines
Best regards,
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Javier Martinez Canillas
maintainerRe: [PATCH v3 2/7] drm/format-helper: Add drm_fb_{xrgb8888, gray8}_to_mono_reversed()
On 2/9/22 16:21, Thomas Zimmermann wrote:
[snip]
Quoted 6 lines
Quoted 3 lines
It could be taken from this patch-set anyways if someone wants to wire the needed support for R8.
I think, policy is to not keep unused code around.
Ok, I'll drop it then. We can include it again when adding R8 formats.
[snip]
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
If might be faster to allocate both buffers in one step and set the pointers into the allocated buffer.
Not sure I got this. Do you mean to have a single buffer with length linepixels +
len_src32and point src32 and gray8 to the same buffer ?That's the idea. I don't know the exact overhead for
kalloc(), but at least the in userspace,malloc()in hot code paths is not a good idea. There's usually some searching for free space involved.
Sure, let's do it in one allocation then and I'll add some comments to make easier for people to follow the code.
Quoted 20 lines
In the long term, we could add a field in struct
drm_framebufferto keep such buffers around for reuse.Quoted 17 lines
Quoted 16 lines
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 662
Quoted 12 lines
drivers/gpu/drm/drm_format_helper.c +11
-0+ +/* +* For damage handling, it is possible that only parts of the source +* buffer is copied and this could lead to start and end pixels that +* are not aligned to multiple of 8. +* +* Calculate if the start and end pixels are not aligned and set the +* offsets for the reversed mono line conversion function to adjust. +*/ + start_offset = clip->x1 %8 ; + end_offset = clip->x2 %8 ;
end_len, again. If you have 1 single bit set in the final byte, the offset is 0, but the length is 1.
Quoted 6 lines
Quoted 1 line
Agreed, will change it too.
Feel free to add my
Reviewed-by Thomas Zimmermann <[email protected]>
Thanks!
Best regards, --
Javier Martinez Canillas
Linux Engineering
Red Hat
Javier Martinez Canillas
maintainerPATCH v3 3/7 drm: Add driver for Solomon SSD130X OLED displays
In reply to Javier Martinez CanillasThis adds a DRM driver for SSD1305, SSD1306, SSD1307 and SSD1309 Solomon OLED display controllers.
It's only the core part of the driver and a bus specific driver is needed for each transport interface supported by the display controllers.
---
Changes in v3:
- Move driver from tiny sub-dir to drivers/gpu/drm/solomon (Sam Ravnborg)
- Split driver in a bus agnostic core and bus specific (Andy Shevchenko)
- Use regmap to access the chip registers (Andy Shevchenko)
- Remove unnecessary blank lines (Andy Shevchenko)
- Remove unneeded inline specifier in functions (Andy Shevchenko)
- Add a comment about always returning a single mode (Andy Shevchenko)
- Change write command logic to use do while loop (Andy Shevchenko)
- Use "firmware description" instead of "device tree" (Andy Shevchenko)
- Use return foo() instead of returning the return value (Andy Shevchenko)
- Don't split lines longer than 80 chars if makes less readable (Andy Shevchenko)
- Remove redundant else statements in .mode_valid callback (Andy Shevchenko)
- Rename powero{n,ff}() functions to power_o{n,ff)() (Andy Shevchenko)
- Use dev_err_probe() to prevent spam logs on probe deferral (Andy Shevchenko)
- Remove ',' after sentinel terminator in array (Andy Shevchenko)
- Fix a bug when doing partial updates (Geert Uytterhoeven)
Changes in v2:
- Drop patch that was adding a DRM_MODE_CONNECTOR_I2C type.
- Invert order of backlight {en,dis}able and display {on,off} (Sam Ravnborg)
- Don't clear the screen and turn on display on probe (Sam Ravnborg)
- Use backlight_get_brightness() macro to get BL brightness (Sam Ravnborg)
- Use dev managed version of devm_backlight_device_register() (Sam Ravnborg)
- Use dev_name(dev) for backlight name instead of an array (Sam Ravnborg)
- Drop the .get_brightness callback since isn't needed (Sam Ravnborg)
- Rename driver to ssd130x since supports a display family (Thomas Zimmermann)
- Drop the TINY prefix from the Kconfig symbol (Thomas Zimmermann)
- Sort the Kconfig symbol dependencies alphabetically (Thomas Zimmermann)
- Rename struct ssd130x_array to struct ssd130x_i2c_msg (Thomas Zimmermann)
- Rename struct ssd130x_i2c_msg .type member to .cmd (Thomas Zimmermann)
- Use sizeof(*foo) instead of sizeof(struct foo) (Thomas Zimmermann)
- Use struct_size() macro to calculate sizeof(*foo) + len (Thomas Zimmermann)
- Use kcalloc() instead of kmalloc_array() + memset() (Thomas Zimmermann)
- Use shadow plane helpers virtual screen support (Thomas Zimmermann)
- Remove unused goto label in ssd1307_fb_blit_rect() (Thomas Zimmermann)
- Use drm_set_preferred_mode() inset of manually set (Thomas Zimmermann)
- Use shadow plane helpers virtual screen support (Thomas Zimmermann)
- Remove unused goto label in ssd1307_fb_blit_rect() (Thomas Zimmermann)
- Use drm_set_preferred_mode() inset of manually set (Thomas Zimmermann)
- Reorganize code in probe to make it more legible (Thomas Zimmermann)
- ssd130x_write_cmd() uses varargs to simplify I2C code (Thomas Zimmermann)
- Move regulator/pwm init logic to display pipe enable callback.
drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/solomon/Kconfig | 12 + drivers/gpu/drm/solomon/Makefile | 1 + drivers/gpu/drm/solomon/ssd130x.c | 823 ++++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.h | 76 +++ 6 files changed, 915 insertions(+) create mode 100644 drivers/gpu/drm/solomon/Kconfig create mode 100644 drivers/gpu/drm/solomon/Makefile create mode 100644 drivers/gpu/drm/solomon/ssd130x.c create mode 100644 drivers/gpu/drm/solomon/ssd130x.h
drivers/gpu/drm/Kconfig +2 -0
@@ -405,6 +405,8 @@ source "drivers/gpu/drm/gud/Kconfig" source "drivers/gpu/drm/sprd/Kconfig" +source "drivers/gpu/drm/solomon/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && MMU && HYPERV
drivers/gpu/drm/Makefile +1 -0
@@ -133,3 +133,4 @@ obj-y += xlnx/ obj-y += gud/ obj-$(CONFIG_DRM_HYPERV) += hyperv/ obj-$(CONFIG_DRM_SPRD) += sprd/ +obj-y += solomon/
drivers/gpu/drm/solomon/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +config DRM_SSD130X + tristate "DRM support for Solomon SSD130X OLED displays" + depends on DRM + select BACKLIGHT_CLASS_DEVICE + select DRM_GEM_SHMEM_HELPER + select DRM_KMS_HELPER + help + DRM driver for the SSD1305, SSD1306, SSD1307 and SSD1309 Solomon + OLED controllers. This is only for the core driver, a driver for + the appropriate bus transport in your chip also must be selected. + + If M is selected the module will be called ssd130x.
drivers/gpu/drm/solomon/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_DRM_SSD130X) += ssd130x.o
drivers/gpu/drm/solomon/ssd130x.c new file +823 -0
823 lines not on this page · raw message
drivers/gpu/drm/solomon/ssd130x.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.34.1
drivers/gpu/drm/solomon/ssd130x.c line 194
Quoted 7 lines · Javier Martinez Canillas
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+if (ssd130x->vbat_reg) { + ret =regulator_enable (ssd130x->vbat_reg); +if (ret) { +dev_err (dev,"Failed to enable VBAT: %d\n" , ret); +return ret; + } + }
Unless the device supports power being physically omitted regulator usage should not be optional, it's just more code and a recipie for poor error handling.
Javier Martinez Canillas
maintainerHello Mark,
Thanks for your feedback.
Quoted 13 lines · Mark Brown
drivers/gpu/drm/solomon/ssd130x.c line 194
Quoted 7 lines · Javier Martinez Canillas
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+if (ssd130x->vbat_reg) { + ret =regulator_enable (ssd130x->vbat_reg); +if (ret) { +dev_err (dev,"Failed to enable VBAT: %d\n" , ret); +return ret; + } + }Unless the device supports power being physically omitted regulator usage should not be optional, it's just more code and a recipie for poor error handling.
The device has a VCC pin but in most cases this is just connected to a power provided by the board in its pinout header. For example, I've it connected to a rpi4 3.3v pin.
I guess in that case what we should do then is to just have a regulator fixed as the vbat-supply in the Device Tree, that's regulator-always-on.
The old ssd1307fb fbdev driver also had this as optional and I wanted to keep the new driver as backward compatible. But I understand now that is not describing the hardware properly by making this regulator optional.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Quoted 9 lines · Javier Martinez Canillas
Quoted 3 lines · Mark Brown
Unless the device supports power being physically omitted regulator usage should not be optional, it's just more code and a recipie for poor error handling.
The device has a VCC pin but in most cases this is just connected to a power provided by the board in its pinout header. For example, I've it connected to a rpi4 3.3v pin.
That sounds like a very common configuration.
Quoted 2 lines
I guess in that case what we should do then is to just have a regulator fixed as the vbat-supply in the Device Tree, that's regulator-always-on.
Generally I'd suggest labelling things with whatever the supply is called in the board's schematics/documentation, that tends to make things clearer and easier to follow.
Quoted 3 lines
The old ssd1307fb fbdev driver also had this as optional and I wanted to keep the new driver as backward compatible. But I understand now that is not describing the hardware properly by making this regulator optional.
It is depressingly common to see broken code here, unfortunately graphics drivers seem like one of the most common offendors.
Javier Martinez Canillas
maintainerQuoted 7 lines · Mark Brown
Quoted 5 lines · Javier Martinez Canillas
Quoted 3 lines · Mark Brown
Unless the device supports power being physically omitted regulator usage should not be optional, it's just more code and a recipie for poor error handling.
Quoted 6 lines
Quoted 3 lines
The device has a VCC pin but in most cases this is just connected to a power provided by the board in its pinout header. For example, I've it connected to a rpi4 3.3v pin.
That sounds like a very common configuration.
Yep.
Quoted 7 lines
Quoted 2 lines
I guess in that case what we should do then is to just have a regulator fixed as the vbat-supply in the Device Tree, that's regulator-always-on.
Generally I'd suggest labelling things with whatever the supply is called in the board's schematics/documentation, that tends to make things clearer and easier to follow.
The display controller datasheet and schematics mention VBAT as the power supply but the documentation says that it's just connected to VCC and the label in the display says VCC.
But I understand why the Device Tree binding and fbdev driver used VBAT since that's what the documentation mentions.
Quoted 6 lines
Quoted 3 lines
The old ssd1307fb fbdev driver also had this as optional and I wanted to keep the new driver as backward compatible. But I understand now that is not describing the hardware properly by making this regulator optional.
It is depressingly common to see broken code here, unfortunately graphics drivers seem like one of the most common offendors.
I'll include a patch for the existing DT binding and mark the vbat-supply property as required. Probably we won't be able to change the fbdev driver without causing regressions, and I'm not interested in that driver anyways.
Best regards,
--
Javier Martinez Canillas
Linux Engineering
Red Hat
Quoted 10 lines · Javier Martinez Canillas
Quoted 8 lines · Mark Brown
Quoted 2 lines · Javier Martinez Canillas
I guess in that case what we should do then is to just have a regulator fixed as the vbat-supply in the Device Tree, that's regulator-always-on.
Generally I'd suggest labelling things with whatever the supply is called in the board's schematics/documentation, that tends to make things clearer and easier to follow.
Quoted 6 lines
The display controller datasheet and schematics mention VBAT as the power supply but the documentation says that it's just connected to VCC and the label in the display says VCC.
But I understand why the Device Tree binding and fbdev driver used VBAT since that's what the documentation mentions.
What is "the documentation" in this context and how is that distinct from the datasheet for the display controller? In general the consumer driver should be using the name from the datasheet and the regulator itself should get a regulator-name reflecting the name in the schematic.
Quoted 6 lines
Quoted 2 lines
It is depressingly common to see broken code here, unfortunately graphics drivers seem like one of the most common offendors.
I'll include a patch for the existing DT binding and mark the vbat-supply property as required. Probably we won't be able to change the fbdev driver without causing regressions, and I'm not interested in that driver anyways.
There should be little danger of causing regressions given that a dummy regualtor will be provided when one is missing.
Javier Martinez Canillas
maintainerQuoted 1 line · Mark Brown
On Wed, Feb 09, 2022 at 03:50:13PM +0100, Javier Martinez Canillas wrote:
[snip]
Quoted 9 lines
Quoted 3 lines
But I understand why the Device Tree binding and fbdev driver used VBAT since that's what the documentation mentions.
What is "the documentation" in this context and how is that distinct from the datasheet for the display controller? In general the consumer driver should be using the name from the datasheet and the regulator itself should get a regulator-name reflecting the name in the schematic.
For "documentation" I meant the datasheet that mentions VBAT but I got what you mean and will also propose a change to the binding to rename the property to vcc-supply instead to match the pin name in the device.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
It is depressingly common to see broken code here, unfortunately graphics drivers seem like one of the most common offendors.
I'll include a patch for the existing DT binding and mark the vbat-supply property as required. Probably we won't be able to change the fbdev driver without causing regressions, and I'm not interested in that driver anyways.
There should be little danger of causing regressions given that a dummy regualtor will be provided when one is missing.
Right, I forgot that a dummy regulator is provided in that case. Perfect.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Quoted 5 lines · Javier Martinez Canillas
This adds a DRM driver for SSD1305, SSD1306, SSD1307 and SSD1309 Solomon OLED display controllers.
It's only the core part of the driver and a bus specific driver is needed for each transport interface supported by the display controllers.
Thank you for the update, my comments below.
...
Quoted 3 lines
source "
drivers/gpu/drm/sprd/Kconfig"+source "
drivers/gpu/drm/solomon/Kconfig"
'o' before 'p' ?
...
Quoted 2 lines
obj-$(CONFIG_DRM_SPRD) += sprd/
+obj-y += solomon/
Ditto ?
...
Quoted 2 lines
+/*
+ * DRM driver for Solomon SSD130X OLED displays
Solomon SSD130x (with lower letter it's easy to read and realize that it's not a model name).
Quoted 13 lines
+ * Copyright 2022 Red Hat Inc.
+ * Authors: Javier Martinez Canillas <[email protected]>
+ *
+ * Based ondrivers/video/fbdev/ssd1307fb.c
+ * Copyright 2012 Free Electrons
+ */drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+#include <linux/backlight.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/property.h> +#include <linux/pwm.h> +#include <linux/regulator/consumer.h>
...
drivers/gpu/drm/solomon/ssd130x.c line 38
Quoted 5 lines
drivers/gpu/drm/solomon/ssd130x.c new file +5
-0+#define DRIVER_NAME "ssd130x" +#define DRIVER_DESC "DRM driver for Solomon SSD130X OLED displays" +#define DRIVER_DATE "20220131" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0
Not sure it has a value when being defined. Only one string is reused and even if hard coded twice linker will optimize it.
...
Quoted 14 lines
drivers/gpu/drm/solomon/ssd130x.c new file +14
-0+/* +* Helper to write command (SSD130X_COMMAND). The fist variadic argument +* is the command to write and the following are the command options. +*/ +static int ssd130x_write_cmd (struct ssd130x_device *ssd130x,int count, +/* u8 cmd, u8 option, ... */ ...) +{ +va_list ap; +u8 value; +int ret; + +va_start (ap, count); + + do {
drivers/gpu/drm/solomon/ssd130x.c line 108
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c new file +10
-0+ value =va_arg (ap, int); + ret =regmap_write (ssd130x->regmap,SSD130X_COMMAND , (u8 )value); +if (ret) + goto out_end; + }while (--count); + +out_end: +va_end (ap); + +return ret;
Can bulk operation be used in the callers instead?
I have noticed that all of the callers are using
- 1 -- makes no sense at all, can be replaced with regmap_write()
- 2
- 3
Can be helpers for two and three arguments, with use of bulk call.
What do you think?
Quoted 1 line
+}
...
drivers/gpu/drm/solomon/ssd130x.c line 177
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+static void ssd130x_reset (struct ssd130x_device *ssd130x) +{ +/* Reset the screen */ +gpiod_set_value_cansleep (ssd130x->reset,1 ); +udelay (4 ); +gpiod_set_value_cansleep (ssd130x->reset,0 ); +udelay (4 );
I don't remember if reset pin is mandatory. fbtft does
if (!gpiod->reset) return; ...do reset...
Quoted 1 line
+}
...
drivers/gpu/drm/solomon/ssd130x.c line 185
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+if (ssd130x->reset)
A-ha, why not in the callee?
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+ssd130x_reset (ssd130x);
...
drivers/gpu/drm/solomon/ssd130x.c line 238
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+/* Set COM direction */ + com_invdir =0xc0 | ssd130x->com_invdir <<3 ;
Can 0xc0 and 3 be GENMASK()'ed and defined?
...
drivers/gpu/drm/solomon/ssd130x.c line 254
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+/* Set clock frequency */ + dclk = ((ssd130x->dclk_div -1 ) &0xf ) | (ssd130x->dclk_frq &0xf ) <<4 ;
GENMASK() ?
...
drivers/gpu/drm/solomon/ssd130x.c line 262
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+u32 mode = ((ssd130x->area_color_enable ?0x30 :0 ) | + (ssd130x->low_power ?5 :0 ));
With if's it will look better.
u32 mode = 0; if (ssd130x->area_color_enable) mode |= 0x30; if (ssd130x->low_power) mode |= 5;
...
drivers/gpu/drm/solomon/ssd130x.c line 288
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+/* Turn on the DC-DC Charge Pump */ + chargepump =BIT (4 ) | (ssd130x->device_info->need_chargepump ?BIT (2 ) :0 );
Ditto.
...
drivers/gpu/drm/solomon/ssd130x.c line 301
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+for (i =0 ; i <ARRAY_SIZE (ssd130x->lookup_table); ++i) {
i++ should work as well.
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c new file +10
-0+u8 val = ssd130x->lookup_table[i]; + +if (val <31 || val >63 ) +dev_warn (ssd130x->dev, +"lookup table index %d value out of range 31 <= %d <= 63\n" , + i, val); + ret =ssd130x_write_cmd (ssd130x,1 , val); +if (ret <0 ) +return ret; + }
...
drivers/gpu/drm/solomon/ssd130x.c line 402
Quoted 3 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+u8 *buf =NULL ; +
Redundant blank line, not sure if checkpatch catches this.
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+struct drm_rect fullscreen = { + .x1 =0 , + .x2 = ssd130x->width, + .y1 =0 , + .y2 = ssd130x->height, + };
...
Quoted 1 line
+power_off:
out_power_off: ?
...
drivers/gpu/drm/solomon/ssd130x.c line 747
Quoted 5 lines
drivers/gpu/drm/solomon/ssd130x.c new file +5
-0+ ret =PTR_ERR (ssd130x->vbat_reg); +if (ret == -ENODEV ) + ssd130x->vbat_reg =NULL ; +else +return dev_err_probe (dev, ret,"Failed to get VBAT regulator\n" );
Can it be
ret = PTR_ERR(ssd130x->vbat_reg); if (ret != -ENODEV) return dev_err_probe(dev, ret, "Failed to get VBAT regulator\n"); ssd130x->vbat_reg = NULL;
?
...
drivers/gpu/drm/solomon/ssd130x.c line 764
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +5
-0+ ssd130x =devm_drm_dev_alloc (dev, &ssd130x_drm_driver, + struct ssd130x_device, drm); +if (IS_ERR (ssd130x)) { +dev_err (dev,"Failed to allocate DRM device: %d\n" , ret); +return ssd130x;
return dev_err_probe() ?
Quoted 1 line
(quoted diff) +1
-0+ }
...
drivers/gpu/drm/solomon/ssd130x.c line 784
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+ bl =devm_backlight_device_register (dev,dev_name (dev), dev, ssd130x, + &ssd130xfb_bl_ops,NULL ); +if (IS_ERR (bl)) { + ret =PTR_ERR (bl); +dev_err (dev,"Unable to register backlight device: %d\n" , ret); +return ERR_PTR (ret);
Ditto.
Quoted 1 line
(quoted diff) +1
-0+ }
...
drivers/gpu/drm/solomon/ssd130x.c line 798
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c new file +4
-0+ ret =drm_dev_register (drm,0 ); +if (ret) { +dev_err (dev,"DRM device register failed: %d\n" , ret); +return ERR_PTR (ret);
Ditto.
Review
Quoted 1 line
(quoted diff) +1
-0+ }
...
I have feelings that half of my comments were ignored... Maybe I missed the discussion(s).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerHello Andy,
Thanks for your feedback.
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Javier Martinez Canillas
This adds a DRM driver for SSD1305, SSD1306, SSD1307 and SSD1309 Solomon OLED display controllers.
It's only the core part of the driver and a bus specific driver is needed for each transport interface supported by the display controllers.
Thank you for the update, my comments below.
Quoted 8 lines
...
Quoted 3 lines
source "
drivers/gpu/drm/sprd/Kconfig"+source "
drivers/gpu/drm/solomon/Kconfig"'o' before 'p' ?
The Kconfig was not sorted alphabetically so I just added it at the end. Same for the Makefile. But I will change it in v4 just to not keep adding unsorted entries.
[snip]
Quoted 6 lines
Quoted 2 lines
+/*
+ * DRM driver for Solomon SSD130X OLED displaysSolomon SSD130x (with lower letter it's easy to read and realize that it's not a model name).
Ok.
Quoted 16 lines
Quoted 13 lines
+ * Copyright 2022 Red Hat Inc.
+ * Authors: Javier Martinez Canillas <[email protected]>
+ *
+ * Based ondrivers/video/fbdev/ssd1307fb.c
+ * Copyright 2012 Free Electrons
+ */drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+#include <linux/backlight.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/property.h> +#include <linux/pwm.h> +#include <linux/regulator/consumer.h> ...
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x.c line 38
Quoted 5 lines
drivers/gpu/drm/solomon/ssd130x.c new file +5
-0+#define DRIVER_NAME "ssd130x" +#define DRIVER_DESC "DRM driver for Solomon SSD130X OLED displays" +#define DRIVER_DATE "20220131" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0Not sure it has a value when being defined. Only one string is reused and even if hard coded twice linker will optimize it.
I like to have all this at the beginning, it makes easier to read IMO.
[snip]
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+ + do { + value = va_arg(ap, int); + ret = regmap_write(ssd130x->regmap, SSD130X_COMMAND, (u8)value); + if (ret) + goto out_end;
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x.c line 108
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+ }while (--count); + +out_end: +va_end (ap); + +return ret;Can bulk operation be used in the callers instead?
I'm using bulk writes for the data but not for the commands. Because I tried to do that before and didn't work. But I'll give it a try again now that I switched to regmap. Maybe it was some mistake on my end.
Quoted 2 lines
I have noticed that all of the callers are using
- 1 -- makes no sense at all, can be replaced withregmap_write()
Yes, I just used for consistency. That way all the places sending a command would use the same function call.
Quoted 7 lines
- 2
- 3Can be helpers for two and three arguments, with use of bulk call.
What do you think?
Agreed, as mentioned I'll give it a try to sending all the data as a bulk write with regmap.
Quoted 19 lines
Quoted 1 line
+}
...
drivers/gpu/drm/solomon/ssd130x.c line 177
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+static void ssd130x_reset (struct ssd130x_device *ssd130x) +{ +/* Reset the screen */ +gpiod_set_value_cansleep (ssd130x->reset,1 ); +udelay (4 ); +gpiod_set_value_cansleep (ssd130x->reset,0 ); +udelay (4 );I don't remember if reset pin is mandatory. fbtft does
if (!gpiod->reset) return; ...do reset...
Quoted 8 lines
Quoted 1 line
+}
...
drivers/gpu/drm/solomon/ssd130x.c line 185
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+if (ssd130x->reset)A-ha, why not in the callee?
I think is easier to read when doing it in the caller, specially since there is only a single call. Than calling it unconditionally and making it a no-op if there isn't a reset GPIO.
Quoted 9 lines
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+ssd130x_reset (ssd130x);...
drivers/gpu/drm/solomon/ssd130x.c line 238
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+/* Set COM direction */ + com_invdir =0xc0 | ssd130x->com_invdir <<3 ;Can
0xc0and 3 be GENMASK()'ed and defined?
Ok.
Quoted 7 lines
...
drivers/gpu/drm/solomon/ssd130x.c line 254
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+/* Set clock frequency */ + dclk = ((ssd130x->dclk_div -1 ) &0xf ) | (ssd130x->dclk_frq &0xf ) <<4 ;
GENMASK()?
Ok.
Quoted 7 lines
...
drivers/gpu/drm/solomon/ssd130x.c line 262
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+u32 mode = ((ssd130x->area_color_enable ?0x30 :0 ) | + (ssd130x->low_power ?5 :0 ));With if's it will look better.
Quoted 7 lines
u32 mode = 0; if (ssd130x->area_color_enable) mode |= 0x30; if (ssd130x->low_power) mode |= 5;
Sure.
Quoted 7 lines
...
drivers/gpu/drm/solomon/ssd130x.c line 288
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+/* Turn on the DC-DC Charge Pump */ + chargepump =BIT (4 ) | (ssd130x->device_info->need_chargepump ?BIT (2 ) :0 );Ditto.
Ok.
Quoted 6 lines
...
drivers/gpu/drm/solomon/ssd130x.c line 301
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+for (i =0 ; i <ARRAY_SIZE (ssd130x->lookup_table); ++i) {i++ should work as well.
Yeah.
Quoted 13 lines
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c new file +10
-0+u8 val = ssd130x->lookup_table[i]; + +if (val <31 || val >63 ) +dev_warn (ssd130x->dev, +"lookup table index %d value out of range 31 <= %d <= 63\n" , + i, val); + ret =ssd130x_write_cmd (ssd130x,1 , val); +if (ret <0 ) +return ret; + }...
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c line 402
Quoted 3 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+u8 *buf =NULL ; +Redundant blank line, not sure if checkpatch catches this.
Agreed.
Quoted 9 lines
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+struct drm_rect fullscreen = { + .x1 =0 , + .x2 = ssd130x->width, + .y1 =0 , + .y2 = ssd130x->height, + };...
Quoted 4 lines
Quoted 1 line
+power_off:
out_power_off: ?
Ok.
Quoted 10 lines
...
drivers/gpu/drm/solomon/ssd130x.c line 747
Quoted 5 lines
drivers/gpu/drm/solomon/ssd130x.c new file +5
-0+ ret =PTR_ERR (ssd130x->vbat_reg); +if (ret == -ENODEV ) + ssd130x->vbat_reg =NULL ; +else +return dev_err_probe (dev, ret,"Failed to get VBAT regulator\n" );Can it be
Quoted 8 lines
ret = PTR_ERR(ssd130x->vbat_reg); if (ret != -ENODEV) return dev_err_probe(dev, ret, "Failed to get VBAT regulator\n"); ssd130x->vbat_reg = NULL;?
Mark mentioned that the regulator shouldn't really be optional. So half of this part is going away.
Quoted 11 lines
...
drivers/gpu/drm/solomon/ssd130x.c line 764
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +5
-0+ ssd130x =devm_drm_dev_alloc (dev, &ssd130x_drm_driver, + struct ssd130x_device, drm); +if (IS_ERR (ssd130x)) { +dev_err (dev,"Failed to allocate DRM device: %d\n" , ret); +return ssd130x;return
dev_err_probe()?
No, because this isn't a resource provided by other driver. If this failed is mostly due a memory allocation error.
Quoted 4 lines
Quoted 1 line
(quoted diff) +1
-0+ }...
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x.c line 784
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+ bl =devm_backlight_device_register (dev,dev_name (dev), dev, ssd130x, + &ssd130xfb_bl_ops,NULL ); +if (IS_ERR (bl)) { + ret =PTR_ERR (bl); +dev_err (dev,"Unable to register backlight device: %d\n" , ret); +return ERR_PTR (ret);Ditto.
Same. This is an error and not a reason to defer the probe.
Quoted 11 lines
Quoted 1 line
(quoted diff) +1
-0+ }...
drivers/gpu/drm/solomon/ssd130x.c line 798
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c new file +4
-0+ ret =drm_dev_register (drm,0 ); +if (ret) { +dev_err (dev,"DRM device register failed: %d\n" , ret); +return ERR_PTR (ret);Ditto.
And same.
Quoted 7 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }...
I have feelings that half of my comments were ignored... Maybe I missed the discussion(s).
I assure you that no comments from you or anyone were ignored.
I may had missed something but if if I did was a mistake and not intentionally. I keep a changelog for each revision in the patches with the name of the reviewer so people can check and compare.
If something that you mentioned is not there, I apologize and please point me out so I can address it in v4.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Quoted 2 lines · Javier Martinez Canillas
Quoted 1 line · Andy Shevchenko
On Wed, Feb 09, 2022 at 10:03:10AM +0100, Javier Martinez Canillas wrote:
...
Quoted 24 lines
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c line 103
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c new file +6
-0+do { + value =va_arg (ap, int); + ret =regmap_write (ssd130x->regmap,SSD130X_COMMAND , (u8 )value); +if (ret) + goto out_end; + }while (--count);Can bulk operation be used in the callers instead?
I'm using bulk writes for the data but not for the commands. Because I tried to do that before and didn't work. But I'll give it a try again now that I switched to regmap. Maybe it was some mistake on my end.
Quoted 2 lines
I have noticed that all of the callers are using
- 1 -- makes no sense at all, can be replaced withregmap_write()Yes, I just used for consistency. That way all the places sending a command would use the same function call.
Quoted 3 lines
- 2
- 3
Quoted 7 lines
Quoted 4 lines
Can be helpers for two and three arguments, with use of bulk call.
What do you think?
Agreed, as mentioned I'll give it a try to sending all the data as a bulk write with regmap.
Ah, it might be that it should be noinc bulk op. Need to be checked anyway.
...
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/solomon/ssd130x.c line 177
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+static void ssd130x_reset (struct ssd130x_device *ssd130x) +{ +/* Reset the screen */ +gpiod_set_value_cansleep (ssd130x->reset,1 ); +udelay (4 ); +gpiod_set_value_cansleep (ssd130x->reset,0 ); +udelay (4 );I don't remember if reset pin is mandatory. fbtft does
if (!gpiod->reset) return; ...do reset...Quoted 1 line
+}
...
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c line 185
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+if (ssd130x->reset)A-ha, why not in the callee?
I think is easier to read when doing it in the caller, specially since there is only a single call. Than calling it unconditionally and making it a no-op if there isn't a reset GPIO.
It doesn't matter where the check is and checking that in the callee seems better as it relies on the reset functionality. Caller in such case shouldn't even think if it's supported or not, not their business.
Last, but not least, if you think of power management, you probably want to assert reset there as well, means additional checks?
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+ssd130x_reset (ssd130x);
...
Quoted 10 lines
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c line 764
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c new file +3
-0+if (IS_ERR (ssd130x)) { +dev_err (dev,"Failed to allocate DRM device: %d\n" , ret); +return ssd130x;return
dev_err_probe()?No, because this isn't a resource provided by other driver. If this failed is mostly due a memory allocation error.
Is it a problem? dev_err_probe() got update in the documentation explaining that's fine to call even in such cases. The outcome is less amount of LOCs.
Quoted 1 line
Quoted 1 line
Quoted 1 line
(quoted diff) +1
-0+ }
...
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c line 784
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c new file +4
-0+if (IS_ERR (bl)) { + ret =PTR_ERR (bl); +dev_err (dev,"Unable to register backlight device: %d\n" , ret); +return ERR_PTR (ret);Ditto.
Same. This is an error and not a reason to defer the probe.
Ditto.
Quoted 1 line
Quoted 1 line
Quoted 1 line
(quoted diff) +1
-0+ }
...
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x.c line 798
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c new file +4
-0+ ret =drm_dev_register (drm,0 ); +if (ret) { +dev_err (dev,"DRM device register failed: %d\n" , ret); +return ERR_PTR (ret);Ditto.
And same.
Ditto.
Quoted 1 line
Quoted 1 line
Quoted 1 line
(quoted diff) +1
-0+ }
...
Quoted 5 lines
Quoted 2 lines
I have feelings that half of my comments were ignored... Maybe I missed the discussion(s).
I assure you that no comments from you or anyone were ignored.
Quoted 7 lines
I may had missed something but if if I did was a mistake and not intentionally. I keep a changelog for each revision in the patches with the name of the reviewer so people can check and compare.
If something that you mentioned is not there, I apologize and please point me out so I can address it in v4.
It's just a feeling, because I repeating that dev_err_probe() a lot :-) Nevertheless, now I see at least your point why you went that way. But see my comments on it.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerOn 2/9/22 17:08, Andy Shevchenko wrote:
[snip]
Quoted 5 lines
Quoted 2 lines
Agreed, as mentioned I'll give it a try to sending all the data as a bulk write with regmap.
Ah, it might be that it should be noinc bulk op. Need to be checked anyway.
Yeah, I'll give it a try for v4. Let's see how it goes.
[snip]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
A-ha, why not in the callee?
Quoted 8 lines
Quoted 3 lines
I think is easier to read when doing it in the caller, specially since there is only a single call. Than calling it unconditionally and making it a no-op if there isn't a reset GPIO.
It doesn't matter where the check is and checking that in the callee seems better as it relies on the reset functionality. Caller in such case shouldn't even think if it's supported or not, not their business.
Ok, no strong opinions really so I will change it.
Quoted 15 lines
Last, but not least, if you think of power management, you probably want to assert reset there as well, means additional checks?
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x.c new file +1
-0+ssd130x_reset (ssd130x);...
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c line 764
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c new file +3
-0+if (IS_ERR (ssd130x)) { +dev_err (dev,"Failed to allocate DRM device: %d\n" , ret); +return ssd130x;return
dev_err_probe()?
Quoted 6 lines
Quoted 2 lines
No, because this isn't a resource provided by other driver. If this failed is mostly due a memory allocation error.
Is it a problem?
dev_err_probe()got update in the documentation explaining that's fine to call even in such cases. The outcome is less amount of LOCs.
Thanks for pointing out. In my mind that was a way to denote in the code that a probe deferral was possible and that the message should be debug but now I went and read the comment as you suggested:
* Note that it is deemed acceptable to use this function for error
* prints during probe even if the @err is known to never be -EPROBE_DEFER.
* The benefit compared to a normal dev_err() is the standardized format
* of the error code and the fact that the error code is returned
So you are correct and using it is preferred even when no probe defer error will be returned. I'll do that here and in the other places you mentioned.
[snip]
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
I have feelings that half of my comments were ignored... Maybe I missed the discussion(s).
I assure you that no comments from you or anyone were ignored.
I may had missed something but if if I did was a mistake and not intentionally. I keep a changelog for each revision in the patches with the name of the reviewer so people can check and compare.
Quoted 6 lines
Quoted 2 lines
If something that you mentioned is not there, I apologize and please point me out so I can address it in v4.
It's just a feeling, because I repeating that
dev_err_probe()a lot :-) Nevertheless, now I see at least your point why you went that way. But see my comments on it.
And I did use dev_err_probe() in the places that could cause a probe deferral so it wasn't (completely) ignored.
On that topic, I even typed a SPI driver because of your feedback :)
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Quoted 1 line · Javier Martinez Canillas
On 2/9/22 17:08, Andy Shevchenko wrote:
...
Quoted 1 line
On that topic, I even typed a SPI driver because of your feedback :)
Much appreciated, makes me much easier to test.
Thank you for doing all this!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerQuoted 4 lines · Javier Martinez Canillas
On 2/9/22 17:08, Andy Shevchenko wrote:
[snip]
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Agreed, as mentioned I'll give it a try to sending all the data as a bulk write with regmap.
Ah, it might be that it should be noinc bulk op. Need to be checked anyway.
Yeah, I'll give it a try for v4. Let's see how it goes.
I tried to do bulk writes for the command, but the problem is that the command stream has to be as follow (i.e: SSD130X_SET_COL_RANGE command):
SSD130X_COMMANDSSD130X_SET_COL_RANGESSD130X_COMMANDcol_startSSD130X_COMMANDcol_end
That is, a SSD130X_COMMAND has to be writtn for each command and command option. This means that you need to either construct a command stream in the ssd130x_write_cmd() function or pass multiple SSD130X_COMMAND as variadic arguments.
Both cases lead to a less elegant implementation than just having a count parameter in ssd130x_write_cmd() and doing multiple writes as it is done in the current implementation.
After all, these are only for commands that are done once to setup the device. The SSD130X_DATA writes that are to update the display pixels are already done in bulk, which are more important to do it efficiently.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Javier Martinez Canillas
maintainerPATCH v3 4/7 drm/solomon: Add SSD130X OLED displays I2C support
In reply to Javier Martinez CanillasThe ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over I2C.
---
Changes in v3:
- Add a separate driver for SSD130X chips I2C support (Andy Shevchenko)
drivers/gpu/drm/solomon/Kconfig | 9 ++ drivers/gpu/drm/solomon/Makefile | 1 + drivers/gpu/drm/solomon/ssd130x-i2c.c | 117 ++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 drivers/gpu/drm/solomon/ssd130x-i2c.c
drivers/gpu/drm/solomon/Kconfig +9 -0
@@ -10,3 +10,12 @@ config DRM_SSD130X the appropriate bus transport in your chip also must be selected. If M is selected the module will be called ssd130x. + +config DRM_SSD130X_I2C + tristate "DRM support for Solomon SSD130X OLED displays (I2C bus)" + depends on DRM_SSD130X && I2C + select REGMAP_I2C + help + Say Y here if the SSD130X OLED display is connected via I2C bus. + + If M is selected the module will be called ssd130x-i2c.
drivers/gpu/drm/solomon/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_DRM_SSD130X) += ssd130x.o +obj-$(CONFIG_DRM_SSD130X_I2C) += ssd130x-i2c.o
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 4/7] drm/solomon: Add SSD130X OLED displays I2C support
Hi Javier,
Quoted 4 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over I2C.
Signed-off-by Javier Martinez Canillas <[email protected]>
Thanks for your patch!
drivers/gpu/drm/solomon/ssd130x-i2c.c line 86
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +4
-0+static const struct of_device_id ssd130x_of_match[] = { + { + .compatible ="solomon,ssd1305fb-i2c" , + .data = (void *)&ssd130x_ssd1305_deviceinfo,
The casts are not needed.
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +6
-0+ }, + { + .compatible = "solomon,ssd1306fb-i2c", + .data = (void *)&ssd130x_ssd1306_deviceinfo, + }, + {
drivers/gpu/drm/solomon/ssd130x-i2c.c line 102
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +10
-0+ .compatible = "solomon,ssd1307fb-i2c", + .data = (void *)&ssd130x_ssd1307_deviceinfo, + }, + { + .compatible = "solomon,ssd1309fb-i2c", + .data = (void *)&ssd130x_ssd1309_deviceinfo, + }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE (of, ssd130x_of_match);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Javier Martinez Canillas
maintainerRe: [PATCH v3 4/7] drm/solomon: Add SSD130X OLED displays I2C support
Hello Geert,
Thanks for your feedback.
On 2/9/22 13:21, Geert Uytterhoeven wrote:
[snip]
Quoted 8 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c line 86
Quoted 5 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +4
-0+static const struct of_device_id ssd130x_of_match[] = { + { + .compatible ="solomon,ssd1305fb-i2c" , + .data = (void *)&ssd130x_ssd1305_deviceinfo,The casts are not needed.
Right. I copied the table from the ssd1307fb driver verbatim. I'll clean it up.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Re: [PATCH v3 4/7] drm/solomon: Add SSD130X OLED displays I2C support
In reply to Javier Martinez CanillasQuoted 2 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over I2C.
Thanks!
...
Quoted 1 line
+ * Authors: Javier Martinez Canillas <[email protected]>
s?!
...
drivers/gpu/drm/solomon/ssd130x-i2c.c line 12
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +2
-0+#include <linux/i2c.h> +#include <linux/module.h>
regmap.h ?err.h?
...
drivers/gpu/drm/solomon/ssd130x-i2c.c line 34
Quoted 3 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +2
-0+ ssd130x =ssd130x_probe (&client->dev, regmap); +
Redundant blank line.
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +2
-0+if (IS_ERR (ssd130x)) +return PTR_ERR (ssd130x);
...
drivers/gpu/drm/solomon/ssd130x-i2c.c line 100
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +1
-0+ { /* sentinel */ },
No comma for terminator entry.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerRe: [PATCH v3 4/7] drm/solomon: Add SSD130X OLED displays I2C support
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over I2C.
Quoted 8 lines
Thanks!
...
Quoted 1 line
+ * Authors: Javier Martinez Canillas <[email protected]>
s?!
Right.
Quoted 8 lines
...
drivers/gpu/drm/solomon/ssd130x-i2c.c line 12
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +2
-0+#include <linux/i2c.h> +#include <linux/module.h>
regmap.h?err.h?
The regmap.h header is included in ssd130x.h and err.h in regmap.h.
Quoted 8 lines
...
drivers/gpu/drm/solomon/ssd130x-i2c.c line 34
Quoted 3 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +2
-0+ ssd130x =ssd130x_probe (&client->dev, regmap); +Redundant blank line.
Ok.
Quoted 10 lines
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +2
-0+if (IS_ERR (ssd130x)) +return PTR_ERR (ssd130x);...
drivers/gpu/drm/solomon/ssd130x-i2c.c line 100
Quoted 1 line
drivers/gpu/drm/solomon/ssd130x-i2c.c new file +1
-0+ { /* sentinel */ },No comma for terminator entry.
Right. I removed in one place bug forgot here.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Javier Martinez Canillas
maintainerPATCH v3 5/7 (WIP) drm/solomon: Add SSD130X OLED displays SPI support
In reply to Javier Martinez CanillasThe ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over SPI.
---
Changes in v3:
- Add a separate driver for SSD130X chips SPI support (Andy Shevchenko)
drivers/gpu/drm/solomon/Kconfig | 9 ++ drivers/gpu/drm/solomon/Makefile | 1 + drivers/gpu/drm/solomon/ssd130x-spi.c | 114 ++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 drivers/gpu/drm/solomon/ssd130x-spi.c
drivers/gpu/drm/solomon/Kconfig +9 -0
@@ -19,3 +19,12 @@ config DRM_SSD130X_I2C Say Y here if the SSD130X OLED display is connected via I2C bus. If M is selected the module will be called ssd130x-i2c. + +config DRM_SSD130X_SPI + tristate "DRM support for Solomon SSD130X OLED displays (SPI bus)" + depends on DRM_SSD130X && SPI + select REGMAP_SPI + help + Say Y here if the SSD130X OLED display is connected via SPI bus. + + If M is selected the module will be called ssd130x-spi.
drivers/gpu/drm/solomon/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_DRM_SSD130X) += ssd130x.o obj-$(CONFIG_DRM_SSD130X_I2C) += ssd130x-i2c.o +obj-$(CONFIG_DRM_SSD130X_SPI) += ssd130x-spi.o
drivers/gpu/drm/solomon/ssd130x-spi.c new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Hi Javier,
Quoted 4 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over SPI.
Signed-off-by Javier Martinez Canillas <[email protected]>
Thanks for your patch!
drivers/gpu/drm/solomon/ssd130x-spi.c line 82
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x-spi.c new file +3
-0+static const struct of_device_id ssd130x_of_match[] = { + { + .compatible ="solomon,ssd1305fb-spi" ,
This needs an update to the DT bindings.
Hence this may be a good time to deprecate the existing "solomon,ssd130*fb-i2c" compatible values, and switch to "solomon,ssd130*fb" instead, for both I2C and SPI.
Of course the I2C subdriver still has to bind against the old values, too, for backwards compatibility.
Quoted 1 line
+ .data = (void *)&ssd130x_ssd1305_deviceinfo,
The casts are not needed.
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x-spi.c new file +7
-0+ }, + { + .compatible = "solomon,ssd1306fb-spi", + .data = (void *)&ssd130x_ssd1306_deviceinfo, + }, + { + .compatible = "solomon,ssd1307fb-spi",
drivers/gpu/drm/solomon/ssd130x-spi.c line 100
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x-spi.c new file +10
-0+ .data = (void *)&ssd130x_ssd1307_deviceinfo, + }, + { + .compatible = "solomon,ssd1309fb-spi", + .data = (void *)&ssd130x_ssd1309_deviceinfo, + }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE (of, ssd130x_of_match); +
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Javier Martinez Canillas
maintainerRe: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 11 lines · Geert Uytterhoeven
Hi Javier,
Quoted 4 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over SPI.
Signed-off-by Javier Martinez Canillas <[email protected]>Thanks for your patch!
Quoted 8 lines
drivers/gpu/drm/solomon/ssd130x-spi.c line 82
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x-spi.c new file +3
-0+static const struct of_device_id ssd130x_of_match[] = { + { + .compatible ="solomon,ssd1305fb-spi" ,This needs an update to the DT bindings.
Yes, I know. Didn't feel like it, because the patch is a WIP anyways (I haven't tested it but was included just for illustration purposes).
If someone confirms that works then I will include a proper DT binding in the next revision.
Quoted 3 lines
Hence this may be a good time to deprecate the existing "solomon,ssd130*fb-i2c" compatible values, and switch to "solomon,ssd130*fb" instead, for both I2C and SPI.
Is this the preferred approach ? Asking because most of the drivers I know use this -$bus suffix. From a device <--> driver matching point of view, shouldn't be an issue to have two different drivers to use the same compatible strings, as long as these are for different buses.
Since AFAIK the match only happens within the same struct bus_type. But I wonder if this could cause issues in other places, for example the module loading. IIRC the OF modaliases don't include the device type.
If instead the drivers were old platform drivers and have an i2c_device_id and spi_device_id tables, then using the same device name would not be an issue due the modalias having a i2c: and spi: prefix to make a distinction.
What I think we should do is drop the "fb" part, since that seemed to me that was included because it was an fbdev driver. And not really hardware description.
Quoted 3 lines
Of course the I2C subdriver still has to bind against the old values, too, for backwards compatibility.
Yes, agreed.
Quoted 4 lines
Quoted 1 line
+ .data = (void *)&ssd130x_ssd1305_deviceinfo,
The casts are not needed.
Ok.
Best regards, --
Javier Martinez Canillas
Linux Engineering
Red Hat
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 9 lines · Javier Martinez Canillas
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 10:12 AM Javier Martinez Canillas <[email protected]> wrote:
Yes, I know. Didn't feel like it, because the patch is a WIP anyways (I haven't tested it but was included just for illustration purposes).
If someone confirms that works then I will include a proper DT binding in the next revision.
In a few weeks I hope I can do this.
But you know Linux is almost always broken (*) on the certain embedded device if nobody keep an eye each rc cycle. It might take time to return it in shape first.
*) Speaking out of my own experience with device(s) that I possess.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerRe: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Javier Martinez Canillas
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 10:12 AM Javier Martinez Canillas <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Yes, I know. Didn't feel like it, because the patch is a WIP anyways (I haven't tested it but was included just for illustration purposes).
If someone confirms that works then I will include a proper DT binding in the next revision.
In a few weeks I hope I can do this.
Thanks, there's no rush. I just included this for your convenience because you mentioned that have an display with a SPI interface.
Quoted 6 lines
But you know Linux is almost always broken (*) on the certain embedded device if nobody keep an eye each rc cycle. It might take time to return it in shape first.
*) Speaking out of my own experience with device(s) that I possess.
Unfortunately that's my experience too. I'll keep this patch in the series and marked as RFC. But in v4 will extend the DT binding to mention the SPI devices.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
In reply to Geert UytterhoevenQuoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 10:12 AM Javier Martinez Canillas <[email protected]> wrote:
...
Quoted 6 lines
Quoted 1 line
+ .compatible = "solomon,ssd1305fb-spi",
This needs an update to the DT bindings.
Hence this may be a good time to deprecate the existing "solomon,ssd130*fb-i2c" compatible values, and switch to "solomon,ssd130*fb" instead, for both I2C and SPI.
Agree!
Quoted 2 lines
Of course the I2C subdriver still has to bind against the old values, too, for backwards compatibility.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerRe: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 10:12 AM Javier Martinez Canillas <[email protected]> wrote:
...
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
+ .compatible = "solomon,ssd1305fb-spi",
This needs an update to the DT bindings.
Hence this may be a good time to deprecate the existing "solomon,ssd130*fb-i2c" compatible values, and switch to "solomon,ssd130*fb" instead, for both I2C and SPI.Agree!
Did you see my comment about automatic module loading ? I think that would be an issue if we use the same compatible for both I2C and SPI drivers.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Hi Javier,
Quoted 14 lines · Javier Martinez Canillas
Quoted 13 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 10:12 AM Javier Martinez Canillas <[email protected]> wrote:
...
Quoted 6 lines
Quoted 1 line
+ .compatible = "solomon,ssd1305fb-spi",
This needs an update to the DT bindings.
Hence this may be a good time to deprecate the existing "solomon,ssd130*fb-i2c" compatible values, and switch to "solomon,ssd130*fb" instead, for both I2C and SPI.
Quoted 6 lines
Quoted 2 lines
Agree!
Did you see my comment about automatic module loading ? I think that would be an issue if we use the same compatible for both I2C and SPI drivers.
We have several drivers that have a core and separate i2c and spi wrappers, see e.g.
$ git grep -w ltc2947_of_match
drivers/hwmon/ltc2947-core.c:const struct of_device_id ltc2947_of_match[] = {
drivers/hwmon/ltc2947-core.c:EXPORT_SYMBOL_GPL(ltc2947_of_match);
drivers/hwmon/ltc2947-core.c:MODULE_DEVICE_TABLE(of, ltc2947_of_match);
drivers/hwmon/ltc2947-i2c.c: .of_match_table = ltc2947_of_match,
drivers/hwmon/ltc2947-spi.c: .of_match_table = ltc2947_of_match,
drivers/hwmon/ltc2947.h:extern const struct of_device_id ltc2947_of_match[];Are they all broken?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 5:07 PM Javier Martinez Canillas <[email protected]> wrote:
...
Quoted 1 line
Are they all broken?
I guess it's incorrect question. The one we need to ask is is OF code broken? B/c ACPI can easily cope with this (they are different buses, can't clash).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerRe: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 11 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 5:07 PM Javier Martinez Canillas <[email protected]> wrote:
...
Quoted 1 line
Are they all broken?
I guess it's incorrect question. The one we need to ask is is OF code broken? B/c ACPI can easily cope with this (they are different buses, can't clash).
Yes, it's a problem specific to OF. It works correctly with both ACPI and legacy platform code.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Javier Martinez Canillas
maintainerRe: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
In reply to Geert UytterhoevenSorry for the long reply but I don't really know how to make it shorter.
Quoted 1 line · Geert Uytterhoeven
Hi Javier,
[snip]
Quoted 15 lines
Quoted 3 lines
Did you see my comment about automatic module loading ? I think that would be an issue if we use the same compatible for both I2C and SPI drivers.
We have several drivers that have a core and separate i2c and spi wrappers, see e.g.
$ git grep -w ltc2947_of_match drivers/hwmon/ltc2947-core.c:const struct of_device_id ltc2947_of_match[] = { drivers/hwmon/ltc2947-core.c:EXPORT_SYMBOL_GPL(ltc2947_of_match); drivers/hwmon/ltc2947-core.c:MODULE_DEVICE_TABLE(of, ltc2947_of_match); drivers/hwmon/ltc2947-i2c.c: .of_match_table = ltc2947_of_match, drivers/hwmon/ltc2947-spi.c: .of_match_table = ltc2947_of_match, drivers/hwmon/ltc2947.h:extern const struct of_device_id ltc2947_of_match[];
Quoted 2 lines
Are they all broken?
It doesn't have an easy answer. It depends on what device ID tables have to match, what modalias are present in the kernel modules and for what buses are since not all subsystem reports the modalias uevent in the same manner.
Let's take this particular driver for example, the module aliases are the following for each kernel module:
$ modinfo drivers/hwmon/ltc2947-core.ko | grep alias alias: of:N*T*Cadi,ltc2947C* alias: of:N*T*Cadi,ltc2947
$ modinfo drivers/hwmon/ltc2947-i2c.ko | grep alias alias: i2c:ltc2947
$ modinfo drivers/hwmon/ltc2947-spi.ko | grep alias alias: spi:ltc2947
The DT node will just contain a node with compatible = "adi,ltc2947", and depending if the device is on a I2C or SPI bus, the OF subsystem will do a device registration with the proper bus_type.
If is SPI, the subsystem always report a modalias uevent of the type "spi:ltc2947", even if the device was registered by OF. So for SPI the proper module will be loaded since it contains an alias "spi:ltc2947".
But I2C does report a proper OF modalias, so it will report instead "of:N*T*Cadi,ltc2947" which will match the core module but not the I2C.
The I2C ltc2947-i2c.ko module is missing a "of:N*T*Cadi,ltc2947" alias and the module loading likely isn't working and needs to be done manually.
Conversely, if ltc2947-spi.ko only add "of:N*T*Cadi,ltc2947", then the automatic module loading wouldn't work because the modalias uevent will be "spi:ltc2947" which won't match "of:N*T*Cadi,ltc2947". So everything is really fragile.
Note also that the "T*" in the alias, that's to denote the device type according to the ePAPR spec but that's only filled in the DT node has a device_type DT property, and most DT nodes don't fill this.
So the driver module is greedy and will match any device type. And also the modalias reported by the kernel won't set this, i.e:
$ cat /sys/bus/i2c/drivers/ssd130x-i2c/1-003c/modalias of:NoledT(null)Csolomon,ssd1306fb-i2c
The only way I found to make this robust and always working is with each driver to define its own tables depending on what is used to match and report the modalias to user-space. That means having an of_device_id and spi_device_id (just for modalias reporting and alias table in module) for SPI and a of_device_id table for I2C and platform devices.
And also having different compatible strings with a "-i2c" and "-spi" as suffixes to allow kmod / udev to differentiate and match the modules.
Otherwise you will get "of:N(null)T(null)Cadi,ltc2947" in both cases and user-space won't be able to figure out which module to match AFAICT.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
In reply to Javier Martinez CanillasQuoted 14 lines · Javier Martinez Canillas
Quoted 13 lines · Andy Shevchenko
Quoted 2 lines · Geert Uytterhoeven
On Wed, Feb 9, 2022 at 10:12 AM Javier Martinez Canillas <[email protected]> wrote:
...
Quoted 6 lines
Quoted 1 line
+ .compatible = "solomon,ssd1305fb-spi",
This needs an update to the DT bindings.
Hence this may be a good time to deprecate the existing "solomon,ssd130*fb-i2c" compatible values, and switch to "solomon,ssd130*fb" instead, for both I2C and SPI.
Quoted 6 lines
Quoted 2 lines
Agree!
Did you see my comment about automatic module loading ? I think that would be an issue if we use the same compatible for both I2C and SPI drivers.
Bug in OF code? This is not a problem in ACPI AFAICT.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
In reply to Javier Martinez CanillasQuoted 2 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over SPI.
Thanks!
Same set of comments as per I²C patch.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Javier Martinez Canillas
maintainerRe: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Javier Martinez Canillas
The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over SPI.
Thanks!
Same set of comments as per I²C patch.
Sure, thanks for your feedback!
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Javier Martinez Canillas
maintainerPATCH v3 6/7 MAINTAINERS: Add entry for Solomon SSD130X OLED displays DRM driver
In reply to Javier Martinez CanillasTo make sure that tools like the get_maintainer.pl script will suggest to Cc me if patches are posted for this driver.
Also include the Device Tree binding for the old ssd1307fb fbdev driver since the new DRM driver was made compatible with the existing binding.
---
Changes in v3:
- Adapt MAINTAINERS entry to point to the new drivers/gpu/drm/solomon directory.
Changes in v2:
- Add Sam Ravnborg's acked-by to patch adding a MAINTAINERS entry (Sam Ravnborg)
MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -6163,6 +6163,13 @@ T: git git://anongit.freedesktop.org/drm/drm-misc F: Documentation/devicetree/bindings/display/repaper.txt F: drivers/gpu/drm/tiny/repaper.c +DRM DRIVER FOR SOLOMON SSD130X OLED DISPLAYS +M: Javier Martinez Canillas <[email protected]> +S: Maintained +T: git git://anongit.freedesktop.org/drm/drm-misc +F: Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +F: drivers/gpu/drm/solomon/ssd130x* + DRM DRIVER FOR QEMU'S CIRRUS DEVICE M: Dave Airlie <[email protected]> M: Gerd Hoffmann <[email protected]>
Signature · 1 line
2.34.1
Javier Martinez Canillas
maintainerPATCH v3 7/7 dt-bindings: display: ssd1307fb: Add myself as binding co-maintainer
In reply to Javier Martinez CanillasThe ssd130x DRM driver also makes use of this Device Tree binding to allow existing users of the fbdev driver to migrate without the need to change their Device Trees.
Add myself as another maintainer of the binding, to make sure that I will be on Cc when patches are proposed for it.
---
(no changes since v2)
Changes in v2:
- Add myself as co-maintainer of the ssd1370fb DT binding (Sam Ravnborg).
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +1 -0
@@ -8,6 +8,7 @@ title: Solomon SSD1307 OLED Controller Framebuffer maintainers: - Maxime Ripard <[email protected]> + - Javier Martinez Canillas <[email protected]> properties: compatible:
Signature · 1 line
2.34.1
Hi Javier,
Quoted 2 lines · Javier Martinez Canillas
This patch series adds a DRM driver for the Solomon OLED SSD1305, SSD1306, SSD1307 and SSD1309 displays. It is a port of the ssd1307fb fbdev driver.
[...]
Quoted 1 line
- Fix a bug when doing partial updates (Geert Uytterhoeven)
Thanks, the text console is now more or less working as expected. There is still an issue with the cursor, though.
After doing "echo hello > /dev/tty0", the text appears, but the cursor is gone. "clear > /dev/tty0" brings it back.
The execution time of "time ls" has improved. It now takes 1.21s (0.86s with ssd1306fb).
The logo is not shown, even when I create a 16-color or 224-color version of the small monochrome logo I'm using.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Javier Martinez Canillas
maintainerHello Geert,
Quoted 4 lines · Geert Uytterhoeven
Hi Javier,
On Wed, Feb 9, 2022 at 10:03 AM Javier Martinez Canillas <[email protected]> wrote:
Quoted 8 lines
Quoted 2 lines
This patch series adds a DRM driver for the Solomon OLED SSD1305, SSD1306, SSD1307 and SSD1309 displays. It is a port of the ssd1307fb fbdev driver.
[...]
Quoted 1 line
- Fix a bug when doing partial updates (Geert Uytterhoeven)
Thanks, the text console is now more or less working as expected.
Thanks for giving it a try to this version too! Glad to know that is working better now.
Quoted 4 lines
There is still an issue with the cursor, though.
After doing "echo hello >/dev/tty0", the text appears, but the cursor is gone. "clear >/dev/tty0" brings it back.
Hmm, I was able to reproduce this too. Thanks for pointing it out, I'll investigate what the problem is.
Quoted 3 lines
The execution time of "time ls" has improved. It now takes 1.21s (0.86s with ssd1306fb).
Yes, I believe that was due the bug I mentioned that partial updates weren't done but a full screen update instead.
Quoted 3 lines
The logo is not shown, even when I create a 16-color or 224-color version of the small monochrome logo I'm using.
I'll also dig into this.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Javier Martinez Canillas
maintainerOn 2/9/22 13:37, Javier Martinez Canillas wrote:
[snip]
Quoted 9 lines
Quoted 5 lines
There is still an issue with the cursor, though.
After doing "echo hello >/dev/tty0", the text appears, but the cursor is gone. "clear >/dev/tty0" brings it back.Hmm, I was able to reproduce this too. Thanks for pointing it out, I'll investigate what the problem is.
I still didn't have time to dig on this for v4. But I think that the driver works well enough to be merged and we can then fix the issues that are still present in the fbdev emulation and fbcon interaction as a follow-up.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Quoted 9 lines · Geert Uytterhoeven
Quoted 2 lines · Javier Martinez Canillas
This patch series adds a DRM driver for the Solomon OLED SSD1305, SSD1306, SSD1307 and SSD1309 displays. It is a port of the ssd1307fb fbdev driver.
[...]
The logo is not shown, even when I create a 16-color or 224-color version of the small monochrome logo I'm using.
My mistake, I messed up the hook-up, causing it to pick a different logo that was too large to be displayed.
Of course it's using the 224-color logo reduced to monochrome instead of the real monochrome logo, as fbcon thinks it's running on XRGB8888.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Javier Martinez Canillas
maintainerHello Geert,
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines · Geert Uytterhoeven
Quoted 2 lines · Javier Martinez Canillas
This patch series adds a DRM driver for the Solomon OLED SSD1305, SSD1306, SSD1307 and SSD1309 displays. It is a port of the ssd1307fb fbdev driver.
Quoted 8 lines
Quoted 4 lines
[...]
The logo is not shown, even when I create a 16-color or 224-color version of the small monochrome logo I'm using.
My mistake, I messed up the hook-up, causing it to pick a different logo that was too large to be displayed.
Great, thanks for all the testing.
Quoted 3 lines
Of course it's using the 224-color logo reduced to monochrome instead of the real monochrome logo, as fbcon thinks it's running on XRGB8888.
Right. Once the patch lands, I'll look at wiring up the needed support in DRM for the drivers to be able to advertise 8-bit grayscale and monochrome to avoid the unnecessary conversions and to have feature parity with fbdev.
But I just wanted to do it incrementally and first port to DRM as first step.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat