On 7/24/19 3:22 PM, Philipp Zabel wrote:
> On Wed, 2019-07-24 at 13:05 +0200, Hans Verkuil wrote:
>> If a driver sets a FMT flag in the enum_fmt op, then that will be
>> ignored since v4l_fill_fmtdesc() overwrites it again.
>>
>> v4l_fill_fmtdesc() should OR its flag, not overwrite it.
>>
>> Signed-off-by: Hans Verkuil <[email protected]>
>> ---
>> drivers/media/v4l2-core/v4l2-ioctl.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>> b/drivers/media/v4l2-core/v4l2-ioctl.c
>> index 80efc581e3f9..911a20f915c5 100644
>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>> @@ -1390,7 +1390,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
>>
>> if (descr)
>> WARN_ON(strscpy(fmt->description, descr, sz) < 0);
>> - fmt->flags = flags;
>> + fmt->flags |= flags;
>> }
>>
>> static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
>
> If the enum_fmt op does not write fmt->flags, will it not contain the
> value provided by userspace at this point? I think p->flags must be
> cleared in v4l2_enum_fmt() with this change, before the enum_fmt op is
> called.
All fields after 'type' in struct v4l2_fmtdesc are cleared by the core:
search for INFO_FL_CLEAR(v4l2_fmtdesc, type) in v4l2-ioctl.c.
So 'flags' is already zeroed when this function is called.
Regards,
Hans