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_INTEL #208

Open
wants to merge 2 commits 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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export CONFIG_VIDEO_OV01A10 = m
export CONFIG_VIDEO_OV02C10 = m
export CONFIG_VIDEO_OV02E10 = m
export CONFIG_VIDEO_OV2740 = m
export CONFIG_VIDEO_OV13858_INTEL = n
export CONFIG_VIDEO_HM2170 = m
export CONFIG_VIDEO_HM2172 = m
export CONFIG_VIDEO_HI556 = m
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ Three ways are available:
To compile this driver as a module, choose M here: the
module will be called ov02e10.

config VIDEO_OV13858_INTEL
tristate "OmniVision OV13858 sensor support"
depends on VIDEO_DEV && I2C
depends on ACPI || COMPILE_TEST
select MEDIA_CONTROLLER
select VIDEO_V4L2_SUBDEV_API
select V4L2_FWNODE
help
This is a Video4Linux2 sensor driver for the OmniVision
OV13858 camera.

To compile this driver as a module, choose M here: the
module will be called ov13858_intel.

config VIDEO_HM2170
tristate "Himax HM2170 sensor support"
depends on VIDEO_DEV && I2C
Expand Down Expand Up @@ -166,6 +180,7 @@ Three ways are available:
obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o
obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o
obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
obj-$(CONFIG_VIDEO_OV13858_INTEL) += ov13858_intel.o
obj-$(CONFIG_VIDEO_HM2170) += hm2170.o
obj-$(CONFIG_VIDEO_HM2170) += hm2172.o
```
Expand All @@ -187,6 +202,7 @@ Three ways are available:
CONFIG_VIDEO_HM11B1=m
CONFIG_VIDEO_OV02C10=m
CONFIG_VIDEO_OV02E10=m
CONFIG_VIDEO_OV13858_INTEL = m
CONFIG_VIDEO_HM2170=m
CONFIG_VIDEO_HM2172=m
# Set this only if you use only 1 camera and don't want too many device nodes in media-ctl
Expand Down
4 changes: 4 additions & 0 deletions dkms.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ BUILT_MODULE_NAME[19]="hm2172"
BUILT_MODULE_LOCATION[19]="drivers/media/i2c"
DEST_MODULE_LOCATION[19]="/updates"

BUILT_MODULE_NAME[19]="ov13858_intel"
BUILT_MODULE_LOCATION[19]="drivers/media/i2c"
DEST_MODULE_LOCATION[19]="/updates"

BUILT_MODULE_NAME[20]="hi556"
BUILT_MODULE_LOCATION[20]="drivers/media/i2c"
DEST_MODULE_LOCATION[20]="/updates"
Expand Down
1 change: 1 addition & 0 deletions drivers/media/i2c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o
obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o
obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
obj-$(CONFIG_VIDEO_OV2740) += ov2740.o
obj-$(CONFIG_VIDEO_OV13858_INTEL) += ov13858_intel.o
obj-$(CONFIG_VIDEO_HM2170) += hm2170.o
obj-$(CONFIG_VIDEO_HM2170) += hm2172.o
obj-$(CONFIG_VIDEO_HI556) += hi556.o
Expand Down
48 changes: 46 additions & 2 deletions 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 Expand Up @@ -2071,4 +2115,4 @@ MODULE_AUTHOR("Kan, Chris <[email protected]>");
MODULE_AUTHOR("Rapolu, Chiranjeevi <[email protected]>");
MODULE_AUTHOR("Yang, Hyungwoo <[email protected]>");
MODULE_DESCRIPTION("Omnivision ov13858 sensor driver");
MODULE_LICENSE("GPL v2");
MODULE_LICENSE("GPL v2");
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 @@ -57,6 +57,8 @@ static const struct cio2_sensor_config cio2_supported_sensors[] = {
CIO2_SENSOR_CONFIG("OVTI08A1", 0, 0),
/* Omnivision ov08x40 */
CIO2_SENSOR_CONFIG("OVTI08F4", 1, 400000000),
/* Omnivision ov13858 */
CIO2_SENSOR_CONFIG("OVTID858", 0, 0),
};

static const struct cio2_property_names prop_names = {
Expand Down