Skip to content

Commit fc2b95e

Browse files
mchehabgregkh
authored andcommitted
media: atomisp: fix enum formats logic
[ Upstream commit fae46cb ] Changeset 374d62e ("media: v4l2-subdev: Verify v4l2_subdev_call() pad config argument") added an extra verification for a pads parameter for enum mbus format code. Such change broke atomisp, because now the V4L2 core refuses to enum MBUS formats if the state is empty. So, add .which field in order to select the active formats, in order to make it work again. While here, improve error messages. Fixes: 374d62e ("media: v4l2-subdev: Verify v4l2_subdev_call() pad config argument") Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6e53532 commit fc2b95e

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎drivers/staging/media/atomisp/pci/atomisp_ioctl.c‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,10 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh,
773773
struct video_device *vdev = video_devdata(file);
774774
struct atomisp_device *isp = video_get_drvdata(vdev);
775775
struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
776-
struct v4l2_subdev_mbus_code_enum code = { 0 };
776+
struct v4l2_subdev_mbus_code_enum code = {
777+
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
778+
};
779+
struct v4l2_subdev *camera;
777780
unsigned int i, fi = 0;
778781
int rval;
779782

@@ -783,14 +786,20 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh,
783786
return -EINVAL;
784787
}
785788

789+
camera = isp->inputs[asd->input_curr].camera;
790+
if(!camera) {
791+
dev_err(isp->dev, "%s(): camera is NULL, device is %s\n",
792+
__func__, vdev->name);
793+
return -EINVAL;
794+
}
795+
786796
rt_mutex_lock(&isp->mutex);
787-
rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad,
788-
enum_mbus_code, NULL, &code);
797+
798+
rval = v4l2_subdev_call(camera, pad, enum_mbus_code, NULL, &code);
789799
if (rval == -ENOIOCTLCMD) {
790800
dev_warn(isp->dev,
791-
"enum_mbus_code pad op not supported. Please fix your sensor driver!\n");
792-
// rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
793-
// video, enum_mbus_fmt, 0, &code.code);
801+
"enum_mbus_code pad op not supported by %s. Please fix your sensor driver!\n",
802+
camera->name);
794803
}
795804
rt_mutex_unlock(&isp->mutex);
796805

@@ -820,6 +829,8 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh,
820829
f->pixelformat = format->pixelformat;
821830
return 0;
822831
}
832+
dev_err(isp->dev, "%s(): format for code %x not found.\n",
833+
__func__, code.code);
823834

824835
return -EINVAL;
825836
}

0 commit comments

Comments
 (0)