drm: Add driver for Solomon SSD130x OLED displays
Subsystems (6)
Javier Martinez Canillas
maintainerv6 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 fbdev emulation, all the tests from Geert Uytterhoeven repo
(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 v6 that addresses the issues pointed in v5. Thanks a lot to all reviewers that gave me feedback and comments.
I didn't include the patch that adds the SPI support this time, because it will require changes in the existing Device Tree binding. And I wanted to avoid that bikesheeding for now, to focus on the core and I2C parts.
Once this series land, I'll post patches for the SPI support. But the WIP patch posted in v3 should still apply cleanly on top of this v6:
https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/
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 a new drm_fb_xrgb8888_to_mono_reversed() helper function to convert from XR24 to reversed monochrome. The latter internally converts each line first to 8-bit grayscale and then to 1-bit reversed monochrome.
Patch #3 adds the driver. This only has the core support and 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.
Patch #5 adds a MAINTAINERS entry for the DRM driver and patch #6 adds myself as co-maintainer of the existing DT binding for the ssd1307fb, since the same DT binding is used for both the fbdev and DRM drivers.
Best regards,
Javier
Changes in v6:
- Add Andy Shevchenko's Reviewed-by to patch #1.
- Add Andy Shevchenko's Reviewed-by to patch #2.
- Just return regmap_bulk_write() in ssd130x_write_data() (Andy Shevchenko)
- Remove unnecessary cast in ssd130x_write_cmd() (Andy Shevchenko)
- Return ERR_PTR(dev_err_probe(...)) everywhere in probe (Andy Shevchenko)
Changes in v5:
- Add Thomas Zimmermann's Reviewed-by to patch #1.
- Use drm_WARN_ON* macros instead of deprecated ones (Thomas Zimmermann)
- Include <linux/bits.h> header (Andy Shevchenko)
- Drop parenthesis for command options macros (Andy Shevchenko)
- Explain in ssd130x_write_cmd() comment how commands are sent (Andy Shevchenko)
- The pwm_*() functions check for NULL already (Andy Shevchenko)
- Remove unnecesary blank line (Andy Shevchenko)
- Simplify error handling for backlight registration failure (Geert Uytterhoeven)
- Don't clear screen on enable, instead send the full buffer (Thomas Zimmermann)
- Add Andy Shevchenko's Reviewed-by tag to patch #4.
- Add Andy Shevchenko's Reviewed-by tag to patch #5.
- Add Andy Shevchenko's Reviewed-by tag to patch #6.
Changes in v4:
- Rename end_offset to end_len (Thomas Zimmermann)
- Warn once if dst_pitch is not a multiple of 8 (Thomas Zimmermann)
- Drop drm_fb_gray8_to_mono_reversed() that's not used (Thomas Zimmermann)
- Allocate single buffer for both copy cma memory and gray8 (Thomas Zimmermann)
- Add Thomas Zimmermann Reviewed-by tag to patch adding XR24 -> mono helper.
- Rename vbat supply to vcc since is how's labeled in the device (Mark Brown)
- Don't make the regulator option since is always needed (Mark Brown)
- Add solomon Kconfig source and directory inclusion sorted (Andy Shevchenko)
- Use SSD130x instead of SSD130X to denote is not a model name (Andy Shevchenko)
- Check if there's a reset pin in the callee and not the caller (Andy Shevchenko)
- Define missing commands instead of using magic numbers (Andy Shevchenko)
- Use GENMASK() and FIELD_PREP() macros when possible (Andy Shevchenko)
- Avoid using ternary operators to ease code readablity (Andy Shevchenko)
- Use i++ instead of --i on some for loops (Andy Shevchenko)
- Remove redundant blank lines (Andy Shevchenko)
- Rename power_off label to out_power_off (Andy Shevchenko)
- Use dev_err_probe() even if no -EPROBE_DEFER (Andy Shevchenko)
- Don't use plural Authors if there's only one (Andy Shevchenko)
- Remove unnecessary casting (Geert Uytterhoeven)
- Remove redundant blank lines (Andy Shevchenko)
- Remove comma after of_device_id table terminator (Andy Shevchenko)
- Add Rob Herring Acked-by tag to patch adding as DT binding co-maintainer.
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)
- 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 (6):
drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line() drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
drm: Add driver for Solomon SSD130x OLED displays drm/solomon: Add SSD130x OLED displays I2C 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 | 141 ++- drivers/gpu/drm/solomon/Kconfig | 21 + drivers/gpu/drm/solomon/Makefile | 2 + drivers/gpu/drm/solomon/ssd130x-i2c.c | 116 +++ drivers/gpu/drm/solomon/ssd130x.c | 843 ++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.h | 76 ++ include/drm/drm_format_helper.h | 4 + 11 files changed, 1202 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.c create mode 100644 drivers/gpu/drm/solomon/ssd130x.h
Signature · 1 line
2.34.1
Javier Martinez Canillas
maintainerPATCH v6 1/6 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 v6:
- Add Andy Shevchenko's Reviewed-by to patch #1.
Changes in v5:
- Add Thomas Zimmermann's Reviewed-by to patch #1.
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
Re: [PATCH v6 1/6] drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line()
Quoted 9 lines · Javier Martinez Canillas
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.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Maxime
Javier Martinez Canillas
maintainerPATCH v6 2/6 drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
In reply to Javier Martinez CanillasAdd support to convert from XR24 to reversed monochrome for drivers that control monochromatic display panels, that only have 1 bit per pixel.
The function does a line-by-line conversion doing an intermediate step first from XR24 to 8-bit grayscale and then to reversed monochrome.
The drm_fb_gray8_to_mono_reversed_line() helper was based on code from drivers/gpu/drm/tiny/repaper.c driver.
---
Changes in v6:
- Add Andy Shevchenko's Reviewed-by to patch #2.
Changes in v5:
- Use drm_WARN_ON* macros instead of deprecated ones (Thomas Zimmermann)
Changes in v4:
- Rename end_offset to end_len (Thomas Zimmermann)
- Warn once if dst_pitch is not a multiple of 8 (Thomas Zimmermann)
- Drop drm_fb_gray8_to_mono_reversed() that's not used (Thomas Zimmermann)
- Allocate single buffer for both copy cma memory and gray8 (Thomas Zimmermann)
- Add Thomas Zimmermann Reviewed-by tag to patch adding XR24 -> mono helper.
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 | 110 ++++++++++++++++++++++++++++ include/drm/drm_format_helper.h | 4 + 2 files changed, 114 insertions(+)
drivers/gpu/drm/drm_format_helper.c +110 -0
@@ -12,9 +12,11 @@#include <linux/slab.h> #include <linux/io.h> +#include <drm/drm_device.h> #include <drm/drm_format_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_fourcc.h> +#include <drm/drm_print.h> #include <drm/drm_rect.h> static unsigned int clip_offset (const struct drm_rect *clip,unsigned int pitch,unsigned int cpp)
@@ -591,3 +593,111 @@ 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_len) +{ +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_len) + end = end_len; + +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_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; +struct drm_device *dev = fb->dev; +unsigned int start_offset, end_len; +unsigned int y; +u8 *mono = dst, *gray8; +u32 *src32; + +if (drm_WARN_ON (dev, 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 ); + +drm_WARN_ONCE (dev, dst_pitch %8 !=0 ,"dst_pitch is not a multiple of 8\n" ); + +/* +* The cma memory is write-combined so reads are uncached. +* Speed up by fetching one line at a time. +* +* Also, format conversion from XR24 to reversed monochrome +* are done line-by-line but are converted to 8-bit grayscale +* as an intermediate step. +* +* Allocate a buffer to be used for both copying from the cma +* memory and to store the intermediate grayscale line pixels. +*/ + src32 =kmalloc (len_src32 + linepixels,GFP_KERNEL ); +if (!src32) +return ; + + gray8 = (u8 *)src32 + len_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_len = 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_len); + vaddr += fb->pitches[0 ]; + mono += dst_pitch; + } + +kfree (src32); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_mono_reversed);
include/drm/drm_format_helper.h +4 -0
@@ -43,4 +43,8 @@ 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_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
Re: [PATCH v6 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
Quoted 6 lines · Javier Martinez Canillas
Add support to convert from XR24 to reversed monochrome for drivers that control monochromatic display panels, that only have 1 bit per pixel.
The function does a line-by-line conversion doing an intermediate step first from XR24 to 8-bit grayscale and then to reversed monochrome.
Quoted 6 lines
The
drm_fb_gray8_to_mono_reversed_line()helper was based on code fromdrivers/gpu/drm/tiny/repaper.cdriver.Signed-off-by Javier Martinez Canillas <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Maxime
Re: [PATCH v6 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
In reply to Javier Martinez CanillasHi Javier,
Quoted 6 lines · Javier Martinez Canillas
Add support to convert from XR24 to reversed monochrome for drivers that control monochromatic display panels, that only have 1 bit per pixel.
The function does a line-by-line conversion doing an intermediate step first from XR24 to 8-bit grayscale and then to reversed monochrome.
Quoted 6 lines
The
drm_fb_gray8_to_mono_reversed_line()helper was based on code fromdrivers/gpu/drm/tiny/repaper.cdriver.Signed-off-by Javier Martinez Canillas <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Thanks for your patch, which is now commit bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()") in drm/drm-next.
Quoted 15 lines
drivers/gpu/drm/drm_format_helper.c +2
-0@@ -12,9 +12,11 @@#include <linux/slab.h> #include <linux/io.h> +#include <drm/drm_device.h> #include <drm/drm_format_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_fourcc.h> +#include <drm/drm_print.h> #include <drm/drm_rect.h> static unsigned int clip_offset (const struct drm_rect *clip,unsigned int pitch,unsigned int cpp)
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 597
Quoted 5 lines
drivers/gpu/drm/drm_format_helper.c +2
-0@@ -591,3 +593,111 @@ 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,
"pixels" is not the number of pixels to process, but the number of bytes in the monochrome destination buffer.
Quoted 13 lines
drivers/gpu/drm/drm_format_helper.c +13
-0+ unsigned int start_offset, unsigned int end_len) +{ +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_len) + end = end_len;
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 620
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+ +for (i = start; i < end; i++) { +unsigned int x = xb *8 + i; + + byte >>=1 ; +if (src[x] >>7 ) + byte |=BIT (7 ); + } + *dst++ = byte; + }
The above is IMHO very hard to read.
I think it can be made simpler by passing the total number of pixels to process instead of "pixels" (which is bytes) and "end_len".
Quoted 12 lines
drivers/gpu/drm/drm_format_helper.c +12
-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
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 642
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+* 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;
drm_rect_height(clip)?
Quoted 7 lines
drivers/gpu/drm/drm_format_helper.c +7
-0+unsigned int cpp = fb->format->cpp[0 ]; +unsigned int len_src32 = linepixels * cpp; +struct drm_device *dev = fb->dev; +unsigned int start_offset, end_len; +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 659
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+ +if (drm_WARN_ON (dev, 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 );
This is not correct when clip->x1 is not a multiple of 8 pixels. Should be:
DIV_ROUND_UP(linepixels + clip->x1 % 8, 8);
drivers/gpu/drm/drm_format_helper.c int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_for · line 661
Quoted 2 lines
drivers/gpu/drm/drm_format_helper.c +2
-0+ +drm_WARN_ONCE (dev, dst_pitch %8 !=0 ,"dst_pitch is not a multiple of 8\n" );
This triggers for me: dst_pitch = 1.
Which is perfectly fine, when flashing an 8-pixel wide cursor ;-)
Quoted 32 lines
drivers/gpu/drm/drm_format_helper.c +32
-0+ +/* +* The cma memory is write-combined so reads are uncached. +* Speed up by fetching one line at a time. +* +* Also, format conversion from XR24 to reversed monochrome +* are done line-by-line but are converted to 8-bit grayscale +* as an intermediate step. +* +* Allocate a buffer to be used for both copying from the cma +* memory and to store the intermediate grayscale line pixels. +*/ + src32 =kmalloc (len_src32 + linepixels,GFP_KERNEL ); +if (!src32) +return ; + + gray8 = (u8 *)src32 + len_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_len = clip->x2 %8 ; + + vaddr +=clip_offset (clip, fb->pitches[0 ], cpp); +for (y =0 ; y < lines; y++) { + src32 =memcpy (src32, vaddr, len_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 703
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+drm_fb_xrgb8888_to_gray8_line (gray8, src32, linepixels); +drm_fb_gray8_to_mono_reversed_line (mono, gray8, dst_pitch, + start_offset, end_len); + vaddr += fb->pitches[0 ]; + mono += dst_pitch; + } + +kfree (src32); +} +EXPORT_SYMBOL (drm_fb_xrgb8888_to_mono_reversed);
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 v6 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
Hello Geert,
Thanks a lot for your feedback.
On 3/8/22 17:13, Geert Uytterhoeven wrote:
[snip]
Quoted 6 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 597
Quoted 2 lines
drivers/gpu/drm/drm_format_helper.c +2
-0+ +static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned int pixels,"pixels" is not the number of pixels to process, but the number of bytes in the monochrome destination buffer.
Right, that parameter name is misleading / incorrect indeed. Probably should be changed by dst_pitch or dst_stride.
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_format_helper.c +19
-0+ unsigned int start_offset, unsigned int end_len) +{ +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_len) + end = end_len; + +for (i = start; i < end; i++) { +unsigned int x = xb *8 + i; + + byte >>=1 ; +if (src[x] >>7 )
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 620
Quoted 4 lines
drivers/gpu/drm/drm_format_helper.c +4
-0+ byte |=BIT (7 ); + } + *dst++ = byte; + }The above is IMHO very hard to read.
I think it can be made simpler by passing the total number of pixels to process instead of "pixels" (which is bytes) and "end_len".
Agreed that's hard to read. I think is better if you propose a patch with your idea to make it simpler.
[snip]
Quoted 8 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 642
Quoted 5 lines
drivers/gpu/drm/drm_format_helper.c +5
-0+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;
drm_rect_height(clip)?
Yes, unsure why didn't use it since used drm_rect_width() for the width.
Quoted 21 lines
Quoted 7 lines
drivers/gpu/drm/drm_format_helper.c +7
-0+unsigned int cpp = fb->format->cpp[0 ]; +unsigned int len_src32 = linepixels * cpp; +struct drm_device *dev = fb->dev; +unsigned int start_offset, end_len; +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 659
Quoted 10 lines
drivers/gpu/drm/drm_format_helper.c +10
-0+ +if (drm_WARN_ON (dev, 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 );This is not correct when
clip->x1is not a multiple of 8 pixels. Should be:
Quoted 2 lines
DIV_ROUND_UP(linepixels + clip->x1 % 8, 8);
Agreed.
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + drm_WARN_ONCE(dev, dst_pitch % 8 != 0, "dst_pitch is not a multiple of 8\n");This triggers for me:
dst_pitch= 1.
Which is perfectly fine, when flashing an 8-pixel wide cursor ;-)
Indeed. I think we should just drop that warn.
Do you want me to post patches for all these or would you do it when simplifying the drm_fb_gray8_to_mono_reversed_line() logic ?
Signature · 5 lines
Best regards, Javier Martinez Canillas Linux Engineering Red Hat
Javier Martinez Canillas
maintainerPATCH v6 3/6 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 v6:
- Just return regmap_bulk_write() in ssd130x_write_data() (Andy Shevchenko)
- Remove unnecessary cast in ssd130x_write_cmd() (Andy Shevchenko)
- Return ERR_PTR(dev_err_probe(...)) everywhere in probe (Andy Shevchenko)
Changes in v5:
- Include <linux/bits.h> header (Andy Shevchenko)
- Drop parenthesis for command options macros (Andy Shevchenko)
- Explain in ssd130x_write_cmd() comment how commands are sent (Andy Shevchenko)
- The pwm_*() functions check for NULL already (Andy Shevchenko)
- Remove unnecesary blank line (Andy Shevchenko)
- Simplify error handling for backlight registration failure (Geert Uytterhoeven)
- Don't clear screen on enable, instead send the full buffer (Thomas Zimmermann)
Changes in v4:
- Rename vbat supply to vcc since is how's labeled in the device (Mark Brown)
- Don't make the regulator option since is always needed (Mark Brown)
- Add solomon Kconfig source and directory inclusion sorted (Andy Shevchenko)
- Use SSD130x instead of SSD130X to denote is not a model name (Andy Shevchenko)
- Check if there's a reset pin in the callee and not the caller (Andy Shevchenko)
- Define missing commands instead of using magic numbers (Andy Shevchenko)
- Use GENMASK() and FIELD_PREP() macros when possible (Andy Shevchenko)
- Avoid using ternary operators to ease code readablity (Andy Shevchenko)
- Use i++ instead of --i on some for loops (Andy Shevchenko)
- Remove redundant blank lines (Andy Shevchenko)
- Rename power_off label to out_power_off (Andy Shevchenko)
- Use dev_err_probe() even if no -EPROBE_DEFER (Andy Shevchenko)
- Don't use plural Authors if there's only one (Andy Shevchenko)
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 | 843 ++++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.h | 76 +++ 6 files changed, 935 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
@@ -403,6 +403,8 @@ source "drivers/gpu/drm/xlnx/Kconfig" source "drivers/gpu/drm/gud/Kconfig" +source "drivers/gpu/drm/solomon/Kconfig" + source "drivers/gpu/drm/sprd/Kconfig" config DRM_HYPERV
drivers/gpu/drm/Makefile +1 -0
@@ -132,4 +132,5 @@ obj-$(CONFIG_DRM_TIDSS) += tidss/ obj-y += xlnx/ obj-y += gud/ obj-$(CONFIG_DRM_HYPERV) += hyperv/ +obj-y += solomon/ obj-$(CONFIG_DRM_SPRD) += sprd/
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 +843 -0
843 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
Quoted 7 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.
Signed-off-by Javier Martinez Canillas <[email protected]>
Maxime
Hi Javier,
Quoted 7 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.
Signed-off-by Javier Martinez Canillas <[email protected]>
Thanks for your patch, which is now commit a61732e808672cfa ("drm:
Add driver for Solomon SSD130x OLED displays") in drm/drm-next
Sorry for the delay, but finally I gave it a try on my Adafruit FeatherWing 128x32 OLED.
Some of the weird issues (cursor disappears after printing some text, more text also doesn't appear until I clear the display) are still there. Unfortunately a regression was introduced since your v3: printed text is mirrored upside-down. I.e. "E" is rendered correctly, but "L" turns into "Γ" (Greek Gamma).
I suspect something went wrong with the display initialization sequence.
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
maintainerQuoted 12 lines · Geert Uytterhoeven
Hi Javier,
Quoted 7 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.
Signed-off-by Javier Martinez Canillas <[email protected]>
Quoted 7 lines
Thanks for your patch, which is now commit
a61732e808672cfa("drm:
Add driver for Solomon SSD130x OLED displays") in drm/drm-nextSorry for the delay, but finally I gave it a try on my Adafruit FeatherWing 128x32 OLED.
Some of the weird issues (cursor disappears after printing some text, more text also doesn't appear until I clear the display) are still there.
I see. Thought that I tested using it as a console and it did work correctly for me. I'll do more tests again.
Quoted 6 lines
Unfortunately a regression was introduced since your v3: printed text is mirrored upside-down. I.e. "E" is rendered correctly, but "L" turns into "Γ" (Greek Gamma).
I suspect something went wrong with the display initialization sequence.
Could you please try Chen-Yu's fix for the COM scan direction mask ?
https://lists.freedesktop.org/archives/dri-devel/2022-March/345915.html
I made a mistake when converting to use the GENMASK() and FIELD_PREP() macros in v4 as suggested by Andy. The SSD130X_SET_COM_SCAN_DIR_MASK wasn't correct which would explain the output to be vertically flipped.
Signature · 5 lines
Best regards, Javier Martinez Canillas Linux Engineering Red Hat
Hi Javier,
Quoted 8 lines · Javier Martinez Canillas
Quoted 6 lines · Geert Uytterhoeven
Unfortunately a regression was introduced since your v3: printed text is mirrored upside-down. I.e. "E" is rendered correctly, but "L" turns into "Γ" (Greek Gamma).
I suspect something went wrong with the display initialization sequence.
Quoted 7 lines
Could you please try Chen-Yu's fix for the COM scan direction mask ?
https://lists.freedesktop.org/archives/dri-devel/2022-March/345915.html
I made a mistake when converting to use the
GENMASK()andFIELD_PREP()macros in v4 as suggested by Andy. TheSSD130X_SET_COM_SCAN_DIR_MASKwasn't correct which would explain the output to be vertically flipped.
Thanks, confirmed fixed.
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 14 lines · Geert Uytterhoeven
Hi Javier,
Quoted 10 lines · Javier Martinez Canillas
Quoted 6 lines · Geert Uytterhoeven
Unfortunately a regression was introduced since your v3: printed text is mirrored upside-down. I.e. "E" is rendered correctly, but "L" turns into "Γ" (Greek Gamma).
I suspect something went wrong with the display initialization sequence.Could you please try Chen-Yu's fix for the COM scan direction mask ?
Quoted 8 lines
Quoted 5 lines
https://lists.freedesktop.org/archives/dri-devel/2022-March/345915.html
I made a mistake when converting to use the
GENMASK()andFIELD_PREP()macros in v4 as suggested by Andy. TheSSD130X_SET_COM_SCAN_DIR_MASKwasn't correct which would explain the output to be vertically flipped.Thanks, confirmed fixed.
Great, thanks a lot for testing and the confirmation!
Signature · 5 lines
Best regards, Javier Martinez Canillas Linux Engineering Red Hat
Hi Javier,
Quoted 66 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.
Signed-off-by Javier Martinez Canillas <[email protected]>drivers/gpu/drm/solomon/ssd130x.c new file +55
-0+static int ssd130x_update_rect (struct ssd130x_device *ssd130x,u8 *buf, +struct drm_rect *rect) +{ +unsigned int x = rect->x1; +unsigned int y = rect->y1; +unsigned int width =drm_rect_width (rect); +unsigned int height =drm_rect_height (rect); +unsigned int line_length =DIV_ROUND_UP (width,8 ); +unsigned int pages =DIV_ROUND_UP (y %8 + height,8 ); +u32 array_idx =0 ; +int ret, i, j, k; +u8 *data_array =NULL ; + + data_array =kcalloc (width, pages,GFP_KERNEL ); +if (!data_array) +return -ENOMEM ; + +/* +* The screen is divided in pages, each having a height of 8 +* pixels, and the width of the screen. When sending a byte of +* data to the controller, it gives the 8 bits for the current +* column. I.e, the first byte are the 8 bits of the first +* column, then the 8 bits for the second column, etc. +* +* +* Representation of the screen, assuming it is 5 bits +* wide. Each letter-number combination is a bit that controls +* one pixel. +* +* A0 A1 A2 A3 A4 +* B0 B1 B2 B3 B4 +* C0 C1 C2 C3 C4 +* D0 D1 D2 D3 D4 +* E0 E1 E2 E3 E4 +* F0 F1 F2 F3 F4 +* G0 G1 G2 G3 G4 +* H0 H1 H2 H3 H4 +* +* If you want to update this screen, you need to send 5 bytes: +* (1) A0 B0 C0 D0 E0 F0 G0 H0 +* (2) A1 B1 C1 D1 E1 F1 G1 H1 +* (3) A2 B2 C2 D2 E2 F2 G2 H2 +* (4) A3 B3 C3 D3 E3 F3 G3 H3 +* (5) A4 B4 C4 D4 E4 F4 G4 H4 +*/ + + ret =ssd130x_set_col_range (ssd130x, ssd130x->col_offset + x, width); +if (ret <0 ) + goto out_free; + + ret =ssd130x_set_page_range (ssd130x, ssd130x->page_offset + y /8 , pages); +if (ret <0 ) + goto out_free; + +for (i = y /8 ; i < y /8 + pages; i++) {
drivers/gpu/drm/solomon/ssd130x.c line 412
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c new file +10
-0+int m =8 ; + +/* Last page may be partial */ +if (8 * (i +1 ) > ssd130x->height) + m = ssd130x->height %8 ; +for (j = x; j < x + width; j++) { +u8 data =0 ; + +for (k =0 ; k < m; k++) { +u8 byte = buf[(8 * i + k) * line_length + j /8 ];
As buf does not point to (0, 0), the above is not correct if rect.x1 != 0 or rect.y1 != 0. After fixing that, writing more than one text line to the console works, but I still see an issue with updates where the rectangle size and/or position are not aligned to 8 pixels horizontally. Will do more investigation, and send fixes...
Quoted 16 lines
drivers/gpu/drm/solomon/ssd130x.c new file +16
-0+u8 bit = (byte >> (j %8 )) &1 ; + + data |= bit << k; + } + data_array[array_idx++] = data; + } + } + + ret =ssd130x_write_data (ssd130x, data_array, width * pages); + +out_free: +kfree (data_array); +return ret; +} + +static void ssd130x_clear_screen (struct ssd130x_device *ssd130x)
drivers/gpu/drm/solomon/ssd130x.c line 438
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c new file +10
-0+{ +u8 *buf =NULL ; +struct drm_rect fullscreen = { + .x1 =0 , + .x2 = ssd130x->width, + .y1 =0 , + .y2 = ssd130x->height, + }; + + buf =kcalloc (ssd130x->width, ssd130x->height,GFP_KERNEL );
This buffer is larger than needed. Will send a fix.
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+if (!buf) +return ; + +ssd130x_update_rect (ssd130x, buf, &fullscreen); + +kfree (buf); +}
drivers/gpu/drm/solomon/ssd130x.c line 455
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x.c new file +10
-0+ +static int ssd130x_fb_blit_rect (struct drm_framebuffer *fb,const struct dma_buf_map *map, +struct drm_rect *rect) +{ +struct ssd130x_device *ssd130x =drm_to_ssd130x (fb->dev); +void *vmap = map->vaddr;/* TODO: Use mapping abstraction properly */ +int ret =0 ; +u8 *buf =NULL ; + + buf =kcalloc (fb->width, fb->height,GFP_KERNEL );
This buffer is much larger than needed. Will send a fix.
drivers/gpu/drm/solomon/ssd130x.c line 466
Quoted 11 lines
drivers/gpu/drm/solomon/ssd130x.c new file +11
-0+if (!buf) +return -ENOMEM ; + +drm_fb_xrgb8888_to_mono_reversed (buf,0 , vmap, fb, rect); + +ssd130x_update_rect (ssd130x, buf, rect); + +kfree (buf); + +return ret; +}
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,
On 3/9/22 21:04, Geert Uytterhoeven wrote:
[snip]
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x.c new file +7
-0+ +/* Last page may be partial */ +if (8 * (i +1 ) > ssd130x->height) + m = ssd130x->height %8 ; +for (j = x; j < x + width; j++) { +u8 data =0 ; +
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x.c line 412
Quoted 2 lines
drivers/gpu/drm/solomon/ssd130x.c new file +2
-0+for (k =0 ; k < m; k++) { +u8 byte = buf[(8 * i + k) * line_length + j /8 ];As buf does not point to (0, 0), the above is not correct if rect.x1 != 0 or rect.y1 != 0. After fixing that, writing more than one text line to the console works, but I still see an issue with updates where the rectangle size and/or position are not aligned to 8 pixels horizontally. Will do more investigation, and send fixes...
Right, I believe this is a consequence of introducing shadow buffers at some point and not adjusting the logic in this function.
Thanks a lot for tracking down the issues and working on fixes for them!
--
Best regards,
Javier Martinez Canillas
Linux Engineering
Red Hat
Javier Martinez Canillas
maintainerPATCH v6 4/6 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.
---
(no changes since v5)
Changes in v5:
- Add Andy Shevchenko's Reviewed-by tag to patch #4.
Changes in v4:
- Remove unnecessary casting (Geert Uytterhoeven)
- Remove redundant blank lines (Andy Shevchenko)
- Remove comma after of_device_id table terminator (Andy Shevchenko)
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 | 116 ++++++++++++++++++++++++++ 3 files changed, 126 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 +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v6 4/6] drm/solomon: Add SSD130x OLED displays I2C support
Quoted 5 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]>Reviewed-by Andy Shevchenko <[email protected]>
Maxime
Javier Martinez Canillas
maintainerPATCH v6 5/6 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.
---
(no changes since v5)
Changes in v5:
- Add Andy Shevchenko's Reviewed-by tag to patch #5.
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
@@ -6102,6 +6102,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
Re: [PATCH v6 5/6] MAINTAINERS: Add entry for Solomon SSD130x OLED displays DRM driver
Quoted 9 lines · Javier Martinez Canillas
To 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.
Signed-off-by Javier Martinez Canillas <[email protected]>Acked-by Sam Ravnborg <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Maxime
Javier Martinez Canillas
maintainerPATCH v6 6/6 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 v5)
Changes in v5:
- Add Andy Shevchenko's Reviewed-by tag to patch #6.
Changes in v4:
- Add Rob Herring Acked-by tag to patch adding as DT binding co-maintainer.
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
Re: [PATCH v6 6/6] dt-bindings: display: ssd1307fb: Add myself as binding co-maintainer
Quoted 11 lines · Javier Martinez Canillas
The 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.
Suggested-by Sam Ravnborg <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Acked-by Rob Herring <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Maxime
Javier Martinez Canillas
maintainerQuoted 12 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.
Using the DRM fbdev emulation, all the tests from Geert Uytterhoeven repo
(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 v6 that addresses the issues pointed in v5. Thanks a lot to all reviewers that gave me feedback and comments.
Pushed this series to drm-misc (drm-misc-next). Thanks all!
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat