Commit 7b606ffd authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] au0828: move V4L2-specific code to au0828-core.c

Instead of having lots of #ifdefs inside au0828-core due to
V4L2, move the dependencies to au0828-video.c. That allows
removing all those ifdefs, as au0828-video is only compiled if
CONFIG_VIDEO_AU0828_V4L2.

This fixes the following warnings reported by Kbuild test
with a random config with au0828 enabled, but V4L2 is disabled.

All warnings (new ones prefixed by >>):

   drivers/media/usb/au0828/au0828-core.c: In function 'au0828_usb_probe':
>> drivers/media/usb/au0828/au0828-core.c:463:1: warning: label 'done' defined but not used [-Wunused-label]
    done:
    ^
   drivers/media/usb/au0828/au0828-core.c: At top level:
   drivers/media/usb/au0828/au0828-core.c:250:12: warning: 'au0828_create_media_graph' defined but not used [-Wunused-function]
    static int au0828_create_media_graph(struct au0828_dev *dev)
               ^

Tested with a WinTV HVR 950Q (USB ID: 2040:7200)
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 82e92f4c
...@@ -143,7 +143,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev) ...@@ -143,7 +143,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
#endif #endif
} }
static void au0828_usb_release(struct au0828_dev *dev) void au0828_usb_release(struct au0828_dev *dev)
{ {
au0828_unregister_media_device(dev); au0828_unregister_media_device(dev);
...@@ -153,33 +153,6 @@ static void au0828_usb_release(struct au0828_dev *dev) ...@@ -153,33 +153,6 @@ static void au0828_usb_release(struct au0828_dev *dev)
kfree(dev); kfree(dev);
} }
#ifdef CONFIG_VIDEO_AU0828_V4L2
static void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
{
#ifdef CONFIG_MEDIA_CONTROLLER
int i;
for (i = 0; i < AU0828_MAX_INPUT; i++) {
if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
return;
media_device_unregister_entity(&dev->input_ent[i]);
}
#endif
}
static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
{
struct au0828_dev *dev =
container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
v4l2_device_unregister(&dev->v4l2_dev);
au0828_usb_v4l2_media_release(dev);
au0828_usb_release(dev);
}
#endif
static void au0828_usb_disconnect(struct usb_interface *interface) static void au0828_usb_disconnect(struct usb_interface *interface)
{ {
struct au0828_dev *dev = usb_get_intfdata(interface); struct au0828_dev *dev = usb_get_intfdata(interface);
...@@ -202,18 +175,13 @@ static void au0828_usb_disconnect(struct usb_interface *interface) ...@@ -202,18 +175,13 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
mutex_lock(&dev->mutex); mutex_lock(&dev->mutex);
dev->usbdev = NULL; dev->usbdev = NULL;
mutex_unlock(&dev->mutex); mutex_unlock(&dev->mutex);
#ifdef CONFIG_VIDEO_AU0828_V4L2 if (au0828_analog_unregister(dev)) {
if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
au0828_analog_unregister(dev);
v4l2_device_disconnect(&dev->v4l2_dev);
v4l2_device_put(&dev->v4l2_dev);
/* /*
* No need to call au0828_usb_release() if V4L2 is enabled, * No need to call au0828_usb_release() if V4L2 is enabled,
* as this is already called via au0828_usb_v4l2_release() * as this is already called via au0828_usb_v4l2_release()
*/ */
return; return;
} }
#endif
au0828_usb_release(dev); au0828_usb_release(dev);
} }
...@@ -247,83 +215,6 @@ static int au0828_media_device_init(struct au0828_dev *dev, ...@@ -247,83 +215,6 @@ static int au0828_media_device_init(struct au0828_dev *dev,
} }
static int 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;
int i, ret;
if (!mdev)
return 0;
media_device_for_each_entity(entity, mdev) {
switch (entity->function) {
case MEDIA_ENT_F_TUNER:
tuner = entity;
break;
case MEDIA_ENT_F_ATV_DECODER:
decoder = entity;
break;
}
}
/* Analog setup, using tuner as a link */
/* Something bad happened! */
if (!decoder)
return -EINVAL;
if (tuner) {
ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
decoder, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
}
ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
for (i = 0; i < AU0828_MAX_INPUT; i++) {
struct media_entity *ent = &dev->input_ent[i];
if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
break;
switch (AUVI_INPUT(i).type) {
case AU0828_VMUX_CABLE:
case AU0828_VMUX_TELEVISION:
case AU0828_VMUX_DVB:
if (!tuner)
break;
ret = media_create_pad_link(ent, 0, tuner,
TUNER_PAD_RF_INPUT,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
break;
case AU0828_VMUX_COMPOSITE:
case AU0828_VMUX_SVIDEO:
default: /* AU0828_VMUX_DEBUG */
/* FIXME: fix the decoder PAD */
ret = media_create_pad_link(ent, 0, decoder, 0, 0);
if (ret)
return ret;
break;
}
}
#endif
return 0;
}
static int au0828_usb_probe(struct usb_interface *interface, static int au0828_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
...@@ -378,32 +269,13 @@ static int au0828_usb_probe(struct usb_interface *interface, ...@@ -378,32 +269,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
return retval; return retval;
} }
#ifdef CONFIG_VIDEO_AU0828_V4L2 retval = au0828_v4l2_device_register(interface, dev);
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) { if (retval) {
pr_err("%s() v4l2_device_register failed\n", au0828_usb_v4l2_media_release(dev);
__func__);
mutex_unlock(&dev->lock);
kfree(dev);
return retval;
}
/* This control handler will inherit the controls from au8522 */
retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
if (retval) {
pr_err("%s() v4l2_ctrl_handler_init failed\n",
__func__);
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
kfree(dev); kfree(dev);
return retval; return retval;
} }
dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
#endif
/* Power Up the bridge */ /* Power Up the bridge */
au0828_write(dev, REG_600, 1 << 4); au0828_write(dev, REG_600, 1 << 4);
...@@ -417,9 +289,7 @@ static int au0828_usb_probe(struct usb_interface *interface, ...@@ -417,9 +289,7 @@ static int au0828_usb_probe(struct usb_interface *interface,
/* Setup */ /* Setup */
au0828_card_setup(dev); au0828_card_setup(dev);
#ifdef CONFIG_VIDEO_AU0828_V4L2
/* Analog TV */ /* Analog TV */
if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
retval = au0828_analog_register(dev, interface); retval = au0828_analog_register(dev, interface);
if (retval) { if (retval) {
pr_err("%s() au0282_dev_register failed to register on V4L2\n", pr_err("%s() au0282_dev_register failed to register on V4L2\n",
...@@ -427,15 +297,6 @@ static int au0828_usb_probe(struct usb_interface *interface, ...@@ -427,15 +297,6 @@ static int au0828_usb_probe(struct usb_interface *interface,
goto done; goto done;
} }
retval = au0828_create_media_graph(dev);
if (retval) {
pr_err("%s() au0282_dev_register failed to create graph\n",
__func__);
goto done;
}
}
#endif
/* Digital TV */ /* Digital TV */
retval = au0828_dvb_register(dev); retval = au0828_dvb_register(dev);
if (retval) if (retval)
......
...@@ -638,6 +638,144 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb) ...@@ -638,6 +638,144 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
return rc; return rc;
} }
void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
{
#ifdef CONFIG_MEDIA_CONTROLLER
int i;
for (i = 0; i < AU0828_MAX_INPUT; i++) {
if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
return;
media_device_unregister_entity(&dev->input_ent[i]);
}
#endif
}
static int 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;
int i, ret;
if (!mdev)
return 0;
media_device_for_each_entity(entity, mdev) {
switch (entity->function) {
case MEDIA_ENT_F_TUNER:
tuner = entity;
break;
case MEDIA_ENT_F_ATV_DECODER:
decoder = entity;
break;
}
}
/* Analog setup, using tuner as a link */
/* Something bad happened! */
if (!decoder)
return -EINVAL;
if (tuner) {
ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
decoder, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
}
ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
for (i = 0; i < AU0828_MAX_INPUT; i++) {
struct media_entity *ent = &dev->input_ent[i];
if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
break;
switch (AUVI_INPUT(i).type) {
case AU0828_VMUX_CABLE:
case AU0828_VMUX_TELEVISION:
case AU0828_VMUX_DVB:
if (!tuner)
break;
ret = media_create_pad_link(ent, 0, tuner,
TUNER_PAD_RF_INPUT,
MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
break;
case AU0828_VMUX_COMPOSITE:
case AU0828_VMUX_SVIDEO:
default: /* AU0828_VMUX_DEBUG */
/* FIXME: fix the decoder PAD */
ret = media_create_pad_link(ent, 0, decoder, 0, 0);
if (ret)
return ret;
break;
}
}
#endif
return 0;
}
static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
{
struct au0828_dev *dev =
container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
v4l2_device_unregister(&dev->v4l2_dev);
au0828_usb_v4l2_media_release(dev);
au0828_usb_release(dev);
}
int au0828_v4l2_device_register(struct usb_interface *interface,
struct au0828_dev *dev)
{
int retval;
if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
return 0;
/* 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",
__func__);
mutex_unlock(&dev->lock);
kfree(dev);
return retval;
}
dev->v4l2_dev.release = au0828_usb_v4l2_release;
/* This control handler will inherit the controls from au8522 */
retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
if (retval) {
pr_err("%s() v4l2_ctrl_handler_init failed\n",
__func__);
mutex_unlock(&dev->lock);
kfree(dev);
return retval;
}
dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
return 0;
}
static int au0828_enable_analog_tuner(struct au0828_dev *dev) static int au0828_enable_analog_tuner(struct au0828_dev *dev)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
...@@ -949,13 +1087,23 @@ static struct vb2_ops au0828_video_qops = { ...@@ -949,13 +1087,23 @@ static struct vb2_ops au0828_video_qops = {
* au0828_analog_unregister * au0828_analog_unregister
* unregister v4l2 devices * unregister v4l2 devices
*/ */
void au0828_analog_unregister(struct au0828_dev *dev) int au0828_analog_unregister(struct au0828_dev *dev)
{ {
dprintk(1, "au0828_analog_unregister called\n"); dprintk(1, "au0828_analog_unregister called\n");
/* No analog TV */
if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
return 0;
mutex_lock(&au0828_sysfs_lock); mutex_lock(&au0828_sysfs_lock);
video_unregister_device(&dev->vdev); video_unregister_device(&dev->vdev);
video_unregister_device(&dev->vbi_dev); video_unregister_device(&dev->vbi_dev);
mutex_unlock(&au0828_sysfs_lock); mutex_unlock(&au0828_sysfs_lock);
v4l2_device_disconnect(&dev->v4l2_dev);
v4l2_device_put(&dev->v4l2_dev);
return 1;
} }
/* This function ensures that video frames continue to be delivered even if /* This function ensures that video frames continue to be delivered even if
...@@ -1871,6 +2019,10 @@ int au0828_analog_register(struct au0828_dev *dev, ...@@ -1871,6 +2019,10 @@ int au0828_analog_register(struct au0828_dev *dev,
dprintk(1, "au0828_analog_register called for intf#%d!\n", dprintk(1, "au0828_analog_register called for intf#%d!\n",
interface->cur_altsetting->desc.bInterfaceNumber); interface->cur_altsetting->desc.bInterfaceNumber);
/* No analog TV */
if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
return 0;
/* set au0828 usb interface0 to as5 */ /* set au0828 usb interface0 to as5 */
retval = usb_set_interface(dev->usbdev, retval = usb_set_interface(dev->usbdev,
interface->cur_altsetting->desc.bInterfaceNumber, 5); interface->cur_altsetting->desc.bInterfaceNumber, 5);
...@@ -1976,6 +2128,14 @@ int au0828_analog_register(struct au0828_dev *dev, ...@@ -1976,6 +2128,14 @@ int au0828_analog_register(struct au0828_dev *dev,
ret = -ENODEV; ret = -ENODEV;
goto err_reg_vbi_dev; goto err_reg_vbi_dev;
} }
retval = au0828_create_media_graph(dev);
if (retval) {
pr_err("%s() au0282_dev_register failed to create graph\n",
__func__);
ret = -ENODEV;
goto err_reg_vbi_dev;
}
dprintk(1, "%s completed!\n", __func__); dprintk(1, "%s completed!\n", __func__);
......
...@@ -301,6 +301,7 @@ struct au0828_dev { ...@@ -301,6 +301,7 @@ struct au0828_dev {
/* au0828-core.c */ /* au0828-core.c */
extern u32 au0828_read(struct au0828_dev *dev, u16 reg); extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val); extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
extern void au0828_usb_release(struct au0828_dev *dev);
extern int au0828_debug; extern int au0828_debug;
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
...@@ -319,16 +320,29 @@ extern int au0828_i2c_unregister(struct au0828_dev *dev); ...@@ -319,16 +320,29 @@ extern int au0828_i2c_unregister(struct au0828_dev *dev);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* au0828-video.c */ /* au0828-video.c */
extern int au0828_analog_register(struct au0828_dev *dev,
struct usb_interface *interface);
extern void au0828_analog_unregister(struct au0828_dev *dev);
extern int au0828_start_analog_streaming(struct vb2_queue *vq, extern int au0828_start_analog_streaming(struct vb2_queue *vq,
unsigned int count); unsigned int count);
extern void au0828_stop_vbi_streaming(struct vb2_queue *vq); extern void au0828_stop_vbi_streaming(struct vb2_queue *vq);
#ifdef CONFIG_VIDEO_AU0828_V4L2 #ifdef CONFIG_VIDEO_AU0828_V4L2
extern int au0828_v4l2_device_register(struct usb_interface *interface,
struct au0828_dev *dev);
extern int au0828_analog_register(struct au0828_dev *dev,
struct usb_interface *interface);
extern int au0828_analog_unregister(struct au0828_dev *dev);
extern void au0828_usb_v4l2_media_release(struct au0828_dev *dev);
extern void au0828_v4l2_suspend(struct au0828_dev *dev); extern void au0828_v4l2_suspend(struct au0828_dev *dev);
extern void au0828_v4l2_resume(struct au0828_dev *dev); extern void au0828_v4l2_resume(struct au0828_dev *dev);
#else #else
static inline int au0828_v4l2_device_register(struct usb_interface *interface,
struct au0828_dev *dev)
{ return 0; };
static inline int au0828_analog_register(struct au0828_dev *dev,
struct usb_interface *interface)
{ return 0; };
static inline int au0828_analog_unregister(struct au0828_dev *dev)
{ return 0; };
static inline void au0828_usb_v4l2_media_release(struct au0828_dev *dev) { };
static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { }; static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { };
static inline void au0828_v4l2_resume(struct au0828_dev *dev) { }; static inline void au0828_v4l2_resume(struct au0828_dev *dev) { };
#endif #endif
......
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