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

Fix build for OV13858 #99

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: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export CONFIG_VIDEO_OV02C10 = m
export CONFIG_VIDEO_OV2740 = m
export CONFIG_VIDEO_HM2170 = m
export CONFIG_VIDEO_HI556 = m
export CONFIG_VIDEO_OV13858_INTEL = m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For"Build with kernel source tree" case, we need to add a Kconfig option for VIDEO_OV13858_INTEL, then in .config set it as "m" and set original VIDEO_OV13858 to "n" or "not set". Please follow other sensors part and update the README.md.


# export CONFIG_POWER_CTRL_LOGIC = m
obj-y += drivers/media/i2c/

Expand Down
1 change: 1 addition & 0 deletions drivers/media/i2c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_OV2740) += ov2740.o
obj-$(CONFIG_VIDEO_HM2170) += hm2170.o
obj-$(CONFIG_VIDEO_HI556) += hi556.o
obj-$(CONFIG_POWER_CTRL_LOGIC) += power_ctrl_logic.o
obj-$(CONFIG_VIDEO_OV13858_INTEL) += ov13858_intel.o
46 changes: 45 additions & 1 deletion drivers/media/i2c/ov13858_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/acpi.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/gpio/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/version.h>
#include <media/v4l2-ctrls.h>
Expand Down Expand Up @@ -1380,9 +1381,15 @@ static int ov13858_write_reg_list(struct ov13858 *ov13858,
static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
struct ov13858 *ov13858 = to_ov13858(sd);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd,
fh->pad,
0);
#else
struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd,
fh->state,
0);
#endif

mutex_lock(&ov13858->mutex);

Expand Down Expand Up @@ -1516,7 +1523,11 @@ static const struct v4l2_ctrl_ops ov13858_ctrl_ops = {
};

static int ov13858_enum_mbus_code(struct v4l2_subdev *sd,
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
struct v4l2_subdev_pad_config *cfg,
#else
struct v4l2_subdev_state *sd_state,
#endif
struct v4l2_subdev_mbus_code_enum *code)
{
/* Only one bayer order(GRBG) is supported */
Expand All @@ -1529,7 +1540,11 @@ static int ov13858_enum_mbus_code(struct v4l2_subdev *sd,
}

static int ov13858_enum_frame_size(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
struct v4l2_subdev_pad_config *cfg,
#else
struct v4l2_subdev_state *sd_state,
#endif
struct v4l2_subdev_frame_size_enum *fse)
{
if (fse->index >= ARRAY_SIZE(supported_modes))
Expand All @@ -1556,14 +1571,23 @@ static void ov13858_update_pad_format(const struct ov13858_mode *mode,
}

static int ov13858_do_get_pad_format(struct ov13858 *ov13858,
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
struct v4l2_subdev_pad_config *cfg,
#else
struct v4l2_subdev_state *sd_state,
#endif
struct v4l2_subdev_format *fmt)
{
struct v4l2_mbus_framefmt *framefmt;
struct v4l2_subdev *sd = &ov13858->sd;

if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
#else
framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
#endif

fmt->format = *framefmt;
} else {
ov13858_update_pad_format(ov13858->cur_mode, fmt);
Expand All @@ -1573,22 +1597,34 @@ static int ov13858_do_get_pad_format(struct ov13858 *ov13858,
}

static int ov13858_get_pad_format(struct v4l2_subdev *sd,
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
struct v4l2_subdev_pad_config *cfg,
#else
struct v4l2_subdev_state *sd_state,
#endif
struct v4l2_subdev_format *fmt)
{
struct ov13858 *ov13858 = to_ov13858(sd);
int ret;

mutex_lock(&ov13858->mutex);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
ret = ov13858_do_get_pad_format(ov13858, cfg, fmt);
#else
ret = ov13858_do_get_pad_format(ov13858, sd_state, fmt);
#endif
mutex_unlock(&ov13858->mutex);

return ret;
}

static int
ov13858_set_pad_format(struct v4l2_subdev *sd,
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
struct v4l2_subdev_pad_config *cfg,
#else
struct v4l2_subdev_state *sd_state,
#endif
struct v4l2_subdev_format *fmt)
{
struct ov13858 *ov13858 = to_ov13858(sd);
Expand All @@ -1612,7 +1648,11 @@ ov13858_set_pad_format(struct v4l2_subdev *sd,
fmt->format.width, fmt->format.height);
ov13858_update_pad_format(mode, fmt);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
#else
framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
#endif
*framefmt = fmt->format;
} else {
ov13858->cur_mode = mode;
Expand Down Expand Up @@ -1990,7 +2030,11 @@ static int ov13858_probe(struct i2c_client *client,
goto error_handler_free;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0)
ret = v4l2_async_register_subdev_sensor_common(&ov13858->sd);
#else
ret = v4l2_async_register_subdev_sensor(&ov13858->sd);
#endif
if (ret < 0)
goto error_media_entity;

Expand Down
2 changes: 2 additions & 0 deletions drivers/media/pci/intel/cio2-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static const struct cio2_sensor_config cio2_supported_sensors[] = {
/* Omnivision ov13b10 */
CIO2_SENSOR_CONFIG("OVTIDB10", 0, 0),
CIO2_SENSOR_CONFIG("OVTI13B1", 0, 0),
/* Omnivision ov13858 */
CIO2_SENSOR_CONFIG("OVTID858", 0, 0),
};

static const struct cio2_property_names prop_names = {
Expand Down