Re: [PATCH 28/57] media: Add ovxxxx_16bit_addr_reg_helpers.h

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

 



Hi Andy,

On 2/10/23 16:35, Andy Shevchenko wrote:
> On Fri, Feb 10, 2023 at 01:05:52PM +0200, Laurent Pinchart wrote:
>> On Fri, Feb 10, 2023 at 12:53:43PM +0200, Andy Shevchenko wrote:
>>> On Fri, Feb 10, 2023 at 12:47:55PM +0200, Sakari Ailus wrote:
>>>> On Fri, Feb 10, 2023 at 12:29:19PM +0200, Laurent Pinchart wrote:
>>>>> On Fri, Feb 10, 2023 at 12:21:15PM +0200, Sakari Ailus wrote:
>>>>>> On Thu, Feb 09, 2023 at 06:11:12PM +0200, Laurent Pinchart wrote:
> 
> ...
> 
>>>>>> I took a look at this some time ago, too, and current regmap API is a poor
>>>>>> fit for CCI devices. CCI works on top of e.g. both I²C and I3C so something
>>>>>> on top of regmap is a better approach indeed.
>>>>>
>>>>> I'm confused, is regmap a poor fit, or a better approach ?
>>>>
>>>> I'm proposing having something on top of regmap, but not changing regmap
>>>> itself.
>>>
>>> I don't understand why we can't change regmap? regmap has a facility called
>>> regmap bus which we can provide specifically for these types of devices. What's
>>> wrong to see it done?
>>
>> How would that work ?
> 
> If I'm not mistaken, you may introduce something like regmal CCI and then
> 
> 	regmap_init_cci();
> 
> 
> 	regmap_read()/regmap_write()
> 	regmap_update_bits()
> 	regmap_bulk_*()
> 
> at your service without changing a bit in the drivers (they will use plain
> regmap APIs instead of custom ones).

regmap_bus is for low-level busses like i2c, i3c, spi, etc.

We could "abuse" this to overwrite the standard regmap read/write helpers
with bus specific ones, but then we loose the actual bus abstraction
and we would need separate regmap-cci implementations for i2c/i3c/spi.

> Again, we can extend regmap to have something like
>
>	int (*reg_width)(regmap *, offset)
>
> callback added that will tell the regmap bus underneath what size to use.
>
> In the driver one will define the respective method to return these widths.

That won't work internal helpers to marshall raw-buffers with both reg-addr
+ reg value(s) to pass to the low-level (i2c/i3c/spi) drivers use an internal
regmap.format struct which gets filled with reg-width specific info once
from __regmap_init() what you are suggesting really requires major surgery
to the whole regmap core.

CCI really is an extra protocol layer on top of lower-level / more primitive
busses and it is best to have a helper library with a few helpers using
regmap underneath to abstract the raw bus accesses away. Note this helper
library can be quite thin and small though :)

Regards,

Hans




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux