Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gc5035: Fix compilation with kernels >= 6.8 #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export CONFIG_VIDEO_OV02E10 = m
export CONFIG_VIDEO_HM2170 = m
export CONFIG_VIDEO_HM2172 = m
export CONFIG_VIDEO_HI556 = m
export CONFIG_VIDEO_GC5035 = m

ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true)
export CONFIG_VIDEO_OV2740 = m
export CONFIG_VIDEO_GC5035 = m
endif
obj-y += drivers/media/i2c/

Expand Down
19 changes: 19 additions & 0 deletions drivers/media/i2c/gc5035.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,11 @@ static int gc5035_set_fmt(struct v4l2_subdev *sd,

mutex_lock(&gc5035->mutex);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
*v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format;
#else
*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
#endif
} else {
gc5035->cur_mode = mode;
h_blank = mode->hts_def - mode->width;
Expand All @@ -1522,7 +1526,11 @@ static int gc5035_get_fmt(struct v4l2_subdev *sd,

mutex_lock(&gc5035->mutex);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
fmt->format = *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
#else
fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad);
#endif
} else {
fmt->format.width = mode->width;
fmt->format.height = mode->height;
Expand Down Expand Up @@ -1714,7 +1722,9 @@ static const struct v4l2_subdev_video_ops gc5035_video_ops = {
};

static const struct v4l2_subdev_pad_ops gc5035_pad_ops = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
.init_cfg = gc5035_entity_init_cfg,
#endif
.enum_mbus_code = gc5035_enum_mbus_code,
.enum_frame_size = gc5035_enum_frame_sizes,
.get_fmt = gc5035_get_fmt,
Expand All @@ -1730,6 +1740,12 @@ static const struct media_entity_operations gc5035_subdev_entity_ops = {
.link_validate = v4l2_subdev_link_validate,
};

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
static const struct v4l2_subdev_internal_ops gc5035_internal_ops = {
.init_state = gc5035_entity_init_cfg,
};
#endif

static int gc5035_set_exposure(struct gc5035 *gc5035, u32 val)
{
u32 caltime = 0;
Expand Down Expand Up @@ -2091,6 +2107,9 @@ static int gc5035_probe(struct i2c_client *client)
mutex_init(&gc5035->mutex);
sd = &gc5035->subdev;
v4l2_i2c_subdev_init(sd, client, &gc5035_subdev_ops);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
sd->internal_ops = &gc5035_internal_ops;
#endif
ret = gc5035_initialize_controls(gc5035);
if (ret) {
dev_err_probe(dev, ret, "Failed to initialize controls\n");
Expand Down