diff options
author | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-12-22 11:16:49 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-01-07 02:07:11 -0500 |
commit | b64f8e9adc2eff4941ca0cf146a850c7b4173594 (patch) | |
tree | c9f8b3cc6aec6929de4db36950b0d0abf78dc510 /drivers/media/usb/em28xx/em28xx-cards.c | |
parent | 54a2a84ea9e8640b4f1df4e222e305d03bb64065 (diff) |
[media] em28xx: move analog-specific init to em28xx-video
There are several init code inside em28xx-cards that are actually
part of analog initialization. Move the code to em28x-video, in
order to remove part of the mess.
In thesis, no functional changes so far.
Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-cards.c')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-cards.c | 150 |
1 files changed, 3 insertions, 147 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 154e6f028fd2..541de6df127b 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c | |||
@@ -2360,24 +2360,6 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { | |||
2360 | }; | 2360 | }; |
2361 | /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */ | 2361 | /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */ |
2362 | 2362 | ||
2363 | /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ | ||
2364 | static unsigned short saa711x_addrs[] = { | ||
2365 | 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */ | ||
2366 | 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ | ||
2367 | I2C_CLIENT_END }; | ||
2368 | |||
2369 | static unsigned short tvp5150_addrs[] = { | ||
2370 | 0xb8 >> 1, | ||
2371 | 0xba >> 1, | ||
2372 | I2C_CLIENT_END | ||
2373 | }; | ||
2374 | |||
2375 | static unsigned short msp3400_addrs[] = { | ||
2376 | 0x80 >> 1, | ||
2377 | 0x88 >> 1, | ||
2378 | I2C_CLIENT_END | ||
2379 | }; | ||
2380 | |||
2381 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) | 2363 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) |
2382 | { | 2364 | { |
2383 | struct em28xx_i2c_bus *i2c_bus = ptr; | 2365 | struct em28xx_i2c_bus *i2c_bus = ptr; |
@@ -2782,58 +2764,8 @@ static void em28xx_card_setup(struct em28xx *dev) | |||
2782 | /* Allow override tuner type by a module parameter */ | 2764 | /* Allow override tuner type by a module parameter */ |
2783 | if (tuner >= 0) | 2765 | if (tuner >= 0) |
2784 | dev->tuner_type = tuner; | 2766 | dev->tuner_type = tuner; |
2785 | |||
2786 | /* request some modules */ | ||
2787 | if (dev->board.has_msp34xx) | ||
2788 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], | ||
2789 | "msp3400", 0, msp3400_addrs); | ||
2790 | |||
2791 | if (dev->board.decoder == EM28XX_SAA711X) | ||
2792 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], | ||
2793 | "saa7115_auto", 0, saa711x_addrs); | ||
2794 | |||
2795 | if (dev->board.decoder == EM28XX_TVP5150) | ||
2796 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], | ||
2797 | "tvp5150", 0, tvp5150_addrs); | ||
2798 | |||
2799 | if (dev->board.adecoder == EM28XX_TVAUDIO) | ||
2800 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], | ||
2801 | "tvaudio", dev->board.tvaudio_addr, NULL); | ||
2802 | |||
2803 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
2804 | int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); | ||
2805 | |||
2806 | if (dev->board.radio.type) | ||
2807 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], | ||
2808 | "tuner", dev->board.radio_addr, NULL); | ||
2809 | |||
2810 | if (has_demod) | ||
2811 | v4l2_i2c_new_subdev(&dev->v4l2_dev, | ||
2812 | &dev->i2c_adap[dev->def_i2c_bus], "tuner", | ||
2813 | 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
2814 | if (dev->tuner_addr == 0) { | ||
2815 | enum v4l2_i2c_tuner_type type = | ||
2816 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | ||
2817 | struct v4l2_subdev *sd; | ||
2818 | |||
2819 | sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, | ||
2820 | &dev->i2c_adap[dev->def_i2c_bus], "tuner", | ||
2821 | 0, v4l2_i2c_tuner_addrs(type)); | ||
2822 | |||
2823 | if (sd) | ||
2824 | dev->tuner_addr = v4l2_i2c_subdev_addr(sd); | ||
2825 | } else { | ||
2826 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], | ||
2827 | "tuner", dev->tuner_addr, NULL); | ||
2828 | } | ||
2829 | } | ||
2830 | |||
2831 | em28xx_tuner_setup(dev); | ||
2832 | |||
2833 | em28xx_init_camera(dev); | ||
2834 | } | 2767 | } |
2835 | 2768 | ||
2836 | |||
2837 | static void request_module_async(struct work_struct *work) | 2769 | static void request_module_async(struct work_struct *work) |
2838 | { | 2770 | { |
2839 | struct em28xx *dev = container_of(work, | 2771 | struct em28xx *dev = container_of(work, |
@@ -2907,7 +2839,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
2907 | struct usb_interface *interface, | 2839 | struct usb_interface *interface, |
2908 | int minor) | 2840 | int minor) |
2909 | { | 2841 | { |
2910 | struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler; | ||
2911 | int retval; | 2842 | int retval; |
2912 | static const char *default_chip_name = "em28xx"; | 2843 | static const char *default_chip_name = "em28xx"; |
2913 | const char *chip_name = default_chip_name; | 2844 | const char *chip_name = default_chip_name; |
@@ -3034,15 +2965,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3034 | } | 2965 | } |
3035 | } | 2966 | } |
3036 | 2967 | ||
3037 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | ||
3038 | if (retval < 0) { | ||
3039 | em28xx_errdev("Call to v4l2_device_register() failed!\n"); | ||
3040 | return retval; | ||
3041 | } | ||
3042 | |||
3043 | v4l2_ctrl_handler_init(hdl, 8); | ||
3044 | dev->v4l2_dev.ctrl_handler = hdl; | ||
3045 | |||
3046 | rt_mutex_init(&dev->i2c_bus_lock); | 2968 | rt_mutex_init(&dev->i2c_bus_lock); |
3047 | 2969 | ||
3048 | /* register i2c bus 0 */ | 2970 | /* register i2c bus 0 */ |
@@ -3053,7 +2975,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3053 | if (retval < 0) { | 2975 | if (retval < 0) { |
3054 | em28xx_errdev("%s: em28xx_i2c_register bus 0 - error [%d]!\n", | 2976 | em28xx_errdev("%s: em28xx_i2c_register bus 0 - error [%d]!\n", |
3055 | __func__, retval); | 2977 | __func__, retval); |
3056 | goto unregister_dev; | 2978 | return retval; |
3057 | } | 2979 | } |
3058 | 2980 | ||
3059 | /* register i2c bus 1 */ | 2981 | /* register i2c bus 1 */ |
@@ -3067,75 +2989,16 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3067 | if (retval < 0) { | 2989 | if (retval < 0) { |
3068 | em28xx_errdev("%s: em28xx_i2c_register bus 1 - error [%d]!\n", | 2990 | em28xx_errdev("%s: em28xx_i2c_register bus 1 - error [%d]!\n", |
3069 | __func__, retval); | 2991 | __func__, retval); |
3070 | goto unregister_dev; | 2992 | return retval; |
3071 | } | 2993 | } |
3072 | } | 2994 | } |
3073 | 2995 | ||
3074 | /* | ||
3075 | * Default format, used for tvp5150 or saa711x output formats | ||
3076 | */ | ||
3077 | dev->vinmode = 0x10; | ||
3078 | dev->vinctl = EM28XX_VINCTRL_INTERLACED | | ||
3079 | EM28XX_VINCTRL_CCIR656_ENABLE; | ||
3080 | |||
3081 | /* Do board specific init and eeprom reading */ | 2996 | /* Do board specific init and eeprom reading */ |
3082 | em28xx_card_setup(dev); | 2997 | em28xx_card_setup(dev); |
3083 | 2998 | ||
3084 | /* Configure audio */ | ||
3085 | retval = em28xx_audio_setup(dev); | ||
3086 | if (retval < 0) { | ||
3087 | em28xx_errdev("%s: Error while setting audio - error [%d]!\n", | ||
3088 | __func__, retval); | ||
3089 | goto fail; | ||
3090 | } | ||
3091 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | ||
3092 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, | ||
3093 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); | ||
3094 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, | ||
3095 | V4L2_CID_AUDIO_VOLUME, 0, 0x1f, 1, 0x1f); | ||
3096 | } else { | ||
3097 | /* install the em28xx notify callback */ | ||
3098 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_MUTE), | ||
3099 | em28xx_ctrl_notify, dev); | ||
3100 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_VOLUME), | ||
3101 | em28xx_ctrl_notify, dev); | ||
3102 | } | ||
3103 | |||
3104 | /* wake i2c devices */ | ||
3105 | em28xx_wake_i2c(dev); | ||
3106 | |||
3107 | /* init video dma queues */ | ||
3108 | INIT_LIST_HEAD(&dev->vidq.active); | ||
3109 | INIT_LIST_HEAD(&dev->vbiq.active); | ||
3110 | |||
3111 | if (dev->board.has_msp34xx) { | ||
3112 | /* Send a reset to other chips via gpio */ | ||
3113 | retval = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7); | ||
3114 | if (retval < 0) { | ||
3115 | em28xx_errdev("%s: em28xx_write_reg - " | ||
3116 | "msp34xx(1) failed! error [%d]\n", | ||
3117 | __func__, retval); | ||
3118 | goto fail; | ||
3119 | } | ||
3120 | msleep(3); | ||
3121 | |||
3122 | retval = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); | ||
3123 | if (retval < 0) { | ||
3124 | em28xx_errdev("%s: em28xx_write_reg - " | ||
3125 | "msp34xx(2) failed! error [%d]\n", | ||
3126 | __func__, retval); | ||
3127 | goto fail; | ||
3128 | } | ||
3129 | msleep(3); | ||
3130 | } | ||
3131 | |||
3132 | retval = em28xx_register_analog_devices(dev); | 2999 | retval = em28xx_register_analog_devices(dev); |
3133 | if (retval < 0) { | 3000 | if (retval < 0) |
3134 | goto fail; | 3001 | goto fail; |
3135 | } | ||
3136 | |||
3137 | /* Save some power by putting tuner to sleep */ | ||
3138 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); | ||
3139 | 3002 | ||
3140 | return 0; | 3003 | return 0; |
3141 | 3004 | ||
@@ -3143,10 +3006,6 @@ fail: | |||
3143 | if (dev->def_i2c_bus) | 3006 | if (dev->def_i2c_bus) |
3144 | em28xx_i2c_unregister(dev, 1); | 3007 | em28xx_i2c_unregister(dev, 1); |
3145 | em28xx_i2c_unregister(dev, 0); | 3008 | em28xx_i2c_unregister(dev, 0); |
3146 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
3147 | |||
3148 | unregister_dev: | ||
3149 | v4l2_device_unregister(&dev->v4l2_dev); | ||
3150 | 3009 | ||
3151 | return retval; | 3010 | return retval; |
3152 | } | 3011 | } |
@@ -3388,9 +3247,6 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3388 | /* save our data pointer in this interface device */ | 3247 | /* save our data pointer in this interface device */ |
3389 | usb_set_intfdata(interface, dev); | 3248 | usb_set_intfdata(interface, dev); |
3390 | 3249 | ||
3391 | /* initialize videobuf2 stuff */ | ||
3392 | em28xx_vb2_setup(dev); | ||
3393 | |||
3394 | /* allocate device struct */ | 3250 | /* allocate device struct */ |
3395 | mutex_init(&dev->lock); | 3251 | mutex_init(&dev->lock); |
3396 | mutex_lock(&dev->lock); | 3252 | mutex_lock(&dev->lock); |