On 2022-05-01 16:56:45, Abhinav Kumar wrote: > [snip] > Wouln't this macro already make sure that 'reg' doesnt have anything in > the top 16 bits? Its doing a & with 0x00003f00 Like I said, it is unlikely that this happens, only if someone starts changing the code that assigns to `reg` which is unlikely to pass review anyway. > [snip] > We can have a common bitfield layout for the two channels for command mode. > > So we can do something like below for common fields: > > -static inline uint32_t > DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE(uint32_t val) > +static inline uint32_t > DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM_DATATYPE(uint32_t val, uint32_t > stream_id) > { > - return ((val) << > DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__SHIFT) & > DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__MASK; > + return ((val) << > (DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__SHIFT + (stream_id > * 16)) & DSI_COMMAND_COMPRESSION_MODE_CTRL_STREAM0_DATATYPE__MASK; > } > > Video mode can also use all of these except for WC as that field is not > present for cmd modes. > > This can go as a separate change . > > I can push this and perhaps get a Tested-by from Vinod as I dont have a > setup to re-validate this. How would you represent this in XML? I was hoping for a method that allows to construct the value in a generic way, without register names, and then simply have a "register macro" that moves (and perhaps masks) the preconstructed value into the right place. A bit like how `enum`s are currently set up in XML, but with bit ranges for the values and macros to set a value. I think I've _partially_ found what I was looking for: a `<bitset>`. However, I don't know if we can utilize this multiple times within a single `reg32`, once with an offset for stream1. Alas, it's just bikeshedding at this point. - Marijn