Commit d5d51a82 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mauro Carvalho Chehab

[media] adv7180: Add media controller support

Add media controller support to the adv7180 driver by registering a media
entity instance for it as well as implementing pad ops for configuring the
format.

As there currently don't seem to be any users of the video ops format
operations those are removed as well in this patch.

Also set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so it is
possible to create a subdevice device node.

Since the driver now depends on VIDEO_V4L2_SUBDEV_API all drivers which
select the driver need to depend on that symbol as well.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-by: default avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent c18818e9
...@@ -177,7 +177,7 @@ comment "Video decoders" ...@@ -177,7 +177,7 @@ comment "Video decoders"
config VIDEO_ADV7180 config VIDEO_ADV7180
tristate "Analog Devices ADV7180 decoder" tristate "Analog Devices ADV7180 decoder"
depends on VIDEO_V4L2 && I2C depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
---help--- ---help---
Support for the Analog Devices ADV7180 video decoder. Support for the Analog Devices ADV7180 video decoder.
......
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
struct adv7180_state { struct adv7180_state {
struct v4l2_ctrl_handler ctrl_hdl; struct v4l2_ctrl_handler ctrl_hdl;
struct v4l2_subdev sd; struct v4l2_subdev sd;
struct media_pad pad;
struct mutex mutex; /* mutual excl. when accessing chip */ struct mutex mutex; /* mutual excl. when accessing chip */
int irq; int irq;
v4l2_std_id curr_norm; v4l2_std_id curr_norm;
...@@ -441,13 +442,14 @@ static void adv7180_exit_controls(struct adv7180_state *state) ...@@ -441,13 +442,14 @@ static void adv7180_exit_controls(struct adv7180_state *state)
v4l2_ctrl_handler_free(&state->ctrl_hdl); v4l2_ctrl_handler_free(&state->ctrl_hdl);
} }
static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, static int adv7180_enum_mbus_code(struct v4l2_subdev *sd,
u32 *code) struct v4l2_subdev_fh *fh,
struct v4l2_subdev_mbus_code_enum *code)
{ {
if (index > 0) if (code->index != 0)
return -EINVAL; return -EINVAL;
*code = MEDIA_BUS_FMT_YUYV8_2X8; code->code = MEDIA_BUS_FMT_YUYV8_2X8;
return 0; return 0;
} }
...@@ -466,6 +468,20 @@ static int adv7180_mbus_fmt(struct v4l2_subdev *sd, ...@@ -466,6 +468,20 @@ static int adv7180_mbus_fmt(struct v4l2_subdev *sd,
return 0; return 0;
} }
static int adv7180_get_pad_format(struct v4l2_subdev *sd,
struct v4l2_subdev_fh *fh,
struct v4l2_subdev_format *format)
{
return adv7180_mbus_fmt(sd, &format->format);
}
static int adv7180_set_pad_format(struct v4l2_subdev *sd,
struct v4l2_subdev_fh *fh,
struct v4l2_subdev_format *format)
{
return adv7180_mbus_fmt(sd, &format->format);
}
static int adv7180_g_mbus_config(struct v4l2_subdev *sd, static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg) struct v4l2_mbus_config *cfg)
{ {
...@@ -485,10 +501,6 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = { ...@@ -485,10 +501,6 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = {
.querystd = adv7180_querystd, .querystd = adv7180_querystd,
.g_input_status = adv7180_g_input_status, .g_input_status = adv7180_g_input_status,
.s_routing = adv7180_s_routing, .s_routing = adv7180_s_routing,
.enum_mbus_fmt = adv7180_enum_mbus_fmt,
.try_mbus_fmt = adv7180_mbus_fmt,
.g_mbus_fmt = adv7180_mbus_fmt,
.s_mbus_fmt = adv7180_mbus_fmt,
.g_mbus_config = adv7180_g_mbus_config, .g_mbus_config = adv7180_g_mbus_config,
}; };
...@@ -496,9 +508,16 @@ static const struct v4l2_subdev_core_ops adv7180_core_ops = { ...@@ -496,9 +508,16 @@ static const struct v4l2_subdev_core_ops adv7180_core_ops = {
.s_power = adv7180_s_power, .s_power = adv7180_s_power,
}; };
static const struct v4l2_subdev_pad_ops adv7180_pad_ops = {
.enum_mbus_code = adv7180_enum_mbus_code,
.set_fmt = adv7180_set_pad_format,
.get_fmt = adv7180_get_pad_format,
};
static const struct v4l2_subdev_ops adv7180_ops = { static const struct v4l2_subdev_ops adv7180_ops = {
.core = &adv7180_core_ops, .core = &adv7180_core_ops,
.video = &adv7180_video_ops, .video = &adv7180_video_ops,
.pad = &adv7180_pad_ops,
}; };
static irqreturn_t adv7180_irq(int irq, void *devid) static irqreturn_t adv7180_irq(int irq, void *devid)
...@@ -627,20 +646,28 @@ static int adv7180_probe(struct i2c_client *client, ...@@ -627,20 +646,28 @@ static int adv7180_probe(struct i2c_client *client,
state->input = 0; state->input = 0;
sd = &state->sd; sd = &state->sd;
v4l2_i2c_subdev_init(sd, client, &adv7180_ops); v4l2_i2c_subdev_init(sd, client, &adv7180_ops);
sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
ret = adv7180_init_controls(state); ret = adv7180_init_controls(state);
if (ret) if (ret)
goto err_unreg_subdev; goto err_unreg_subdev;
ret = init_device(state);
state->pad.flags = MEDIA_PAD_FL_SOURCE;
sd->entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
ret = media_entity_init(&sd->entity, 1, &state->pad, 0);
if (ret) if (ret)
goto err_free_ctrl; goto err_free_ctrl;
ret = init_device(state);
if (ret)
goto err_media_entity_cleanup;
if (state->irq) { if (state->irq) {
ret = request_threaded_irq(client->irq, NULL, adv7180_irq, ret = request_threaded_irq(client->irq, NULL, adv7180_irq,
IRQF_ONESHOT | IRQF_TRIGGER_FALLING, IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
KBUILD_MODNAME, state); KBUILD_MODNAME, state);
if (ret) if (ret)
goto err_free_ctrl; goto err_media_entity_cleanup;
} }
ret = v4l2_async_register_subdev(sd); ret = v4l2_async_register_subdev(sd);
...@@ -652,6 +679,8 @@ static int adv7180_probe(struct i2c_client *client, ...@@ -652,6 +679,8 @@ static int adv7180_probe(struct i2c_client *client,
err_free_irq: err_free_irq:
if (state->irq > 0) if (state->irq > 0)
free_irq(client->irq, state); free_irq(client->irq, state);
err_media_entity_cleanup:
media_entity_cleanup(&sd->entity);
err_free_ctrl: err_free_ctrl:
adv7180_exit_controls(state); adv7180_exit_controls(state);
err_unreg_subdev: err_unreg_subdev:
...@@ -669,6 +698,7 @@ static int adv7180_remove(struct i2c_client *client) ...@@ -669,6 +698,7 @@ static int adv7180_remove(struct i2c_client *client)
if (state->irq > 0) if (state->irq > 0)
free_irq(client->irq, state); free_irq(client->irq, state);
media_entity_cleanup(&sd->entity);
adv7180_exit_controls(state); adv7180_exit_controls(state);
mutex_destroy(&state->mutex); mutex_destroy(&state->mutex);
return 0; return 0;
......
...@@ -5,6 +5,7 @@ config STA2X11_VIP ...@@ -5,6 +5,7 @@ config STA2X11_VIP
select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
select VIDEOBUF2_DMA_CONTIG select VIDEOBUF2_DMA_CONTIG
depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS
depends on VIDEO_V4L2_SUBDEV_API
depends on I2C depends on I2C
help help
Say Y for support for STA2X11 VIP (Video Input Port) capture Say Y for support for STA2X11 VIP (Video Input Port) capture
......
...@@ -56,7 +56,7 @@ config VIDEO_VIU ...@@ -56,7 +56,7 @@ config VIDEO_VIU
config VIDEO_TIMBERDALE config VIDEO_TIMBERDALE
tristate "Support for timberdale Video In/LogiWIN" tristate "Support for timberdale Video In/LogiWIN"
depends on VIDEO_V4L2 && I2C depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST
select VIDEO_ADV7180 select VIDEO_ADV7180
select VIDEOBUF_DMA_CONTIG select VIDEOBUF_DMA_CONTIG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment