Hi Reza,

On 10/16/26 8:30 AM, Reza Kurniawan wrote:
Many places open-code the conversion between log2 bits-per-pixel and
the actual number of bits or bytes per pixel, using expressions such as
"1 << bpix", "(1 << bpix) / 8" and "((1 << bpix) >> 3)". Meanwhile,
<video.h> already provides VNBITS() and VNBYTES() helpers for exactly
these conversions. Replace the open-coded expressions with the helpers.

Using the helpers makes the intent of the expression clear, removes
duplicated bit manipulation, and reduces the reliance on the specially
crafted VIDEO_BPP* enum values, since callers no longer need to know
that those values are log2 quantities which is also important for
future extensions.

Note that VNBYTES() is only correct for 8bpp and above, since it returns
a whole number of bytes per pixel and cannot represent sub-byte pixel
sizes. Every site converted to VNBYTES() here uses 16bpp or 32bpp, so
the result is identical to the original expression.

No functional change is made.

Signed-off-by: Reza Kurniawan <[email protected]>
---
Changes in v2:
- Convert uncaught conversion cases in the following files:
   - arch/sandbox/cpu/sdl.c
   - boot/fdt_simplefb.c
   - drivers/video/atmel_lcdfb.c
   - drivers/video/rockchip/rk_vop.c
   - drivers/video/sunxi/sunxi_de2.c
   - drivers/video/tegra/tegra124/display.c
- Updated commit message
- Link to v1: 
https://patch.msgid.link/[email protected]
---
  arch/sandbox/cpu/sdl.c                 | 4 ++--
  boot/fdt_simplefb.c                    | 2 +-
  cmd/bdinfo.c                           | 2 +-
  drivers/video/atmel_hlcdfb.c           | 2 +-
  drivers/video/atmel_lcdfb.c            | 4 ++--
  drivers/video/imx/mxc_ipuv3_fb.c       | 2 +-
  drivers/video/meson/meson_vpu.c        | 4 ++--
  drivers/video/mvebu_lcd.c              | 2 +-
  drivers/video/rockchip/rk_vop.c        | 4 ++--

Reviewed-by: Quentin Schulz <[email protected]> # Rockchip

Cheers,
Quentin

Reply via email to