aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-05 04:08:25 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-10 04:23:41 -0500
commitde39078779cb08b21e7e3d2daa7d3b64a53a8d20 (patch)
treea5410b2b661486d1fbd6dcbd240ed8d524e324e0
parent54d0dbac1266d2b9a6b5a87316162a068ad545bf (diff)
[media] em2xx: use v4l2_mc_create_media_graph()
Now that the core has a function to create the media graph, we can get rid of the specialized code at em28xx. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c131
1 files changed, 1 insertions, 130 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 16a2d4039330..e7fd0bac4a08 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -883,135 +883,6 @@ static void em28xx_v4l2_media_release(struct em28xx *dev)
883 * Media Controller helper functions 883 * Media Controller helper functions
884 */ 884 */
885 885
886static int em28xx_v4l2_create_media_graph(struct em28xx *dev)
887{
888#ifdef CONFIG_MEDIA_CONTROLLER
889 struct em28xx_v4l2 *v4l2 = dev->v4l2;
890 struct media_device *mdev = dev->media_dev;
891 struct media_entity *entity;
892 struct media_entity *if_vid = NULL, *if_aud = NULL;
893 struct media_entity *tuner = NULL, *decoder = NULL;
894 int i, ret;
895
896 if (!mdev)
897 return 0;
898
899 /* Webcams are really simple */
900 if (dev->board.is_webcam) {
901 media_device_for_each_entity(entity, mdev) {
902 if (entity->function != MEDIA_ENT_F_CAM_SENSOR)
903 continue;
904 ret = media_create_pad_link(entity, 0,
905 &v4l2->vdev.entity, 0,
906 MEDIA_LNK_FL_ENABLED);
907 if (ret)
908 return ret;
909 }
910 return 0;
911 }
912
913 /* Non-webcams have analog TV decoder and other complexities */
914
915 media_device_for_each_entity(entity, mdev) {
916 switch (entity->function) {
917 case MEDIA_ENT_F_IF_VID_DECODER:
918 if_vid = entity;
919 break;
920 case MEDIA_ENT_F_IF_AUD_DECODER:
921 if_aud = entity;
922 break;
923 case MEDIA_ENT_F_TUNER:
924 tuner = entity;
925 break;
926 case MEDIA_ENT_F_ATV_DECODER:
927 decoder = entity;
928 break;
929 }
930 }
931
932 /* Analog setup, using tuner as a link */
933
934 /* Something bad happened! */
935 if (!decoder)
936 return -EINVAL;
937
938 if (tuner) {
939 if (if_vid) {
940 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
941 if_vid,
942 IF_VID_DEC_PAD_IF_INPUT,
943 MEDIA_LNK_FL_ENABLED);
944 if (ret)
945 return ret;
946 ret = media_create_pad_link(if_vid, IF_VID_DEC_PAD_OUT,
947 decoder, DEMOD_PAD_IF_INPUT,
948 MEDIA_LNK_FL_ENABLED);
949 if (ret)
950 return ret;
951 } else {
952 ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
953 decoder, DEMOD_PAD_IF_INPUT,
954 MEDIA_LNK_FL_ENABLED);
955 if (ret)
956 return ret;
957 }
958
959 if (if_aud) {
960 ret = media_create_pad_link(tuner, TUNER_PAD_AUD_OUT,
961 if_aud,
962 IF_AUD_DEC_PAD_IF_INPUT,
963 MEDIA_LNK_FL_ENABLED);
964 if (ret)
965 return ret;
966 } else {
967 if_aud = tuner;
968 }
969
970 }
971 ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
972 &v4l2->vdev.entity, 0,
973 MEDIA_LNK_FL_ENABLED);
974 if (ret)
975 return ret;
976
977 if (em28xx_vbi_supported(dev)) {
978 ret = media_create_pad_link(decoder, DEMOD_PAD_VBI_OUT,
979 &v4l2->vbi_dev.entity, 0,
980 MEDIA_LNK_FL_ENABLED);
981 if (ret)
982 return ret;
983 }
984
985 for (i = 0; i < MAX_EM28XX_INPUT; i++) {
986 struct media_entity *ent = &dev->input_ent[i];
987
988 if (!INPUT(i)->type)
989 break;
990
991 switch (INPUT(i)->type) {
992 case EM28XX_VMUX_COMPOSITE:
993 case EM28XX_VMUX_SVIDEO:
994 ret = media_create_pad_link(ent, 0, decoder,
995 DEMOD_PAD_IF_INPUT, 0);
996 if (ret)
997 return ret;
998 break;
999 default: /* EM28XX_VMUX_TELEVISION or EM28XX_RADIO */
1000 if (!tuner)
1001 break;
1002
1003 ret = media_create_pad_link(ent, 0, tuner,
1004 TUNER_PAD_RF_INPUT,
1005 MEDIA_LNK_FL_ENABLED);
1006 if (ret)
1007 return ret;
1008 break;
1009 }
1010 }
1011#endif
1012 return 0;
1013}
1014
1015static int em28xx_enable_analog_tuner(struct em28xx *dev) 886static int em28xx_enable_analog_tuner(struct em28xx *dev)
1016{ 887{
1017#ifdef CONFIG_MEDIA_CONTROLLER 888#ifdef CONFIG_MEDIA_CONTROLLER
@@ -2842,7 +2713,7 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2842 /* Init entities at the Media Controller */ 2713 /* Init entities at the Media Controller */
2843 em28xx_v4l2_create_entities(dev); 2714 em28xx_v4l2_create_entities(dev);
2844 2715
2845 ret = em28xx_v4l2_create_media_graph(dev); 2716 ret = v4l2_mc_create_media_graph(dev->media_dev);
2846 if (ret) { 2717 if (ret) {
2847 em28xx_errdev("failed to create media graph\n"); 2718 em28xx_errdev("failed to create media graph\n");
2848 em28xx_v4l2_media_release(dev); 2719 em28xx_v4l2_media_release(dev);