Re: [PATCH v2 3/3] drm/panel: Add MIPI DBI compatible SPI driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Den 27.01.2022 18.19, skrev David Lechner:
> On 1/25/22 11:57 AM, Noralf Trønnes wrote:
>> Add a driver that will work with most MIPI DBI compatible SPI panels.
>> This avoids adding a driver for every new MIPI DBI compatible controller
>> that is to be used by Linux. The 'compatible' Device Tree property with
>> a '.bin' suffix will be used to load a firmware file that contains the
>> controller configuration.
>>
>> Example (driver will load sainsmart18.bin):
>>
>> display@0 {
>>     compatible = "sainsmart18", "panel-mipi-dbi-spi";
>>     reg = <0>;
>>     reset-gpios = <&gpio 25 0>;
>>     dc-gpios = <&gpio 24 0>;
>> };
>>
> 
> ...
> 
>> +static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
>> +{
>> +    struct device *dev = &spi->dev;
>> +    struct drm_display_mode mode;
>> +    struct mipi_dbi_dev *dbidev;
>> +    const struct firmware *fw;
>> +    const char *compatible;
>> +    struct drm_device *drm;
>> +    struct property *prop;
>> +    bool fw_found = false;
>> +    struct mipi_dbi *dbi;
>> +    struct gpio_desc *dc;
>> +    char fw_name[40];
>> +    int ret;
>> +
>> +    dbidev = devm_drm_dev_alloc(dev, &panel_mipi_dbi_driver, struct
>> mipi_dbi_dev, drm);
>> +    if (IS_ERR(dbidev))
>> +        return PTR_ERR(dbidev);
>> +
>> +    dbi = &dbidev->dbi;
>> +    drm = &dbidev->drm;
>> +
>> +    of_property_for_each_string(dev->of_node, "compatible", prop,
>> compatible) {
>> +        snprintf(fw_name, sizeof(fw_name), "%s.bin", compatible);
>> +
>> +        ret = firmware_request_nowarn(&fw, fw_name, dev);
>> +        if (ret) {
>> +            drm_dbg(drm, "No config file found for compatible: '%s'
>> (error=%d)\n",
>> +                compatible, ret);
>> +            continue;
>> +        }
>> +
> 
> Should we add a directory prefix to the firmware file name to avoid the
> possibility of
> file name clashes with unrelated firmwares?

I did consider this but I think it very unlikely that there would be a
collision between the name of display/panel and some other firmware file
which usually have the product name/model in the filename. And in the
unlikelihood that there is a collision it's possible to choose another
name for the compatible.

Noralf.



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux