au0828: move dev->boards atribuition to happen earlier
PATCH v3 1/2 au0828: move dev->boards atribuition to happen earlier
The attribution of dev->boards occured too late, which would couse an OOPS in media controller registration.
--- drivers/media/usb/au0828/au0828-cards.c | 2 -- drivers/media/usb/au0828/au0828-core.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-cards.c +0 -2
@@ -195,8 +195,6 @@ void au0828_card_setup(struct au0828_dev *dev)dprintk (1 ,"%s()\n" , __func__); - dev->board = au0828_boards[dev->boardnr]; -if (dev->i2c_rc ==0 ) { dev->i2c_client.addr =0xa0 >>1 ;tveeprom_read (&dev->i2c_client, eeprom,sizeof (eeprom));
drivers/media/usb/au0828/au0828-core.c +2 -0
@@ -222,6 +222,8 @@ static int au0828_usb_probe(struct usb_interface *interface,mutex_init (&dev->dvb.lock); dev->usbdev = usbdev; dev->boardnr = id->driver_info; + dev->board = au0828_boards[dev->boardnr]; +#ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release;
Signature · 1 line
2.1.0
PATCH v3 2/2 au0828: Add support for media controller
Add support for analog and dvb tv using media controller.
--- drivers/media/dvb-frontends/au8522_decoder.c | 17 +++++ drivers/media/dvb-frontends/au8522_priv.h | 12 ++++ drivers/media/usb/au0828/au0828-core.c | 98 ++++++++++++++++++++++++++++ drivers/media/usb/au0828/au0828-dvb.c | 10 +++ drivers/media/usb/au0828/au0828-video.c | 83 +++++++++++++++++++++++ drivers/media/usb/au0828/au0828.h | 6 ++ 6 files changed, 226 insertions(+)
drivers/media/dvb-frontends/au8522_decoder.c +17 -0
@@ -731,6 +731,9 @@ static int au8522_probe(struct i2c_client *client,struct v4l2_subdev *sd;int instance;struct au8522_config *demod_config; +#ifdef CONFIG_MEDIA_CONTROLLER +int ret; +#endif /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter,
@@ -767,6 +770,20 @@ static int au8522_probe(struct i2c_client *client, sd = &state->sd;v4l2_i2c_subdev_init (sd, client, &au8522_ops); +#if defined(CONFIG_MEDIA_CONTROLLER ) + + state->pads[AU8522_PAD_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[AU8522_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[AU8522_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; + + ret =media_entity_init (&sd->entity,ARRAY_SIZE (state->pads), + state->pads,0 ); +if (ret <0 ) { +v4l_info (client,"failed to initialize media entity!\n" ); +return ret; + } +#endif hdl = &state->hdl;v4l2_ctrl_handler_init (hdl,4 );
drivers/media/dvb-frontends/au8522_priv.h +12 -0
@@ -39,6 +39,14 @@#define AU8522_DIGITAL_MODE 1#define AU8522_SUSPEND_MODE 2 +enum au8522_media_pads { +AU8522_PAD_INPUT , +AU8522_PAD_VID_OUT , +AU8522_PAD_VBI_OUT , + +AU8522_NUM_PADS +}; +struct au8522_state {struct i2c_client *c;struct i2c_adapter *i2c;
@@ -68,6 +76,10 @@ struct au8522_state {u32 id;u32 rev;struct v4l2_ctrl_handler hdl; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad pads[AU8522_NUM_PADS ]; +#endif };/* These are routines shared by both the VSB/QAM demodulator and the analog
drivers/media/usb/au0828/au0828-core.c +98 -0
135 lines not on this page · raw message
drivers/media/usb/au0828/au0828-dvb.c +10 -0
@@ -415,6 +415,11 @@ static int dvb_register(struct au0828_dev *dev) result); goto fail_adapter; } + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->adapter.mdev = dev->media_dev; +#endif + dvb->adapter.priv = dev;/* register frontend */
@@ -480,6 +485,11 @@ static int dvb_register(struct au0828_dev *dev) dvb->start_count =0 ; dvb->stop_count =0 ; + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +dvb_create_media_graph (&dvb->adapter); +#endif +return 0 ; fail_fe_conn:
drivers/media/usb/au0828/au0828-video.c +83 -0
101 lines not on this page · raw message
drivers/media/usb/au0828/au0828.h +6 -0
@@ -32,6 +32,7 @@#include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-fh.h> +#include <media/media-device.h> /* DVB */ #include "demux.h"
@@ -275,6 +276,11 @@ struct au0828_dev {/* Preallocated transfer digital transfer buffers */ char *dig_transfer_buffer[URB_COUNT ]; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *media_dev; +struct media_pad video_pad, vbi_pad; +#endif };
Signature · 1 line
2.1.0
Re: [PATCH 2/2 v3] au0828: Add support for media controller
Quoted 17 lines · Rafael Lourenço de Lima Chehab
Add support for analog and dvb tv using media controller.
Signed-off-by Rafael Lourenço de Lima Chehab <[email protected]>--- drivers/media/dvb-frontends/au8522_decoder.c | 17 +++++ drivers/media/dvb-frontends/au8522_priv.h | 12 ++++ drivers/media/usb/au0828/au0828-core.c | 98 ++++++++++++++++++++++++++++ drivers/media/usb/au0828/au0828-dvb.c | 10 +++ drivers/media/usb/au0828/au0828-video.c | 83 +++++++++++++++++++++++ drivers/media/usb/au0828/au0828.h | 6 ++ 6 files changed, 226 insertions(+)drivers/media/dvb-frontends/au8522_decoder.c +0
-0
drivers/media/dvb-frontends/au8522_decoder.c static int au8522_probe(struct i2c_client *client, · line 736
Quoted 6 lines
drivers/media/dvb-frontends/au8522_decoder.c +3
-0@@ -731,6 +731,9 @@ static int au8522_probe(struct i2c_client *client,struct v4l2_subdev *sd;int instance;struct au8522_config *demod_config; +#ifdef CONFIG_MEDIA_CONTROLLER +int ret; +#endif
You won't need to enclose the code in CONFIG_MEDIA_CONTROLLER blocks, once the patch I sent gets in. Please see below for patch.
Quoted 106 lines
drivers/media/dvb-frontends/au8522_decoder.c +14
-0/* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter,@@ -767,6 +770,20 @@ static int au8522_probe(struct i2c_client *client, sd = &state->sd;v4l2_i2c_subdev_init (sd, client, &au8522_ops); +#if defined(CONFIG_MEDIA_CONTROLLER ) + + state->pads[AU8522_PAD_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[AU8522_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[AU8522_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; + + ret =media_entity_init (&sd->entity,ARRAY_SIZE (state->pads), + state->pads,0 ); +if (ret <0 ) { +v4l_info (client,"failed to initialize media entity!\n" ); +return ret; + } +#endif hdl = &state->hdl;v4l2_ctrl_handler_init (hdl,4 );drivers/media/dvb-frontends/au8522_priv.h +12
-0@@ -39,6 +39,14 @@#define AU8522_DIGITAL_MODE 1#define AU8522_SUSPEND_MODE 2 +enum au8522_media_pads { +AU8522_PAD_INPUT , +AU8522_PAD_VID_OUT , +AU8522_PAD_VBI_OUT , + +AU8522_NUM_PADS +}; +struct au8522_state {struct i2c_client *c;struct i2c_adapter *i2c;@@ -68,6 +76,10 @@ struct au8522_state {u32 id;u32 rev;struct v4l2_ctrl_handler hdl; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad pads[AU8522_NUM_PADS ]; +#endif };/* These are routines shared by both the VSB/QAM demodulator and the analog drivers/media/usb/au0828/au0828-core.c +28
-0@@ -127,8 +127,22 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,return status; } +static void au0828_unregister_media_device (struct au0828_dev *dev) +{ + +#ifdef CONFIG_MEDIA_CONTROLLER +if (dev->media_dev) { +media_device_unregister (dev->media_dev); +kfree (dev->media_dev); + dev->media_dev =NULL ; + } +#endif +} +static void au0828_usb_release (struct au0828_dev *dev) { +au0828_unregister_media_device (dev); +/* I2C */ au0828_i2c_unregister (dev);@@ -161,6 +175,8 @@ static void au0828_usb_disconnect(struct usb_interface *interface)*/ dev->dev_state =DEV_DISCONNECTED ; +au0828_unregister_media_device (dev); +au0828_rc_unregister (dev);/* Digital TV */ au0828_dvb_unregister (dev);@@ -180,6 +196,81 @@ static void au0828_usb_disconnect(struct usb_interface *interface)au0828_usb_release (dev); } +static void au0828_media_device_register (struct au0828_dev *dev, +struct usb_device *udev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev; +int ret; + + mdev =kzalloc (sizeof (*mdev),GFP_KERNEL ); +if (!mdev) +return ; + + mdev->dev = &udev->dev;
drivers/media/usb/au0828/au0828-core.c static void au0828_usb_disconnect(struct usb_interface *interface) · line 220
Quoted 10 lines
drivers/media/usb/au0828/au0828-core.c +10
-0+ +if (!dev->board.name) +strlcpy (mdev->model,"unknown au0828" ,sizeof (mdev->model)); +else +strlcpy (mdev->model, dev->board.name,sizeof (mdev->model)); +if (udev->serial) +strlcpy (mdev->serial, udev->serial,sizeof (mdev->serial)); +strcpy (mdev->bus_info, udev->devpath); + mdev->hw_revision =le16_to_cpu (udev->descriptor.bcdDevice); + mdev->driver_version =LINUX_VERSION_CODE ;
Does this work? I saw checkpatch warnings come up for using LINUX_VERSION_CODE.
Quoted 249 lines
drivers/media/usb/au0828/au0828-core.c +60
-0+ + ret =media_device_register (mdev); +if (ret) { +pr_err ( +"Couldn't create a media device. Error: %d\n" , + ret); +kfree (mdev); +return ; + } + + dev->media_dev = mdev; +#endif +} + + +static void au0828_create_media_graph (struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev = dev->media_dev; +struct media_entity *entity; +struct media_entity *tuner =NULL , *decoder =NULL ; + +if (!mdev) +return ; + +media_device_for_each_entity (entity, mdev) { +switch (entity->type) { +case MEDIA_ENT_T_V4L2_SUBDEV_TUNER : + tuner = entity; +break ; +case MEDIA_ENT_T_V4L2_SUBDEV_DECODER : + decoder = entity; +break ; + } + } + +/* Analog setup, using tuner as a link */ + +if (!decoder) +return ; + +if (tuner) +media_entity_create_link (tuner,0 , decoder,0 , +MEDIA_LNK_FL_ENABLED ); +if (dev->vdev.entity.links) +media_entity_create_link (decoder,1 , &dev->vdev.entity,0 , +MEDIA_LNK_FL_ENABLED ); +if (dev->vbi_dev.entity.links) +media_entity_create_link (decoder,2 , &dev->vbi_dev.entity,0 , +MEDIA_LNK_FL_ENABLED ); +#endif +} +static int au0828_usb_probe (struct usb_interface *interface,const struct usb_device_id *id) {@@ -224,11 +315,16 @@ static int au0828_usb_probe(struct usb_interface *interface, dev->boardnr = id->driver_info; dev->board = au0828_boards[dev->boardnr]; +/* Register the media controller */ +au0828_media_device_register (dev, usbdev);#ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release;/* Create the v4l2_device */ +#ifdef CONFIG_MEDIA_CONTROLLER + dev->v4l2_dev.mdev = dev->media_dev; +#endif retval =v4l2_device_register (&interface->dev, &dev->v4l2_dev);if (retval) { pr_err("%s() v4l2_device_register failed\n",@@ -287,6 +383,8 @@ static int au0828_usb_probe(struct usb_interface *interface,mutex_unlock (&dev->lock); +au0828_create_media_graph (dev); +return retval; }drivers/media/usb/au0828/au0828-dvb.c +10
-0@@ -415,6 +415,11 @@ static int dvb_register(struct au0828_dev *dev) result); goto fail_adapter; } + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->adapter.mdev = dev->media_dev; +#endif + dvb->adapter.priv = dev;/* register frontend */ @@ -480,6 +485,11 @@ static int dvb_register(struct au0828_dev *dev) dvb->start_count =0 ; dvb->stop_count =0 ; + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +dvb_create_media_graph (&dvb->adapter); +#endif +return 0 ; fail_fe_conn:drivers/media/usb/au0828/au0828-video.c +83
-0@@ -637,6 +637,75 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)return rc; } +static int au0828_enable_analog_tuner (struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev = dev->media_dev; +struct media_entity *entity, *decoder =NULL , *source; +struct media_link *link, *found_link =NULL ; +int i, ret, active_links =0 ; + +if (!mdev) +return 0 ; + +/* +* This will find the tuner that is connected into the decoder. +* Technically, this is not 100% correct, as the device may be +* using an analog input instead of the tuner. However, as we can't +* do DVB streaming while the DMA engine is being used for V4L2, +* this should be enough for the actual needs. +*/ +media_device_for_each_entity (entity, mdev) { +if (entity->type ==MEDIA_ENT_T_V4L2_SUBDEV_DECODER ) { + decoder = entity; +break ; + } + } +if (!decoder) +return 0 ; + +for (i =0 ; i < decoder->num_links; i++) { + link = &decoder->links[i]; +if (link->sink->entity == decoder) { + found_link = link; +if (link->flags &MEDIA_LNK_FL_ENABLED ) + active_links++; +break ; + } + } + +if (active_links ==1 || !found_link) +return 0 ; + + source = found_link->source->entity; +for (i =0 ; i < source->num_links; i++) { +struct media_entity *sink; +int flags =0 ; + + link = &source->links[i]; + sink = link->sink->entity; + +if (sink == entity) + flags =MEDIA_LNK_FL_ENABLED ; + + ret =media_entity_setup_link (link, flags); +if (ret) { +pr_err ( +"Couldn't change link %s->%s to %s. Error %d\n" , + source->name, sink->name, + flags ?"enabled" :"disabled" , + ret); +return ret; + }else +au0828_isocdbg ( +"link %s->%s was %s\n" , + source->name, sink->name, + flags ?"ENABLED" :"disabled" ); + } +#endif +return 0 ; +} +static int queue_setup (struct vb2_queue *vq,const struct v4l2_format *fmt,unsigned int *nbuffers,unsigned int *nplanes,unsigned int sizes[],void *alloc_ctxs[])@@ -652,6 +721,8 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, *nplanes =1 ; sizes[0 ] = size; +au0828_enable_analog_tuner (dev); +return 0 ; }@@ -1821,6 +1892,18 @@ int au0828_analog_register(struct au0828_dev *dev, dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock;strcpy (dev->vbi_dev.name,"au0828a vbi" ); +#if defined(CONFIG_MEDIA_CONTROLLER ) + dev->video_pad.flags =MEDIA_PAD_FL_SINK ; + ret =media_entity_init (&dev->vdev.entity,1 , &dev->video_pad,0 ); +if (ret <0 ) +pr_err ("failed to initialize video media entity!\n" ); + + dev->vbi_pad.flags =MEDIA_PAD_FL_SINK ; + ret =media_entity_init (&dev->vbi_dev.entity,1 , &dev->vbi_pad,0 ); +if (ret <0 ) +pr_err ("failed to initialize vbi media entity!\n" ); +#endif +/* initialize videobuf2 stuff */ retval =au0828_vb2_setup (dev);if (retval !=0 ) {drivers/media/usb/au0828/au0828.h +6
-1@@ -32,6 +32,7 @@#include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-fh.h> +#include <media/media-device.h> /* DVB */ #include "demux.h" @@ -275,6 +276,11 @@ struct au0828_dev {/* Preallocated transfer digital transfer buffers */ char *dig_transfer_buffer[URB_COUNT ]; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *media_dev; +struct media_pad video_pad, vbi_pad; +#endif }; --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2 v3] au0828: Add support for media controller
Em Mon, 8 Jun 2015 21:08:32 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 29 lines
Quoted 17 lines · Rafael Lourenço de Lima Chehab
Add support for analog and dvb tv using media controller.
Signed-off-by Rafael Lourenço de Lima Chehab <[email protected]>--- drivers/media/dvb-frontends/au8522_decoder.c | 17 +++++ drivers/media/dvb-frontends/au8522_priv.h | 12 ++++ drivers/media/usb/au0828/au0828-core.c | 98 ++++++++++++++++++++++++++++ drivers/media/usb/au0828/au0828-dvb.c | 10 +++ drivers/media/usb/au0828/au0828-video.c | 83 +++++++++++++++++++++++ drivers/media/usb/au0828/au0828.h | 6 ++ 6 files changed, 226 insertions(+)drivers/media/dvb-frontends/au8522_decoder.c +0
-0drivers/media/dvb-frontends/au8522_decoder.c static int au8522_probe(struct i2c_client *client, · line 736
Quoted 6 lines
drivers/media/dvb-frontends/au8522_decoder.c +3
-0@@ -731,6 +731,9 @@ static int au8522_probe(struct i2c_client *client,struct v4l2_subdev *sd;int instance;struct au8522_config *demod_config; +#ifdef CONFIG_MEDIA_CONTROLLER +int ret; +#endif You won't need to enclose the code in
CONFIG_MEDIA_CONTROLLERblocks, once the patch I sent gets in. Please see below for patch.
Quoted 1 line
True. Well, let me apply both Rafael and your patches. Then, I'll do the cleanup.
Regards,
Mauro
Quoted 374 lines
Quoted 107 lines
drivers/media/dvb-frontends/au8522_decoder.c +14
-0/* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter,@@ -767,6 +770,20 @@ static int au8522_probe(struct i2c_client *client, sd = &state->sd;v4l2_i2c_subdev_init (sd, client, &au8522_ops); +#if defined(CONFIG_MEDIA_CONTROLLER ) + + state->pads[AU8522_PAD_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[AU8522_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[AU8522_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; + + ret =media_entity_init (&sd->entity,ARRAY_SIZE (state->pads), + state->pads,0 ); +if (ret <0 ) { +v4l_info (client,"failed to initialize media entity!\n" ); +return ret; + } +#endif hdl = &state->hdl;v4l2_ctrl_handler_init (hdl,4 );drivers/media/dvb-frontends/au8522_priv.h +12
-0@@ -39,6 +39,14 @@#define AU8522_DIGITAL_MODE 1#define AU8522_SUSPEND_MODE 2 +enum au8522_media_pads { +AU8522_PAD_INPUT , +AU8522_PAD_VID_OUT , +AU8522_PAD_VBI_OUT , + +AU8522_NUM_PADS +}; +struct au8522_state {struct i2c_client *c;struct i2c_adapter *i2c;@@ -68,6 +76,10 @@ struct au8522_state {u32 id;u32 rev;struct v4l2_ctrl_handler hdl; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad pads[AU8522_NUM_PADS ]; +#endif };/* These are routines shared by both the VSB/QAM demodulator and the analog drivers/media/usb/au0828/au0828-core.c +28
-0@@ -127,8 +127,22 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,return status; } +static void au0828_unregister_media_device (struct au0828_dev *dev) +{ + +#ifdef CONFIG_MEDIA_CONTROLLER +if (dev->media_dev) { +media_device_unregister (dev->media_dev); +kfree (dev->media_dev); + dev->media_dev =NULL ; + } +#endif +} +static void au0828_usb_release (struct au0828_dev *dev) { +au0828_unregister_media_device (dev); +/* I2C */ au0828_i2c_unregister (dev);@@ -161,6 +175,8 @@ static void au0828_usb_disconnect(struct usb_interface *interface)*/ dev->dev_state =DEV_DISCONNECTED ; +au0828_unregister_media_device (dev); +au0828_rc_unregister (dev);/* Digital TV */ au0828_dvb_unregister (dev);@@ -180,6 +196,81 @@ static void au0828_usb_disconnect(struct usb_interface *interface)au0828_usb_release (dev); } +static void au0828_media_device_register (struct au0828_dev *dev, +struct usb_device *udev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev; +int ret; + + mdev =kzalloc (sizeof (*mdev),GFP_KERNEL ); +if (!mdev) +return ; + + mdev->dev = &udev->dev;drivers/media/usb/au0828/au0828-core.c static void au0828_usb_disconnect(struct usb_interface *interface) · line 220
Quoted 10 lines
drivers/media/usb/au0828/au0828-core.c +10
-0+ +if (!dev->board.name) +strlcpy (mdev->model,"unknown au0828" ,sizeof (mdev->model)); +else +strlcpy (mdev->model, dev->board.name,sizeof (mdev->model)); +if (udev->serial) +strlcpy (mdev->serial, udev->serial,sizeof (mdev->serial)); +strcpy (mdev->bus_info, udev->devpath); + mdev->hw_revision =le16_to_cpu (udev->descriptor.bcdDevice); + mdev->driver_version =LINUX_VERSION_CODE ;Does this work? I saw checkpatch warnings come up for using
LINUX_VERSION_CODE.Quoted 245 lines
drivers/media/usb/au0828/au0828-core.c +60
-0+ + ret =media_device_register (mdev); +if (ret) { +pr_err ( +"Couldn't create a media device. Error: %d\n" , + ret); +kfree (mdev); +return ; + } + + dev->media_dev = mdev; +#endif +} + + +static void au0828_create_media_graph (struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev = dev->media_dev; +struct media_entity *entity; +struct media_entity *tuner =NULL , *decoder =NULL ; + +if (!mdev) +return ; + +media_device_for_each_entity (entity, mdev) { +switch (entity->type) { +case MEDIA_ENT_T_V4L2_SUBDEV_TUNER : + tuner = entity; +break ; +case MEDIA_ENT_T_V4L2_SUBDEV_DECODER : + decoder = entity; +break ; + } + } + +/* Analog setup, using tuner as a link */ + +if (!decoder) +return ; + +if (tuner) +media_entity_create_link (tuner,0 , decoder,0 , +MEDIA_LNK_FL_ENABLED ); +if (dev->vdev.entity.links) +media_entity_create_link (decoder,1 , &dev->vdev.entity,0 , +MEDIA_LNK_FL_ENABLED ); +if (dev->vbi_dev.entity.links) +media_entity_create_link (decoder,2 , &dev->vbi_dev.entity,0 , +MEDIA_LNK_FL_ENABLED ); +#endif +} +static int au0828_usb_probe (struct usb_interface *interface,const struct usb_device_id *id) {@@ -224,11 +315,16 @@ static int au0828_usb_probe(struct usb_interface *interface, dev->boardnr = id->driver_info; dev->board = au0828_boards[dev->boardnr]; +/* Register the media controller */ +au0828_media_device_register (dev, usbdev);#ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release;/* Create the v4l2_device */ +#ifdef CONFIG_MEDIA_CONTROLLER + dev->v4l2_dev.mdev = dev->media_dev; +#endif retval =v4l2_device_register (&interface->dev, &dev->v4l2_dev);if (retval) { pr_err("%s() v4l2_device_register failed\n",@@ -287,6 +383,8 @@ static int au0828_usb_probe(struct usb_interface *interface,mutex_unlock (&dev->lock); +au0828_create_media_graph (dev); +return retval; }drivers/media/usb/au0828/au0828-dvb.c +10
-0@@ -415,6 +415,11 @@ static int dvb_register(struct au0828_dev *dev) result); goto fail_adapter; } + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->adapter.mdev = dev->media_dev; +#endif + dvb->adapter.priv = dev;/* register frontend */ @@ -480,6 +485,11 @@ static int dvb_register(struct au0828_dev *dev) dvb->start_count =0 ; dvb->stop_count =0 ; + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +dvb_create_media_graph (&dvb->adapter); +#endif +return 0 ; fail_fe_conn:drivers/media/usb/au0828/au0828-video.c +83
-0@@ -637,6 +637,75 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)return rc; } +static int au0828_enable_analog_tuner (struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev = dev->media_dev; +struct media_entity *entity, *decoder =NULL , *source; +struct media_link *link, *found_link =NULL ; +int i, ret, active_links =0 ; + +if (!mdev) +return 0 ; + +/* +* This will find the tuner that is connected into the decoder. +* Technically, this is not 100% correct, as the device may be +* using an analog input instead of the tuner. However, as we can't +* do DVB streaming while the DMA engine is being used for V4L2, +* this should be enough for the actual needs. +*/ +media_device_for_each_entity (entity, mdev) { +if (entity->type ==MEDIA_ENT_T_V4L2_SUBDEV_DECODER ) { + decoder = entity; +break ; + } + } +if (!decoder) +return 0 ; + +for (i =0 ; i < decoder->num_links; i++) { + link = &decoder->links[i]; +if (link->sink->entity == decoder) { + found_link = link; +if (link->flags &MEDIA_LNK_FL_ENABLED ) + active_links++; +break ; + } + } + +if (active_links ==1 || !found_link) +return 0 ; + + source = found_link->source->entity; +for (i =0 ; i < source->num_links; i++) { +struct media_entity *sink; +int flags =0 ; + + link = &source->links[i]; + sink = link->sink->entity; + +if (sink == entity) + flags =MEDIA_LNK_FL_ENABLED ; + + ret =media_entity_setup_link (link, flags); +if (ret) { +pr_err ( +"Couldn't change link %s->%s to %s. Error %d\n" , + source->name, sink->name, + flags ?"enabled" :"disabled" , + ret); +return ret; + }else +au0828_isocdbg ( +"link %s->%s was %s\n" , + source->name, sink->name, + flags ?"ENABLED" :"disabled" ); + } +#endif +return 0 ; +} +static int queue_setup (struct vb2_queue *vq,const struct v4l2_format *fmt,unsigned int *nbuffers,unsigned int *nplanes,unsigned int sizes[],void *alloc_ctxs[])@@ -652,6 +721,8 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, *nplanes =1 ; sizes[0 ] = size; +au0828_enable_analog_tuner (dev); +return 0 ; }@@ -1821,6 +1892,18 @@ int au0828_analog_register(struct au0828_dev *dev, dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock;strcpy (dev->vbi_dev.name,"au0828a vbi" ); +#if defined(CONFIG_MEDIA_CONTROLLER ) + dev->video_pad.flags =MEDIA_PAD_FL_SINK ; + ret =media_entity_init (&dev->vdev.entity,1 , &dev->video_pad,0 ); +if (ret <0 ) +pr_err ("failed to initialize video media entity!\n" ); + + dev->vbi_pad.flags =MEDIA_PAD_FL_SINK ; + ret =media_entity_init (&dev->vbi_dev.entity,1 , &dev->vbi_pad,0 ); +if (ret <0 ) +pr_err ("failed to initialize vbi media entity!\n" ); +#endif +/* initialize videobuf2 stuff */ retval =au0828_vb2_setup (dev);if (retval !=0 ) {drivers/media/usb/au0828/au0828.h +6
-1@@ -32,6 +32,7 @@#include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-fh.h> +#include <media/media-device.h> /* DVB */ #include "demux.h" @@ -275,6 +276,11 @@ struct au0828_dev {/* Preallocated transfer digital transfer buffers */ char *dig_transfer_buffer[URB_COUNT ]; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *media_dev; +struct media_pad video_pad, vbi_pad; +#endif }; --2.1.0
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html