drm/ssd130x: Make the SSD1322 work
Subsystems (4)
cover drm/ssd130x: Make the SSD1322 work
The SSD1322 has been in the ssd130x match tables since the ssd132x family was added, but that family was brought up on an SSD1327. The two controllers share a RAM layout and many opcodes, but the SSD1322 takes command parameters on the data path and differs in several commands. This series gives the SSD1322 its own family, shaped like the ssd135x.
Mario Limonciello's connector luminance series [1], not merged yet, sends the SSD130x contrast command to every family it does not know. The SSD1322 does not have that command, so whichever series lands second needs an SSD1322 case there.
Testing:
- ZJY 3.12" 256x64 SSD1322 module on 4-wire SPI (mode 3) at 16 MHz,
Raspberry Pi 5, Raspberry Pi rpi-7.3.y kernel (7.3.0-v8-16k+) with
the ssd130x files from this series in tree. That tree also needed
commit 3dcb0564c509 from drm-misc-next. - Without the series, a modeset and a full white frame leave the panel dark. With it, the frame is white as expected.
- A KMS client at ~200 fps matches its rendered frames on the glass through a camera harness, at the default clock and with solomon,dclk-div = <1>.
- Backlight brightness 0, 64, 127 and 255 moves the contrast on the glass.
- solomon,dclk-div = <3> is refused with an error and no init is sent.
[1] https://lore.kernel.org/dri-devel/[email protected]/
Thanks,
Fabio
Fabio Piparo (2):
dt-bindings: display: solomon,ssd132x: Add col-offset and dclk
properties for the SSD1322
drm/ssd130x: Add SSD1322_FAMILY and move the SSD1322 to it
.../bindings/display/solomon,ssd132x.yaml | 29 ++ drivers/gpu/drm/solomon/ssd130x-i2c.c | 3 +- drivers/gpu/drm/solomon/ssd130x-spi.c | 6 +- drivers/gpu/drm/solomon/ssd130x.c | 277 +++++++++++++++++- drivers/gpu/drm/solomon/ssd130x.h | 4 +- 5 files changed, 310 insertions(+), 9 deletions(-)
base-commit: 21803a577cc692d01307102799f795a606871212
Signature · 1 line
2.53.0
PATCH 1/2 dt-bindings: display: solomon,ssd132x: Add col-offset and dclk properties for the SSD1322
Add solomon,col-offset, solomon,dclk-div and solomon,dclk-frq for the SSD1322, to set where the panel sits in the controller's columns and the panel's refresh rate. On the SSD1322 the clock divisor is a power of two, from 1 to 1024.
--- .../bindings/display/solomon,ssd132x.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +29 -0
@@ -16,6 +16,29 @@ properties: - solomon,ssd1325 - solomon,ssd1327 + solomon,col-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 119 + default: 0 + description: + Offset of columns that the screen is mapped to, in units of four + pixels. + + solomon,dclk-div: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] + default: 2 + description: + Clock divisor. + + solomon,dclk-frq: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 15 + default: 9 + description: + Clock frequency, higher value means higher frequency. + required: - compatible - reg
@@ -46,6 +69,9 @@ allOf: default: 128 solomon,height: default: 80 + solomon,col-offset: false + solomon,dclk-div: false + solomon,dclk-frq: false - if: properties:
@@ -58,6 +84,9 @@ allOf: default: 128 solomon,height: default: 128 + solomon,col-offset: false + solomon,dclk-div: false + solomon,dclk-frq: false unevaluatedProperties: false
Signature · 1 line
2.53.0
PATCH 2/2 drm/ssd130x: Add SSD1322_FAMILY and move the SSD1322 to it
In reply to Fabio PiparoThe SSD1322 has been in the match tables since commit fdd591e00a9c ("drm/ssd130x: Add support for the SSD132x OLED controller family") as a member of the ssd132x family, which was brought up on an SSD1327. The two controllers share the 4-bit grayscale RAM layout and many opcodes, but the ssd132x paths cannot produce an image on an SSD1322:
- A command's parameters travel on the data path, as on the SSD1351, so every multi-byte command in ssd132x_init() is read as a run of single opcodes.
- Some of the opcodes differ: 0xa4 is "entire display off" on the SSD1322 and normal display mode is 0xa6, the multiplex ratio command is 0xca, the contrast command 0xc1 and the precharge voltage command 0xbb.
- A column address covers four Segments instead of two, the RAM only accepts pixel data after a Write RAM command (0x5c), and with nibble remap the leftmost pixel of a pair is the high nibble.
Give the SSD1322 its own family, shaped like ssd135x: an init table, a Write RAM before the pixel data, a contrast command with its value in the data phase, and its own plane update, encoder enable and backlight callbacks.
The init sequence follows the Newhaven NHD-3.12-25664UCW2 datasheet, including its analog settings for the module (external VSL, precharge, VCOMH), with three changes: the display clock and the column offset come from the device tree, the contrast is the backlight brightness and is set after the sequence, and dual COM line mode, which the datasheet only allows up to 64 rows, is turned off for taller panels.
--- drivers/gpu/drm/solomon/ssd130x-i2c.c | 3 +- drivers/gpu/drm/solomon/ssd130x-spi.c | 6 +- drivers/gpu/drm/solomon/ssd130x.c | 277 +++++++++++++++++++++++++- drivers/gpu/drm/solomon/ssd130x.h | 4 +- 4 files changed, 281 insertions(+), 9 deletions(-)
drivers/gpu/drm/solomon/ssd130x-i2c.c +2 -1
@@ -92,11 +92,12 @@ static const struct of_device_id ssd130x_of_match[] = { .compatible = "solomon,ssd1309fb-i2c", .data = &ssd130x_variants[SSD1309_ID], }, -/* ssd132x family */ +/* ssd1322 family */ { .compatible = "solomon,ssd1322", .data = &ssd130x_variants[SSD1322_ID], }, +/* ssd132x family */ { .compatible = "solomon,ssd1325", .data = &ssd130x_variants[SSD1325_ID],
drivers/gpu/drm/solomon/ssd130x-spi.c +4 -2
@@ -128,11 +128,12 @@ static const struct of_device_id ssd130x_of_match[] = { .compatible = "solomon,ssd1309", .data = &ssd130x_variants[SSD1309_ID], }, -/* ssd132x family */ +/* ssd1322 family */ { .compatible = "solomon,ssd1322", .data = &ssd130x_variants[SSD1322_ID], }, +/* ssd132x family */ { .compatible = "solomon,ssd1325", .data = &ssd130x_variants[SSD1325_ID],
@@ -170,8 +171,9 @@ static const struct spi_device_id ssd130x_spi_id[] = { { .name = "ssd1306", .driver_data = SSD1306_ID }, { .name = "ssd1307", .driver_data = SSD1307_ID }, { .name = "ssd1309", .driver_data = SSD1309_ID }, - /* ssd132x family */ + /* ssd1322 family */ { .name = "ssd1322", .driver_data = SSD1322_ID }, + /* ssd132x family */ { .name = "ssd1325", .driver_data = SSD1325_ID }, { .name = "ssd1327", .driver_data = SSD1327_ID },/* ssd133x family */
drivers/gpu/drm/solomon/ssd130x.c +272 -5
373 lines not on this page · raw message
drivers/gpu/drm/solomon/ssd130x.h +3 -1
@@ -28,6 +28,7 @@ enum ssd130x_family_ids {SSD132X_FAMILY ,SSD133X_FAMILY ,SSD135X_FAMILY , + SSD1322_FAMILY, }; enum ssd130x_variants {
@@ -37,8 +38,9 @@ enum ssd130x_variants {SSD1306_ID ,SSD1307_ID ,SSD1309_ID , -/* ssd132x family */ +/* ssd1322 family */ SSD1322_ID , +/* ssd132x family */ SSD1325_ID , SSD1327_ID,/* ssd133x family */
Signature · 1 line
2.53.0
Re: [PATCH 1/2] dt-bindings: display: solomon,ssd132x: Add col-offset and dclk properties for the SSD1322
In reply to Fabio PiparoQuoted 23 lines · Fabio Piparo
Add solomon,col-offset, solomon,dclk-div and solomon,dclk-frq for the SSD1322, to set where the panel sits in the controller's columns and the panel's refresh rate. On the SSD1322 the clock divisor is a power of two, from 1 to 1024.
Assisted-by LLMSigned-off-by Fabio Piparo <[email protected]>--- .../bindings/display/solomon,ssd132x.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +4
-0@@ -16,6 +16,29 @@ properties: - solomon,ssd1325 - solomon,ssd1327 + solomon,col-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 119 + default: 0
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 32
Quoted 10 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +10
-0+ description: + Offset of columns that the screen is mapped to, in units of four + pixels. + + solomon,dclk-div: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] + default: 2 + description: + Clock divisor.
Why this cannot be deduced from clock frequency?
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 35
Quoted 3 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +3
-0+ + solomon,dclk-frq: + $ref: /schemas/types.yaml#/definitions/uint32
Use either existing properties or - if there aren't such - existing unit suffixes.
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/property-units.yaml
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 40
Quoted 5 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +5
-0+ minimum: 0 + maximum: 15 + default: 9 + description: + Clock frequency, higher value means higher frequency.
Why would the frequency be fixed/static?
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 43
Quoted 3 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +1
-0+ required: - compatible
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-bindings: display: solomon,ssd132x: Add col-offset and dclk properties for the SSD1322
Quoted 9 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 32
Quoted 6 lines · Fabio Piparo
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +6
-0+ solomon,dclk-div: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] + default: 2 + description: + Clock divisor.Why this cannot be deduced from clock frequency?
On this module the SSD1322 runs from its internal oscillator, and the external clock pin is not on the ribbon. These two values only set how often the panel redraws.
Quoted 6 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 35
Quoted 2 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +2
-0+ solomon,dclk-frq: + $ref: /schemas/types.yaml#/definitions/uint32Use either existing properties or - if there aren't such - existing unit suffixes.
Quoted 7 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 40
Quoted 5 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +5
-0+ minimum: 0 + maximum: 15 + default: 9 + description: + Clock frequency, higher value means higher frequency.Why would the frequency be fixed/static?
Right, it doesn't need to be, and I'll drop both properties in v2.
I still need the redraw rate to be adjustable. I drive this panel at about 200 FPS, and at the default clock it redraws at about 115 times a second. One way would be to offer the 256x64 mode at a few refresh rates and set the clock divider from the mode userspace picks, the way panel-newvision-nv3051d offers 640x480 at 60, 100 and 120 Hz. The rates would be approximate since the panel's oscillator is not exact, is this a good way to do it here?
Thanks,
Fabio
Re: [PATCH 2/2] drm/ssd130x: Add SSD1322_FAMILY and move the SSD1322 to it
In reply to Fabio PiparoFabio Piparo <[email protected]> writes:
Hello Fabio,
Thanks a lot for your patch and sorry for the delay with the review...
Quoted 6 lines
The SSD1322 has been in the match tables since commit
fdd591e00a9c("drm/ssd130x: Add support for the SSD132x OLED controller family") as a member of the ssd132x family, which was brought up on an SSD1327. The two controllers share the 4-bit grayscale RAM layout and many opcodes, but the ssd132x paths cannot produce an image on an SSD1322:
Yes, I wrongly assumed that SSD1322, SSD1325 and SSD1327 were similar. As you point out, I tested with SSD1327 because it was the only SSD132x panel I had. I *think* that also checked the SSD1325 datasheet and saw that were similar to SSD1327. But I did not check for SSD1322 indeed.
Quoted 11 lines
- A command's parameters travel on the data path, as on the SSD1351, so every multi-byte command in
ssd132x_init()is read as a run of single opcodes.
- Some of the opcodes differ:0xa4is "entire display off" on the SSD1322 and normal display mode is0xa6, the multiplex ratio command is0xca, the contrast command0xc1and the precharge voltage command0xbb.
- A column address covers four Segments instead of two, the RAM only accepts pixel data after a Write RAM command (0x5c), and with nibble remap the leftmost pixel of a pair is the high nibble.
Thanks for this summary, it is very helpful to review your changes.
Quoted 5 lines
Give the SSD1322 its own family, shaped like ssd135x: an init table, a Write RAM before the pixel data, a contrast command with its value in the data phase, and its own plane update, encoder enable and backlight callbacks.
I don't think that like this approach. When I conceived the per-family split, I wanted to use the same "families" that Solomon chose for their display controllers.
As far as I can tell, the part numbering depends on the pixel formats that are supported by the devices. That is:
* SSD130x: monochrome
* SSD132x: 16 gray scale
* SSD133x: 65k color
* SSD135x: 262k color
So I would like the driver's family split to match the HW grouping.
Having a family for a single device would break this convention. Also, your SSD1322_FAMILY reuses many of the ssd132x helpers and the ssd1322 ones you are adding are just a slight variation of the existing ones.
Instead, what about adding an .init and .set_contrast function pointers to struct ssd130x_deviceinfo ? That way, you could for example use the same ssd132x_encoder_atomic_enable() and just lookup the deviceinfo's .init, instead of unconditionally call to the ssd132x_init() helper.
The same comment applies for the rest of your logic, I really think that you could make extend the other ssd132x helpers to accommodate for the SSD1322 differences.
For example, having a device_info .nibble_hi_first, .segment_width and .needs_write_ram fields for ssd132x_update_rect(), etc.
I believe doing it this way would make the driver more organized. But maybe I'm missing subtleties, so I want to know your thoughts on this.
Quoted 8 lines
The init sequence follows the Newhaven NHD-3.12-25664UCW2 datasheet, including its analog settings for the module (external VSL, precharge, VCOMH), with three changes: the display clock and the column offset come from the device tree, the contrast is the backlight brightness and is set after the sequence, and dual COM line mode, which the datasheet only allows up to 64 rows, is turned off for taller panels.
Assisted-by LLM
Please drop this, is not needed anymore since commit 1e035297ffda ("docs:
remove Assisted-by references").
Quoted 13 lines
Signed-off-by Fabio Piparo <[email protected]>--- drivers/gpu/drm/solomon/ssd130x-i2c.c | 3 +- drivers/gpu/drm/solomon/ssd130x-spi.c | 6 +- drivers/gpu/drm/solomon/ssd130x.c | 277 +++++++++++++++++++++++++- drivers/gpu/drm/solomon/ssd130x.h | 4 +- 4 files changed, 281 insertions(+), 9 deletions(-)drivers/gpu/drm/solomon/ssd130x-i2c.c +0
-0
drivers/gpu/drm/solomon/ssd130x-i2c.c static const struct of_device_id ssd130x_of_match[] = { · line 99
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +1
-1@@ -92,11 +92,12 @@ static const struct of_device_id ssd130x_of_match[] = { .compatible = "solomon,ssd1309fb-i2c", .data = &ssd130x_variants[SSD1309_ID], }, -/* ssd132x family */ +/* ssd1322 family */ { .compatible = "solomon,ssd1322", .data = &ssd130x_variants[SSD1322_ID], },
This is what I mentioned, a family for a single device doesn't sound correct to me.
drivers/gpu/drm/solomon/ssd130x-i2c.c static const struct of_device_id ssd130x_of_match[] = { · line 102
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +1
-0#define SSD132X_SEGMENT_WIDTH 2 +#define SSD1322_SEGMENT_WIDTH 4
I think it's OK to keep this and then you could do:
+ [SSD1322_ID] = {
+ .default_width = 480,
+ .default_height = 128,
+ .default_dclk_div = 2,
+ .default_dclk_frq = 9,
+ .family_id = SSD132x_FAMILY,
+ .cmd_params_are_data = true,
+ .segment_width = SSD1322_SEGMENT_WIDTH,
+ .needs_write_ram = true,
+ .nibble_hi_first = true,
+ .init = ssd1322_init,
+ .set_contrast = ssd1322_set_contrast,
+
+ },
Please post a preparatory patch that sets the .init and .set_contrast callbacks for all the other devices. It will be just set to the family defaults currently used.
drivers/gpu/drm/solomon/ssd130x-i2c.c line 187
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +0
-0/* ssd13xx commands */ #define
SSD13XX_CONTRAST0x81drivers/gpu/drm/solomon/ssd130x-i2c.c +1
-0@@ -182,6 +184,38 @@#define SSD135X_SET_REMAP_COM_SPLIT BIT(5)#define SSD135X_SET_REMAP_65K BIT(6) +/* ssd1322 commands */
Just put it under /* ssd132x commands */, the constant defines already are named SSD1322_* which implies is only for SSD1322.
[...]
Quoted 15 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +15
-0+static int ssd1322_update_rect (struct ssd130x_device *ssd130x, +struct drm_rect *rect,u8 *data_array, +unsigned int pitch) +{ +unsigned int col = ssd130x->col_offset + rect->x1 /SSD1322_SEGMENT_WIDTH ; +unsigned int columns =DIV_ROUND_UP (drm_rect_width (rect),SSD1322_SEGMENT_WIDTH ); +unsigned int rows =drm_rect_height (rect); +struct drm_device *drm = &ssd130x->drm; +int ret; + +drm_WARN_ONCE (drm, rect->x1 %SSD1322_SEGMENT_WIDTH !=0 , +"x must be aligned to screen segment\n" ); + + ret =ssd132x_set_col_range (ssd130x, col, columns); +if (ret <0 )
drivers/gpu/drm/solomon/ssd130x-i2c.c line 212
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +10
-0+return ret; + + ret =ssd132x_set_row_range (ssd130x, rect->y1, rows); +if (ret <0 ) +return ret; + + ret =ssd130x_write_cmd (ssd130x,1 ,SSD1322_WRITE_RAM ); +if (ret <0 ) +return ret; +
this for example would be something like the following:
if (ssd130x->device_info->needs_write_ram) {
ret = ssd130x_write_cmd(ssd130x, 1, SSD1322_WRITE_RAM);
if (ret < 0)
return ret;
}and you could keep reuse the nibble pack logic from ssd132x_update_rect() here. Just query deviceinfo->nibble_hi_first (or whatever you want to name it), and use to decide whether to do (n2 & 0xf0) | (n1 >> 4) or (n1 & 0xf0) | (n2 >> 4).
Quoted 5 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +5
-0+static int ssd1322_fb_blit_rect (struct drm_framebuffer *fb, +const struct iosys_map *vmap, +struct drm_rect *rect,u8 *buf, +u8 *data_array, +struct drm_format_conv_state *fmtcnv_state)
drivers/gpu/drm/solomon/ssd130x-i2c.c
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +10
-0+{ +struct ssd130x_device *ssd130x =drm_to_ssd130x (fb->dev); +unsigned int width, height, pitch; +unsigned int i, j; +u32 array_idx =0 ; +struct iosys_map dst; + +/* Align x to display segment boundaries */ + rect->x1 =round_down (rect->x1,SSD1322_SEGMENT_WIDTH ); + rect->x2 = min_t(unsigned int, round_up(rect->x2, SSD1322_SEGMENT_WIDTH),
again deviceinfo->segment_width will be used to make ssd132x_fb_blit_rect() usable for both ssd132x and ssd1322.
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +9
-0+ ssd130x->width); + + width =drm_rect_width (rect); + height =drm_rect_height (rect); + pitch =DIV_ROUND_UP (width,2 ); + +iosys_map_set_vaddr (&dst, buf); +drm_fb_xrgb8888_to_gray8 (&dst, &width, vmap, fb, rect, fmtcnv_state); +
drivers/gpu/drm/solomon/ssd130x-i2c.c
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +10
-0+for (i =0 ; i < height; i++) { +/* Process pair of pixels and combine them into a single byte */ +for (j =0 ; j < width; j +=2 ) { +u8 n1 = buf[i * width + j]; +u8 n2 = j +1 < width ? buf[i * width + j +1 ] :0 ; + + data_array[array_idx++] = (n1 &0xf0 ) | (n2 >>4 ); + } + } +
And this nibble pack won't be needed anymore since ssd132x_update_rect() will be parameterized by the deviceinfo data.
Quoted 23 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +23
-0+static void ssd1322_primary_plane_atomic_update (struct drm_plane *plane, +struct drm_atomic_commit *state) +{ +struct drm_plane_state *plane_state =drm_atomic_get_new_plane_state (state, plane); +struct drm_plane_state *old_plane_state =drm_atomic_get_old_plane_state (state, plane); +struct drm_shadow_plane_state *shadow_plane_state =to_drm_shadow_plane_state (plane_state); +struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, plane_state->crtc); +struct ssd130x_crtc_state *ssd130x_crtc_state =to_ssd130x_crtc_state (crtc_state); +struct ssd130x_plane_state *ssd130x_plane_state =to_ssd130x_plane_state (plane_state); +struct drm_framebuffer *fb = plane_state->fb; +struct drm_atomic_helper_damage_iter iter; +struct drm_device *drm = plane->dev; +struct drm_rect dst_clip; +struct drm_rect damage; +int idx; + +if (!drm_dev_enter (drm, &idx)) +return ; + +if (drm_gem_fb_begin_cpu_access (fb,DMA_FROM_DEVICE )) + goto out_drm_dev_exit; + +drm_atomic_helper_damage_iter_init (&iter, old_plane_state, plane_state);
drivers/gpu/drm/solomon/ssd130x-i2c.c
Quoted 10 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +10
-0+drm_atomic_for_each_plane_damage (&iter, &damage) { + dst_clip = plane_state->dst; + +if (!drm_rect_intersect (&dst_clip, &damage)) +continue ; + +ssd1322_fb_blit_rect (fb, &shadow_plane_state->data[0 ], &dst_clip, + ssd130x_plane_state->buffer, + ssd130x_crtc_state->data_array, + &shadow_plane_state->fmtcnv_state);
Note how the only difference with ssd132x_primary_plane_atomic_update() is the custom _fb_blit_rect() but as mentioned ssd132x_fb_blit_rect() can be reused. So you could just drop custom SSD1322 plane helpers.
drivers/gpu/drm/solomon/ssd130x-i2c.c
Quoted 8 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +8
-0+static void ssd1322_primary_plane_atomic_disable (struct drm_plane *plane, +struct drm_atomic_commit *state) +{ +/* +* Keep this empty function to avoid calling +* atomic_update when disabling the plane. +*/ +}
The ssd132x_primary_plane_atomic_disable() clears the screen. So I'm not sure why you needed this empty callback. Can you just reuse the ssd132x one ? Ah, you need to add similar changes to ssd132x_clear_screen().
That is, use deviceinfo->segment_width, check device_info->needs_write_ram to send the SSD1322_WRITE_RAM, etc.
drivers/gpu/drm/solomon/ssd130x-i2c.c
Quoted 6 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +6
-0+ [SSD1322_FAMILY] = { + DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, + .atomic_check = ssd132x_primary_plane_atomic_check, + .atomic_update = ssd1322_primary_plane_atomic_update, + .atomic_disable = ssd1322_primary_plane_atomic_disable, + },
And this can all go away since the default SSD132X_FAMILY plane helpers will be used for SSD1322 as well.
drivers/gpu/drm/solomon/ssd130x-i2c.c static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs[] = { · line 2053
Quoted 11 lines
};
static const struct
drm_plane_funcsssd130x_primary_plane_funcs= {drivers/gpu/drm/solomon/ssd130x-i2c.c +4
-0@@ -1825,6 +2047,10 @@ static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs[] = { .mode_valid = ssd130x_crtc_mode_valid, .atomic_check = ssd133x_crtc_atomic_check, }, + [SSD1322_FAMILY] = { + .mode_valid = ssd130x_crtc_mode_valid, + .atomic_check = ssd132x_crtc_atomic_check, + },
and this can go away since are the same as used by the SSD132X_FAMILY.
drivers/gpu/drm/solomon/ssd130x-i2c.c static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs[] = {
Quoted 12 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +12
-0+static void ssd1322_encoder_atomic_enable (struct drm_encoder *encoder, +struct drm_atomic_commit *state) +{ +struct drm_device *drm = encoder->dev; +struct ssd130x_device *ssd130x =drm_to_ssd130x (drm); +int ret; + + ret =ssd130x_power_on (ssd130x); +if (ret) +return ; + + ret =ssd1322_init (ssd130x);
only init is different, so the ssd132x + deviceinfo->init will be enough.
drivers/gpu/drm/solomon/ssd130x-i2c.c static const struct drm_encoder_helper_funcs ssd130x_encoder_helper_funcs[] = { · line 2224
Quoted 8 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +4
-0@@ -1967,6 +2218,10 @@ static const struct drm_encoder_helper_funcs ssd130x_encoder_helper_funcs[] = { .atomic_enable = ssd135x_encoder_atomic_enable, .atomic_disable = ssd130x_encoder_atomic_disable, }, + [SSD1322_FAMILY] = { + .atomic_enable = ssd1322_encoder_atomic_enable, + .atomic_disable = ssd130x_encoder_atomic_disable, + },
Same, it goes away.
drivers/gpu/drm/solomon/ssd130x-i2c.c static const struct drm_encoder_helper_funcs ssd130x_encoder_helper_funcs[] = {
Quoted 7 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +7
-0+static int ssd1322_update_bl (struct backlight_device *bdev) +{ +struct ssd130x_device *ssd130x =bl_get_data (bdev); + + ssd130x->contrast =backlight_get_brightness (bdev); + +return ssd1322_set_contrast (ssd130x, ssd130x->contrast);
ssd132x_update_bl() + deviceinfo->set_contrast instead.
drivers/gpu/drm/solomon/ssd130x-i2c.c
Quoted 3 lines
drivers/gpu/drm/solomon/ssd130x-i2c.c +3
-0+ [SSD1322_FAMILY] = { + .update_status = ssd1322_update_bl, + },
No need for this as well.
If you do all this rework, feel free to add my:
and I could just merge it as soon as you re-spin the series.
Thanks again for this work, it's great to know that more devices are working with this driver!
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Javier Martinez Canillas
maintainerRe: [PATCH 1/2] dt-bindings: display: solomon,ssd132x: Add col-offset and dclk properties for the SSD1322
In reply to Fabio PiparoQuoted 9 lines · Fabio Piparo
Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines · Fabio Piparo
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +6
-0+ solomon,dclk-div: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] + default: 2 + description: + Clock divisor.
Quoted 6 lines
Quoted 1 line
Why this cannot be deduced from clock frequency?
On this module the SSD1322 runs from its internal oscillator, and the external clock pin is not on the ribbon. These two values only set how often the panel redraws.
Yeah, the property name is misleading. Note that properies Fabio is adding are from Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml, which is for another family of controllers supported by the same driver.
The ssd132x, ssd133x and ssd135x families don't make use of them. That's why they are not defined in the DT binding schemas of these controllers.
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 35
Quoted 2 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +2
-0+ solomon,dclk-frq: + $ref: /schemas/types.yaml#/definitions/uint32Use either existing properties or - if there aren't such - existing unit suffixes.
Again Fabio just took what currently exists in solomon,ssd1307fb.yaml, I agree with Krzysztof though that these properties are not nice and don't really describe the hardware...
The ssd1307fb is pretty old and was originally for a fbdev driver, then a DRM driver was written based on that for ssd130x, and finally the DRM driver extended to support othere families, which had newer DT bindings.
Quoted 10 lines
Quoted 7 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml properties: · line 40
Quoted 5 lines
Documentation/devicetree/bindings/display/solomon,ssd132x.yaml +5
-0+ minimum: 0 + maximum: 15 + default: 9 + description: + Clock frequency, higher value means higher frequency.Why would the frequency be fixed/static?
Right, it doesn't need to be, and I'll drop both properties in v2.
Quoted 9 lines
I still need the redraw rate to be adjustable. I drive this panel at about 200 FPS, and at the default clock it redraws at about 115 times a second. One way would be to offer the 256x64 mode at a few refresh rates and set the clock divider from the mode userspace picks, the way panel-newvision-nv3051d offers 640x480 at 60, 100 and 120 Hz. The rates would be approximate since the panel's oscillator is not exact, is this a good way to do it here?
Fabio, I suggest to just drop this patch and as a first step just set a default_dclk_{div,freq} in the SSD1322 struct deviceinfo.
That way, your driver changes won't be blocked by the DT binding schema changes. Later, once your driver changes land, we can figure out what to do to make all this configurable from DT.
But Krzysztof is correct here that these properties don't seem the correct way to do it. They are just exposing raw register values in the DT, which is not the proper approach.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat