Re: [PATCH v2 2/4] drm/tiny: Add driver for Solomon SSD130X OLED displays
From: Javier Martinez Canillas
Date: Sat Feb 05 2022 - 12:40:15 EST
On 2/5/22 14:04, Andy Shevchenko wrote:
> On Fri, Feb 04, 2022 at 08:19:12PM +0100, Javier Martinez Canillas wrote:
>> On 2/4/22 15:26, Andy Shevchenko wrote:
>>> On Fri, Feb 04, 2022 at 02:43:45PM +0100, Javier Martinez Canillas wrote:
>
> ...
>
>>>> +struct ssd130x_device {
>>>> + struct drm_device drm;
>>>> + struct drm_simple_display_pipe pipe;
>>>> + struct drm_display_mode mode;
>>>> + struct drm_connector connector;
>>>
>>>
>>>> + struct i2c_client *client;
>>>
>>> Can we logically separate hw protocol vs hw interface from day 1, please?
>>> This will allow to add SPI support for this panel much easier.
>>>
>>> Technically I would like to see here
>>>
>>> struct device *dev;
>>>
>>> and probably (I haven't looked into design)
>>>
>>> struct ssd130x_ops *ops;
>>>
>>> or something alike.
>>
>> Sure. I wanted to keep the driver simple, making the writes bus agnostic and
>> adding a level of indirection would make it more complex. But I agree that
>> it will also make easier to add more buses later. I will do that for v3.
>
> I have SSD1306 display with SPI interface and I'm not able to test your series.
> With the above it at least gives me a point to consider helping (coding and
> testing) with SPI one.
>
Yes, I understand that. On the other hand, I only have a SSD1306 with an I2C
interface so I'm interested in supporting that. Then someone could extend to
support other buses :)
But I agree with you that making the driver easier to extend and using regmap
would be desirable. In fact, since I will add the level of indirection I can
got ahead and attempt to add the SPI support as well.
I won't be able to test but I can use drivers/staging/fbtft/fb_ssd1306.c as a
reference for this.
> ...
>
>>>> + if (!fb)
>>>> + return;
>>>
>>> Can it happen?
>>
>> I don't know, but saw that the handler of other drivers checked for this so
>> preferred to play safe and do the same.
>
> So, either cargo-cult or indeed it may happen. Somebody may conduct a research
> on this...
>
Someone familiar with the simple display pipe helpers should chime in, I tried
to grep around but couldn't figure out whether it was safe or not to assume the
struct drm_framebuffer won't ever be NULL in a struct drm_shadow_plane_state.
As mentioned other drivers were doing and I preferred to be defensive rather
than leading to a possible NULL pointer dereference.
> ...
>
>>>> + drm_mode_probed_add(connector, mode);
>>>> + drm_set_preferred_mode(connector, mode->hdisplay, mode->vdisplay);
>>>> +
>>>> + return 1;
>>>
>>> Positive code, what is the meaning of it?
>>
>> It's the number of connector modes. The driver only supports 1.
>
> A comment then?
>
Yes, that makes sense.
Best regards,
--
Javier Martinez Canillas
Linux Engineering
Red Hat