diff mbox

[media] v4l2-mediabus: Add helper functions

Message ID 1499415487-15785-1-git-send-email-todor.tomov@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Todor Tomov July 7, 2017, 8:18 a.m. UTC
Add helper functions for mbus to/from mplane pixel format conversion.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
---
 include/media/v4l2-mediabus.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Hans Verkuil July 7, 2017, 8:23 a.m. UTC | #1
On 07/07/2017 10:18 AM, Todor Tomov wrote:
> Add helper functions for mbus to/from mplane pixel format conversion.
> 
> Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
> ---
>   include/media/v4l2-mediabus.h | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)
> 
> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
> index 34cc99e..f97fd4a 100644
> --- a/include/media/v4l2-mediabus.h
> +++ b/include/media/v4l2-mediabus.h
> @@ -113,4 +113,30 @@ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
>   	mbus_fmt->code = code;
>   }
>   
> +static inline void v4l2_fill_pix_format_mplane(
> +				struct v4l2_pix_format_mplane *pix_fmt,
> +				const struct v4l2_mbus_framefmt *mbus_fmt)
> +{
> +	pix_fmt->width = mbus_fmt->width;
> +	pix_fmt->height = mbus_fmt->height;
> +	pix_fmt->field = mbus_fmt->field;
> +	pix_fmt->colorspace = mbus_fmt->colorspace;
> +	pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
> +	pix_fmt->quantization = mbus_fmt->quantization;
> +	pix_fmt->xfer_func = mbus_fmt->xfer_func;
> +}
> +
> +static inline void v4l2_fill_mbus_format_mplane(
> +				struct v4l2_mbus_framefmt *mbus_fmt,
> +				const struct v4l2_pix_format_mplane *pix_fmt)
> +{
> +	mbus_fmt->width = pix_fmt->width;
> +	mbus_fmt->height = pix_fmt->height;
> +	mbus_fmt->field = pix_fmt->field;
> +	mbus_fmt->colorspace = pix_fmt->colorspace;
> +	mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
> +	mbus_fmt->quantization = pix_fmt->quantization;
> +	mbus_fmt->xfer_func = pix_fmt->xfer_func;
> +}
> +
>   #endif
> 

Looks good. But can you rename pix_fmt to pix_mp_fmt? It makes it a bit
clearer that we're operating on the pix_mp member of struct v4l2_format.

Regards,

	Hans
Todor Tomov July 7, 2017, 8:38 a.m. UTC | #2
On 07/07/2017 11:23 AM, Hans Verkuil wrote:
> On 07/07/2017 10:18 AM, Todor Tomov wrote:
>> Add helper functions for mbus to/from mplane pixel format conversion.
>>
>> Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
>> ---
>>   include/media/v4l2-mediabus.h | 26 ++++++++++++++++++++++++++
>>   1 file changed, 26 insertions(+)
>>
>> diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
>> index 34cc99e..f97fd4a 100644
>> --- a/include/media/v4l2-mediabus.h
>> +++ b/include/media/v4l2-mediabus.h
>> @@ -113,4 +113,30 @@ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
>>       mbus_fmt->code = code;
>>   }
>>   +static inline void v4l2_fill_pix_format_mplane(
>> +                struct v4l2_pix_format_mplane *pix_fmt,
>> +                const struct v4l2_mbus_framefmt *mbus_fmt)
>> +{
>> +    pix_fmt->width = mbus_fmt->width;
>> +    pix_fmt->height = mbus_fmt->height;
>> +    pix_fmt->field = mbus_fmt->field;
>> +    pix_fmt->colorspace = mbus_fmt->colorspace;
>> +    pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
>> +    pix_fmt->quantization = mbus_fmt->quantization;
>> +    pix_fmt->xfer_func = mbus_fmt->xfer_func;
>> +}
>> +
>> +static inline void v4l2_fill_mbus_format_mplane(
>> +                struct v4l2_mbus_framefmt *mbus_fmt,
>> +                const struct v4l2_pix_format_mplane *pix_fmt)
>> +{
>> +    mbus_fmt->width = pix_fmt->width;
>> +    mbus_fmt->height = pix_fmt->height;
>> +    mbus_fmt->field = pix_fmt->field;
>> +    mbus_fmt->colorspace = pix_fmt->colorspace;
>> +    mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
>> +    mbus_fmt->quantization = pix_fmt->quantization;
>> +    mbus_fmt->xfer_func = pix_fmt->xfer_func;
>> +}
>> +
>>   #endif
>>
> 
> Looks good. But can you rename pix_fmt to pix_mp_fmt? It makes it a bit
> clearer that we're operating on the pix_mp member of struct v4l2_format.

Ok, I'll rename and resend.

> 
> Regards,
> 
>     Hans
diff mbox

Patch

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 34cc99e..f97fd4a 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -113,4 +113,30 @@  static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
 	mbus_fmt->code = code;
 }
 
+static inline void v4l2_fill_pix_format_mplane(
+				struct v4l2_pix_format_mplane *pix_fmt,
+				const struct v4l2_mbus_framefmt *mbus_fmt)
+{
+	pix_fmt->width = mbus_fmt->width;
+	pix_fmt->height = mbus_fmt->height;
+	pix_fmt->field = mbus_fmt->field;
+	pix_fmt->colorspace = mbus_fmt->colorspace;
+	pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
+	pix_fmt->quantization = mbus_fmt->quantization;
+	pix_fmt->xfer_func = mbus_fmt->xfer_func;
+}
+
+static inline void v4l2_fill_mbus_format_mplane(
+				struct v4l2_mbus_framefmt *mbus_fmt,
+				const struct v4l2_pix_format_mplane *pix_fmt)
+{
+	mbus_fmt->width = pix_fmt->width;
+	mbus_fmt->height = pix_fmt->height;
+	mbus_fmt->field = pix_fmt->field;
+	mbus_fmt->colorspace = pix_fmt->colorspace;
+	mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
+	mbus_fmt->quantization = pix_fmt->quantization;
+	mbus_fmt->xfer_func = pix_fmt->xfer_func;
+}
+
 #endif