media: qcom: camss: Add per-format BPL alignment helper

Add camss_format_get_bpl_alignment(), a helper that returns the
bytes-per-line (BPL) alignment requirement for a given CAMSS format.

Different RAW Bayer packing schemes impose different BPL alignment
constraints (e.g. RAW10 requires multiples of 5 bytes, RAW12 multiples of
3 bytes, RAW14 multiples of 7 bytes, etc.). Centralizing this logic
makes the alignment rules explicit and avoids duplicating them across
the pipeline.

This will allow PIX paths and buffer preparation code to correctly
round up BPL values to hardware-required boundaries.

Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
This commit is contained in:
Loic Poulain 2026-03-13 20:51:50 +01:00 committed by Bryan O'Donoghue
parent 5837c36e01
commit 91978c39ee
2 changed files with 15 additions and 0 deletions

View File

@ -7,8 +7,10 @@
* Copyright (c) 2023, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Technologies, Inc.
*/
#include <linux/bits.h>
#include <linux/bug.h>
#include <linux/errno.h>
#include <linux/lcm.h>
#include "camss-format.h"
@ -33,6 +35,18 @@ u8 camss_format_get_bpp(const struct camss_format_info *formats, unsigned int nf
return formats[0].mbus_bpp;
}
/*
* camss_format_get_bpl_alignment - Retrieve required BPL alignment for a given format.
* @format: a pointer to the format
*
* Return the required alignment, in bytes.
*/
unsigned int camss_format_get_bpl_alignment(const struct camss_format_info *format)
{
/* Minimal number of bytes required to keep the line length an integer number of pixels */
return lcm_not_zero(format->mbus_bpp, BITS_PER_BYTE) / BITS_PER_BYTE;
}
/*
* camss_format_find_code - Find a format code in an array
* @code: a pointer to media bus format codes array

View File

@ -55,6 +55,7 @@ struct camss_formats {
};
u8 camss_format_get_bpp(const struct camss_format_info *formats, unsigned int nformats, u32 code);
unsigned int camss_format_get_bpl_alignment(const struct camss_format_info *f);
u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned int index, u32 req_code);
int camss_format_find_format(u32 code, u32 pixelformat, const struct camss_format_info *formats,
unsigned int nformats);