Add media controller support to em28xx driver
Subsystems (6)
PATCH 6/13 media.h: add support for IF-PLL video/sound decoder
In reply to a message not in the archiveVery old hardware may have an analog stage tuner. Those hardware consists of a PLL that converts a RF signal into IF signals.
Depending on the hardware, those video IF signal can be decoded directly by the bridge chipset. Most Conexant chips (bt8x8, cx2388x, etc) have internally the decoders for that. Yet, even on such hardware, the tuner may have internally its own TV multi-standard decoder like tda9887.
The same happens with the audio IF signal, where some bridges are capable of receiving it, while others require an external IF-PLL sound decoder, like msp3400.
Those external IF-PLL audio and video decoders have their own I2C address, and use different drivers to handle them. So, they're mapped as different subdevices on Linux.
Thankfully, all modern hardware comes with an IC chip that has both the RF and the IF stages on it, being capable of decoding audio and video IF signals internally.
Yet, as we need to support drivers that can work with either analog or silicon tuners, we need to add two entity types for those old hardware.
--- Documentation/DocBook/media/v4l/media-types.xml | 29 ++++++++++++++++++++++++- include/uapi/linux/media.h | 17 +++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-)
Documentation/DocBook/media/v4l/media-types.xml +28 -1
@@ -84,7 +84,34 @@ </row> <row> <entry><constant>MEDIA_ENT_F_TUNER</constant></entry> - <entry>Digital TV, analog TV, radio and/or software radio tuner.</entry> + <entry>Digital TV, analog TV, radio and/or software radio tuner, + with consists on a PLL tuning stage that converts radio + frequency (RF) signal into an Intermediate Frequency (IF). + Modern tuners have internally IF-PLL decoders for audio + and video, but older models have those stages implemented + on separate entities. + </entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_IF_VID_DECODER</constant></entry> + <entry>IF-PLL video decoder. It receives the IF from a PLL + and decodes the analog TV video signal. This is commonly + found on some very old analog tuners, like Philips MK3 + designs. They all contain a tda9887 (or some software + compatible similar chip, like tda9885). Those devices + use a different I2C address than the tuner PLL. + </entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_IF_AUD_DECODER</constant></entry> + <entry>IF-PLL sound decoder. It receives the IF from a PLL + and decodes the analog TV audio signal. This is commonly + found on some very old analog hardware, like Micronas + msp3400, Philips tda9840, tda985x, etc. Those devices + use a different I2C address than the tuner PLL and + should be controlled together with the IF-PLL video + decoder. + </entry> </row> </tbody> </tgroup>
include/uapi/linux/media.h +15 -2
@@ -89,6 +89,15 @@ struct media_device_info {#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33)/* +* Analog TV IF-PLL decoders +* +* It is a responsibility of the master/bridge drivers to create links +* for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER. +*/ +#define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 41) +#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 42) + +/* * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility * with the legacy v1 API.The number range is out of range by purpose:
@@ -107,8 +116,12 @@ struct media_device_info {#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)/* -* It is a responsibility of the entity drivers to add connectors and links -* for the tuner entities. +* It is a responsibility of the master/bridge drivers to add connectors +* and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners +* may require the usage of separate I2C chips to decode analog TV signals, +* when the master/bridge chipset doesn't have its own TV standard decoder. +* On such cases, the IF-PLL staging is mapped via one or two entities: +* MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER. */ #define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
Signature · 1 line
2.5.0
cover Add media controller support to em28xx driver
This series add MC support to the em28xx driver. Among the hybrid TV USB drivers, this is the most complex one, as there are lots of different hardware options that are compatible with this driver.
Yet, it is used with only two analog TV demod drivers (tvp5150 and saa7115) and, optionally, one IF-PLL audio decoder (msp3400). It means that there aren't many I2C drivers that need to be touched.
The PCI drivers are a way more complex, as they may have audio processors and may use a wide range of other I2C drivers. So, it is wise to implement MC support at em28xx before those, as it helps to address some issues before extending MC to the wild.
The two patches in this series are actually unrelated to MC. The first one is a cleanup at em28xx, and the second patch fixes one KASAN error.
The next patches make the Media Controller aware of the existence of IF-PLL drivers, commonly found on older designs. They also standardize the pad index for tuners, IF-PLLs and demods.
Finally, MC support for tda9887, tvp5150, saa7115 and msp3400 is added, making those drivers to properly report the MC function supported by the driver and creating the source/sink pads for them.
The last patch finally add em28xx MC support.
I opted to not add any helper function for now at v4l2-mc.c, putting all needed code at em28xx, because I didn't want to cause hard to find conflicts with Shuah's patches, that are touching the routines at au0828. After having Shuah patches merged, I'll work to move the generic code to v4l2-mc.c (yet to be created).
This series was tested on the following devices:
Hauppauge HVR-950 (2040:6513):
https://mchehab.fedorapeople.org/mc-next-gen/hvr_950.png
Haupauge WinTV USB2 (2040:4200):
https://mchehab.fedorapeople.org/mc-next-gen/wintv_usb2.png
KWorld USB ATSC TV Stick UB435-Q V3 (1b80:e34c):
https://mchehab.fedorapeople.org/mc-next-gen/kworld_435q.png
PCTV 261e (2013:0258):
https://mchehab.fedorapeople.org/mc-next-gen/pctv_261e.png
PCTV 290e (2013:024f):
https://mchehab.fedorapeople.org/mc-next-gen/pctv_290e.png
Pixelview PlayTV USB2 (eb1a:2821):
https://mchehab.fedorapeople.org/mc-next-gen/playtv_usb.png
(an extra patch was needed for it to detect the tuner - I'll send it in separate)
Regards,
Mauro
Mauro Carvalho Chehab (13):
[media] em28xx: remove unused input types
[media] xc2028: avoid use after free
[media] tuner.h: rename TUNER_PAD_IF_OUTPUT to TUNER_PAD_OUTPUT [media] v4l2-mc.h: move tuner PAD definitions to this new header [media] v4l2-mc.h: Split audio from baseband output [media] media.h: add support for IF-PLL video/sound decoder [media] v4l2-mc.h Add pads for audio and video IF-PLL decoders [media] v4l2-mc: add analog TV demodulator pad index macros [media] tvp5150: create the expected number of pads [media] msp3400: initialize MC data
[media] tvp5150: identify it as a MEDIA_ENT_F_ATV_DECODER [media] saa7115: initialize demod type and add the needed pads [media] em28xx: add media controller support
Documentation/DocBook/device-drivers.tmpl | 1 + Documentation/DocBook/media/v4l/media-types.xml | 29 ++- drivers/media/dvb-core/dvbdev.c | 2 +- drivers/media/i2c/msp3400-driver.c | 14 ++ drivers/media/i2c/msp3400-driver.h | 5 + drivers/media/i2c/saa7115.c | 19 ++ drivers/media/i2c/tvp5150.c | 14 +- drivers/media/tuners/tuner-xc2028.c | 5 +- drivers/media/usb/au0828/au0828-core.c | 2 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 2 +- drivers/media/usb/em28xx/em28xx-cards.c | 189 ++++++++++------ drivers/media/usb/em28xx/em28xx-dvb.c | 10 + drivers/media/usb/em28xx/em28xx-video.c | 279 ++++++++++++++++++++++-- drivers/media/usb/em28xx/em28xx.h | 21 +- drivers/media/v4l2-core/tuner-core.c | 26 ++- include/media/tuner.h | 9 +- include/media/v4l2-mc.h | 91 ++++++++ include/uapi/linux/media.h | 17 +- 19 files changed, 621 insertions(+), 116 deletions(-) create mode 100644 include/media/v4l2-mc.h
Signature · 1 line
2.5.0
PATCH 1/13 em28xx: remove unused input types
The em28xx driver have lots of different input types but only 4 of such types are actually used. The others are bogus.
Remove them, in order to cleanup the driver.
--- drivers/media/usb/em28xx/em28xx-cards.c | 134 ++++++++++++++++---------------- drivers/media/usb/em28xx/em28xx-video.c | 16 ++-- drivers/media/usb/em28xx/em28xx.h | 8 +- 3 files changed, 73 insertions(+), 85 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +67 -67
@@ -570,7 +570,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .is_webcam = 1, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = 0, .amux = EM28XX_AMUX_VIDEO, .gpio = silvercrest_reg_seq,
@@ -583,7 +583,7 @@ struct em28xx_board em28xx_boards[] = { .decoder = EM28XX_SAA711X, .tuner_type = TUNER_ABSENT, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -605,7 +605,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .is_webcam = 1, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = 0, .amux = EM28XX_AMUX_VIDEO, } },
@@ -616,7 +616,7 @@ struct em28xx_board em28xx_boards[] = { .tda9887_conf = TDA9887_PRESENT, .decoder = EM28XX_SAA711X, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -635,7 +635,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_LINE_IN, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -655,7 +655,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -675,7 +675,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -715,7 +715,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_LINE_IN, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -735,7 +735,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_LINE_IN, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -755,7 +755,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -775,7 +775,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -800,7 +800,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE4, .amux = EM28XX_AMUX_AUX, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE5, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -819,7 +819,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .is_webcam = 1, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = 0, .amux = EM28XX_AMUX_VIDEO, } },
@@ -829,7 +829,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .is_webcam = 1, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = 0, .amux = EM28XX_AMUX_VIDEO, .gpio = silvercrest_reg_seq,
@@ -848,7 +848,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_LINE_IN, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_VIDEO, }, {
@@ -863,7 +863,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, /* Capture only device */ .decoder = EM28XX_SAA711X, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -879,7 +879,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .is_webcam = 1, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = 0, .amux = EM28XX_AMUX_VIDEO, } },
@@ -889,7 +889,7 @@ struct em28xx_board em28xx_boards[] = { .decoder = EM28XX_SAA711X, .tuner_type = TUNER_ABSENT, /* Capture only device */ .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -909,7 +909,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -930,7 +930,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -952,7 +952,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -974,7 +974,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = TVP5150_COMPOSITE0, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -992,7 +992,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = TVP5150_COMPOSITE0, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1006,7 +1006,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, /* Capture only device */ .decoder = EM28XX_TVP5150, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1029,7 +1029,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_LINE_IN, .gpio = pinnacle_hybrid_pro_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = pinnacle_hybrid_pro_analog,
@@ -1100,7 +1100,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = terratec_cinergy_USB_XS_FR_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = terratec_cinergy_USB_XS_FR_analog,
@@ -1186,7 +1186,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1213,7 +1213,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1239,7 +1239,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1265,7 +1265,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1291,7 +1291,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1317,7 +1317,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1343,7 +1343,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = default_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = default_analog,
@@ -1368,7 +1368,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1392,7 +1392,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE4, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1413,7 +1413,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1428,7 +1428,7 @@ struct em28xx_board em28xx_boards[] = { .decoder = EM28XX_SAA711X, .tuner_type = TUNER_ABSENT, /* capture only board */ .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1443,7 +1443,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, /* Capture-only board */ .decoder = EM28XX_SAA711X, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, .gpio = vc211a_enable,
@@ -1465,7 +1465,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1485,7 +1485,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1500,7 +1500,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, /* capture only board */ .decoder = EM28XX_SAA711X, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1520,7 +1520,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1541,7 +1541,7 @@ struct em28xx_board em28xx_boards[] = { .aout = EM28XX_AOUT_MONO | /* I2S */ EM28XX_AOUT_MASTER, /* Line out pin */ }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1563,7 +1563,7 @@ struct em28xx_board em28xx_boards[] = { .aout = EM28XX_AOUT_MONO | /* I2S */ EM28XX_AOUT_MASTER, /* Line out pin */ }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1581,7 +1581,7 @@ struct em28xx_board em28xx_boards[] = { .type = EM28XX_VMUX_SVIDEO, .vmux = SAA7115_SVIDEO3, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, } }, },
@@ -1610,7 +1610,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = em2880_msi_digivox_ad_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = em2880_msi_digivox_ad_analog,
@@ -1633,7 +1633,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = em2880_msi_digivox_ad_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = em2880_msi_digivox_ad_analog,
@@ -1654,7 +1654,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = TVP5150_COMPOSITE0, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1677,7 +1677,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = default_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = default_analog,
@@ -1708,7 +1708,7 @@ struct em28xx_board em28xx_boards[] = { .gpio = em2882_kworld_315u_analog, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, .gpio = em2882_kworld_315u_analog1,
@@ -1735,7 +1735,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = default_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = default_analog,
@@ -1758,7 +1758,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = default_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = default_analog,
@@ -1782,7 +1782,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = pinnacle_hybrid_pro_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = pinnacle_hybrid_pro_analog,
@@ -1808,7 +1808,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1834,7 +1834,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = TVP5150_COMPOSITE0, .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1859,7 +1859,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = hauppauge_wintv_hvr_900_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = hauppauge_wintv_hvr_900_analog,
@@ -1904,7 +1904,7 @@ struct em28xx_board em28xx_boards[] = { .gpio = kworld_330u_analog, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = kworld_330u_analog,
@@ -1951,7 +1951,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1970,7 +1970,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .decoder = EM28XX_SAA711X, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -1990,7 +1990,7 @@ struct em28xx_board em28xx_boards[] = { .vmux = TVP5150_COMPOSITE0, .amux = EM28XX_AMUX_VIDEO, }, { /* Composite has not been tested yet */ - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_VIDEO, }, { /* S-video has not been tested yet */
@@ -2006,7 +2006,7 @@ struct em28xx_board em28xx_boards[] = { .decoder = EM28XX_SAA711X, .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -2023,7 +2023,7 @@ struct em28xx_board em28xx_boards[] = { .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, .mute_gpio = terratec_av350_mute_gpio, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AUDIO_SRC_LINE, .gpio = terratec_av350_unmute_gpio,
@@ -2041,7 +2041,7 @@ struct em28xx_board em28xx_boards[] = { .decoder = EM28XX_SAA711X, .tuner_type = TUNER_ABSENT, /* Capture only device */ .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -2067,7 +2067,7 @@ struct em28xx_board em28xx_boards[] = { .amux = EM28XX_AMUX_VIDEO, .gpio = evga_indtube_analog, }, { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, .gpio = evga_indtube_analog,
@@ -2125,7 +2125,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .decoder = EM28XX_SAA711X, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, }, {
@@ -2238,7 +2238,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, .is_webcam = 1, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .amux = EM28XX_AMUX_VIDEO, .gpio = speedlink_vad_laplace_reg_seq, } },
@@ -2272,7 +2272,7 @@ struct em28xx_board em28xx_boards[] = { .tuner_type = TUNER_ABSENT, /* Capture only device */ .decoder = EM28XX_TVP5150, .input = { { - .type = EM28XX_VMUX_COMPOSITE1, + .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, .amux = EM28XX_AMUX_LINE_IN, }, {
drivers/media/usb/em28xx/em28xx-video.c +5 -11
@@ -1442,16 +1442,11 @@ static int vidioc_s_parm(struct file *file, void *priv, 0, video, s_parm, p); } -static const char *iname[] = { - [EM28XX_VMUX_COMPOSITE1 ] ="Composite1" , - [EM28XX_VMUX_COMPOSITE2 ] ="Composite2" , - [EM28XX_VMUX_COMPOSITE3 ] ="Composite3" , - [EM28XX_VMUX_COMPOSITE4 ] ="Composite4" , - [EM28XX_VMUX_SVIDEO ] ="S-Video" , +static const char *const iname[] = { + [EM28XX_VMUX_COMPOSITE ] ="Composite" , + [EM28XX_VMUX_SVIDEO ] ="S-Video" , [EM28XX_VMUX_TELEVISION ] ="Television" , - [EM28XX_VMUX_CABLE ] ="Cable TV" , - [EM28XX_VMUX_DVB ] ="DVB" , - [EM28XX_VMUX_DEBUG ] ="for debug only" , + [EM28XX_RADIO ] ="Radio" , }; static int vidioc_enum_input(struct file *file, void *priv,
@@ -1471,8 +1466,7 @@ static int vidioc_enum_input(struct file *file, void *priv,strcpy (i->name, iname[INPUT (n)->type]); -if ((EM28XX_VMUX_TELEVISION ==INPUT (n)->type) || - (EM28XX_VMUX_CABLE ==INPUT (n)->type)) +if ((EM28XX_VMUX_TELEVISION ==INPUT (n)->type)) i->type =V4L2_INPUT_TYPE_TUNER ; i->std = dev->v4l2->vdev.tvnorms;
drivers/media/usb/em28xx/em28xx.h +1 -7
@@ -291,15 +291,9 @@ struct em28xx_dmaqueue {#define MAX_EM28XX_INPUT 4enum enum28xx_itype { -EM28XX_VMUX_COMPOSITE1 =1 , -EM28XX_VMUX_COMPOSITE2 , -EM28XX_VMUX_COMPOSITE3 , -EM28XX_VMUX_COMPOSITE4 , +EM28XX_VMUX_COMPOSITE =1 ,EM28XX_VMUX_SVIDEO ,EM28XX_VMUX_TELEVISION , -EM28XX_VMUX_CABLE , -EM28XX_VMUX_DVB , -EM28XX_VMUX_DEBUG ,EM28XX_RADIO , };
Signature · 1 line
2.5.0
PATCH 2/13 xc2028: avoid use after free
In reply to Mauro Carvalho ChehabIf struct xc2028_config is passed without a firmware name, the following trouble may happen:
[11009.907205] xc2028 5-0061: type set to XCeive xc2028/xc3028 tuner [11009.907491] ================================================================== [11009.907750] BUG: KASAN: use-after-free in strcmp+0x96/0xb0 at addr ffff8803bd78ab40 [11009.907992] Read of size 1 by task modprobe/28992 [11009.907994] ============================================================================= [11009.907997] BUG kmalloc-16 (Tainted: G W ): kasan: bad access detected [11009.907999] -----------------------------------------------------------------------------
[11009.908008] INFO: Allocated in xhci_urb_enqueue+0x214/0x14c0 [xhci_hcd] age=0 cpu=3 pid=28992 [11009.908012] ___slab_alloc+0x581/0x5b0 [11009.908014] __slab_alloc+0x51/0x90 [11009.908017] __kmalloc+0x27b/0x350 [11009.908022] xhci_urb_enqueue+0x214/0x14c0 [xhci_hcd] [11009.908026] usb_hcd_submit_urb+0x1e8/0x1c60 [11009.908029] usb_submit_urb+0xb0e/0x1200 [11009.908032] usb_serial_generic_write_start+0xb6/0x4c0 [11009.908035] usb_serial_generic_write+0x92/0xc0 [11009.908039] usb_console_write+0x38a/0x560 [11009.908045] call_console_drivers.constprop.14+0x1ee/0x2c0 [11009.908051] console_unlock+0x40d/0x900 [11009.908056] vprintk_emit+0x4b4/0x830 [11009.908061] vprintk_default+0x1f/0x30 [11009.908064] printk+0x99/0xb5 [11009.908067] kasan_report_error+0x10a/0x550 [11009.908070] __asan_report_load1_noabort+0x43/0x50 [11009.908074] INFO: Freed in xc2028_set_config+0x90/0x630 [tuner_xc2028] age=1 cpu=3 pid=28992 [11009.908077] __slab_free+0x2ec/0x460 [11009.908080] kfree+0x266/0x280 [11009.908083] xc2028_set_config+0x90/0x630 [tuner_xc2028] [11009.908086] xc2028_attach+0x310/0x8a0 [tuner_xc2028] [11009.908090] em28xx_attach_xc3028.constprop.7+0x1f9/0x30d [em28xx_dvb] [11009.908094] em28xx_dvb_init.part.3+0x8e4/0x5cf4 [em28xx_dvb] [11009.908098] em28xx_dvb_init+0x81/0x8a [em28xx_dvb] [11009.908101] em28xx_register_extension+0xd9/0x190 [em28xx] [11009.908105] em28xx_dvb_register+0x10/0x1000 [em28xx_dvb] [11009.908108] do_one_initcall+0x141/0x300 [11009.908111] do_init_module+0x1d0/0x5ad [11009.908114] load_module+0x6666/0x9ba0 [11009.908117] SyS_finit_module+0x108/0x130 [11009.908120] entry_SYSCALL_64_fastpath+0x16/0x76 [11009.908123] INFO: Slab 0xffffea000ef5e280 objects=25 used=25 fp=0x (null) flags=0x2ffff8000004080 [11009.908126] INFO: Object 0xffff8803bd78ab40 @offset=2880 fp=0x0000000000000001
[11009.908130] Bytes b4 ffff8803bd78ab30: 01 00 00 00 2a 07 00 00 9d 28 00 00 01 00 00 00 ....*....(...... [11009.908133] Object ffff8803bd78ab40: 01 00 00 00 00 00 00 00 b0 1d c3 6a 00 88 ff ff ...........j.... [11009.908137] CPU: 3 PID: 28992 Comm: modprobe Tainted: G B W 4.5.0-rc1+ #43 [11009.908140] Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0350.2015.0812.1722 08/12/2015 [11009.908142] ffff8803bd78a000 ffff8802c273f1b8 ffffffff81932007 ffff8803c6407a80 [11009.908148] ffff8802c273f1e8 ffffffff81556759 ffff8803c6407a80 ffffea000ef5e280 [11009.908153] ffff8803bd78ab40 dffffc0000000000 ffff8802c273f210 ffffffff8155ccb4 [11009.908158] Call Trace: [11009.908162] [<ffffffff81932007>] dump_stack+0x4b/0x64 [11009.908165] [<ffffffff81556759>] print_trailer+0xf9/0x150 [11009.908168] [<ffffffff8155ccb4>] object_err+0x34/0x40 [11009.908171] [<ffffffff8155f260>] kasan_report_error+0x230/0x550 [11009.908175] [<ffffffff81237d71>] ? trace_hardirqs_off_caller+0x21/0x290 [11009.908179] [<ffffffff8155e926>] ? kasan_unpoison_shadow+0x36/0x50 [11009.908182] [<ffffffff8155f5c3>] __asan_report_load1_noabort+0x43/0x50 [11009.908185] [<ffffffff8155ea00>] ? __asan_register_globals+0x50/0xa0 [11009.908189] [<ffffffff8194cea6>] ? strcmp+0x96/0xb0 [11009.908192] [<ffffffff8194cea6>] strcmp+0x96/0xb0 [11009.908196] [<ffffffffa13ba4ac>] xc2028_set_config+0x15c/0x630 [tuner_xc2028] [11009.908200] [<ffffffffa13bac90>] xc2028_attach+0x310/0x8a0 [tuner_xc2028] [11009.908203] [<ffffffff8155ea78>] ? memset+0x28/0x30 [11009.908206] [<ffffffffa13ba980>] ? xc2028_set_config+0x630/0x630 [tuner_xc2028] [11009.908211] [<ffffffffa157a59a>] em28xx_attach_xc3028.constprop.7+0x1f9/0x30d [em28xx_dvb] [11009.908215] [<ffffffffa157aa2a>] ? em28xx_dvb_init.part.3+0x37c/0x5cf4 [em28xx_dvb] [11009.908219] [<ffffffffa157a3a1>] ? hauppauge_hvr930c_init+0x487/0x487 [em28xx_dvb] [11009.908222] [<ffffffffa01795ac>] ? lgdt330x_attach+0x1cc/0x370 [lgdt330x] [11009.908226] [<ffffffffa01793e0>] ? i2c_read_demod_bytes.isra.2+0x210/0x210 [lgdt330x] [11009.908230] [<ffffffff812e87d0>] ? ref_module.part.15+0x10/0x10 [11009.908233] [<ffffffff812e56e0>] ? module_assert_mutex_or_preempt+0x80/0x80 [11009.908238] [<ffffffffa157af92>] em28xx_dvb_init.part.3+0x8e4/0x5cf4 [em28xx_dvb] [11009.908242] [<ffffffffa157a6ae>] ? em28xx_attach_xc3028.constprop.7+0x30d/0x30d [em28xx_dvb] [11009.908245] [<ffffffff8195222d>] ? string+0x14d/0x1f0 [11009.908249] [<ffffffff8195381f>] ? symbol_string+0xff/0x1a0 [11009.908253] [<ffffffff81953720>] ? uuid_string+0x6f0/0x6f0 [11009.908257] [<ffffffff811a775e>] ? __kernel_text_address+0x7e/0xa0 [11009.908260] [<ffffffff8104b02f>] ? print_context_stack+0x7f/0xf0 [11009.908264] [<ffffffff812e9846>] ? __module_address+0xb6/0x360 [11009.908268] [<ffffffff8137fdc9>] ? is_ftrace_trampoline+0x99/0xe0 [11009.908271] [<ffffffff811a775e>] ? __kernel_text_address+0x7e/0xa0 [11009.908275] [<ffffffff81240a70>] ? debug_check_no_locks_freed+0x290/0x290 [11009.908278] [<ffffffff8104a24b>] ? dump_trace+0x11b/0x300 [11009.908282] [<ffffffffa13e8143>] ? em28xx_register_extension+0x23/0x190 [em28xx] [11009.908285] [<ffffffff81237d71>] ? trace_hardirqs_off_caller+0x21/0x290 [11009.908289] [<ffffffff8123ff56>] ? trace_hardirqs_on_caller+0x16/0x590 [11009.908292] [<ffffffff812404dd>] ? trace_hardirqs_on+0xd/0x10 [11009.908296] [<ffffffffa13e8143>] ? em28xx_register_extension+0x23/0x190 [em28xx] [11009.908299] [<ffffffff822dcbb0>] ? mutex_trylock+0x400/0x400 [11009.908302] [<ffffffff810021a1>] ? do_one_initcall+0x131/0x300 [11009.908306] [<ffffffff81296dc7>] ? call_rcu_sched+0x17/0x20 [11009.908309] [<ffffffff8159e708>] ? put_object+0x48/0x70 [11009.908314] [<ffffffffa1579f11>] em28xx_dvb_init+0x81/0x8a [em28xx_dvb] [11009.908317] [<ffffffffa13e81f9>] em28xx_register_extension+0xd9/0x190 [em28xx] [11009.908320] [<ffffffffa0150000>] ? 0xffffffffa0150000 [11009.908324] [<ffffffffa0150010>] em28xx_dvb_register+0x10/0x1000 [em28xx_dvb] [11009.908327] [<ffffffff810021b1>] do_one_initcall+0x141/0x300 [11009.908330] [<ffffffff81002070>] ? try_to_run_init_process+0x40/0x40 [11009.908333] [<ffffffff8123ff56>] ? trace_hardirqs_on_caller+0x16/0x590 [11009.908337] [<ffffffff8155e926>] ? kasan_unpoison_shadow+0x36/0x50 [11009.908340] [<ffffffff8155e926>] ? kasan_unpoison_shadow+0x36/0x50 [11009.908343] [<ffffffff8155e926>] ? kasan_unpoison_shadow+0x36/0x50 [11009.908346] [<ffffffff8155ea37>] ? __asan_register_globals+0x87/0xa0 [11009.908350] [<ffffffff8144da7b>] do_init_module+0x1d0/0x5ad [11009.908353] [<ffffffff812f2626>] load_module+0x6666/0x9ba0 [11009.908356] [<ffffffff812e9c90>] ? symbol_put_addr+0x50/0x50 [11009.908361] [<ffffffffa1580037>] ? em28xx_dvb_init.part.3+0x5989/0x5cf4 [em28xx_dvb] [11009.908366] [<ffffffff812ebfc0>] ? module_frob_arch_sections+0x20/0x20 [11009.908369] [<ffffffff815bc940>] ? open_exec+0x50/0x50 [11009.908374] [<ffffffff811671bb>] ? ns_capable+0x5b/0xd0 [11009.908377] [<ffffffff812f5e58>] SyS_finit_module+0x108/0x130 [11009.908379] [<ffffffff812f5d50>] ? SyS_init_module+0x1f0/0x1f0 [11009.908383] [<ffffffff81004044>] ? lockdep_sys_exit_thunk+0x12/0x14 [11009.908394] [<ffffffff822e6936>] entry_SYSCALL_64_fastpath+0x16/0x76 [11009.908396] Memory state around the buggy address: [11009.908398] ffff8803bd78aa00: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc [11009.908401] ffff8803bd78aa80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [11009.908403] >ffff8803bd78ab00: fc fc fc fc fc fc fc fc 00 00 fc fc fc fc fc fc [11009.908405] ^ [11009.908407] ffff8803bd78ab80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [11009.908409] ffff8803bd78ac00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [11009.908411] ==================================================================
In order to avoid it, let's set the cached value of the firmware name to NULL after freeing it. While here, return an error if the memory allocation fails.
--- drivers/media/tuners/tuner-xc2028.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/tuners/tuner-xc2028.c +3 -2
@@ -1393,7 +1393,7 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)struct xc2028_ctrl *p = priv_cfg;int rc =0 ; -tuner_dbg ("%s called\n" , __func__); +tuner_dbg ("%s called, fname = %p\n" , __func__, priv->ctrl.fname);mutex_lock (&priv->lock);
@@ -1403,11 +1403,12 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)* in order to avoid troubles during device release. */ kfree (priv->ctrl.fname); + priv->ctrl.fname =NULL ;memcpy (&priv->ctrl, p,sizeof (priv->ctrl));if (p->fname) { priv->ctrl.fname =kstrdup (p->fname,GFP_KERNEL );if (priv->ctrl.fname ==NULL ) - rc = -ENOMEM ; +return -ENOMEM ; }/*
Signature · 1 line
2.5.0
PATCH 4/13 v4l2-mc.h: move tuner PAD definitions to this new header
In reply to Mauro Carvalho ChehabThe customer PC hardware can be shipped with lots of different configurations, as vendors use to replace some of the chips on their hardware along the time. All drivers that support such devices are prepared to handle the hardware differences, using their own auto-probing logic.
They do it in a way that number of inputs and outputs for a given hardware type doesn't change.
Now that we're adding media controller capabilities to those drivers, we need to standardize the number of inputs and outputs for each hardware type, as we want to have a generic function at the V4L2 core that would create the links for the entities that are expected on such hardware.
Such standard is already there for tuners, but tuner.h is not the best place to store such data, as we'll need to add definitions also for analog TV demodulators.
Also, we'll need a place to put a set of MC handling functions. So, let's create a v4l2-mc.h to store such kind of definitions.
--- Documentation/DocBook/device-drivers.tmpl | 1 + include/media/tuner.h | 24 +------------------ include/media/v4l2-mc.h | 38 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 include/media/v4l2-mc.h
Documentation/DocBook/device-drivers.tmpl +1 -0
@@ -229,6 +229,7 @@ X!Isound/sound_firmware.c !Iinclude/media/v4l2-dv-timings.h !Iinclude/media/v4l2-event.h !Iinclude/media/v4l2-flash-led-class.h +!Iinclude/media/v4l2-mc.h !Iinclude/media/v4l2-mediabus.h !Iinclude/media/v4l2-mem2mem.h !Iinclude/media/v4l2-of.h
include/media/tuner.h +1 -23
@@ -20,29 +20,7 @@#ifdef __KERNEL__#include <linux/videodev2.h> - -/** -* enum tuner_pad_index - tuner pad index -* -* @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a -* RF connector entity. -* @TUNER_PAD_OUTPUT: Tuner output pad. This is actually more complex than -* a single pad output, as, in addition to luminance and -* chrominance IF a tuner may have internally an -* audio decoder (like xc3028) or it may produce an audio -* IF that will be used by an audio decoder like msp34xx. -* It may also have an IF-PLL demodulator on it, like -* tuners with tda9887. Yet, currently, we don't need to -* represent all the dirty details, as this is transparent -* for the V4L2 API usage. So, let's represent all kinds -* of different outputs as a single source pad. -* @TUNER_NUM_PADS: Number of pads of the tuner. -*/ -enum tuner_pad_index { -TUNER_PAD_RF_INPUT , -TUNER_PAD_OUTPUT , -TUNER_NUM_PADS -}; +#include <media/v4l2-mc.h> #define ADDR_UNSET (255)
include/media/v4l2-mc.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* v4l2-mc.h - Media Controller V4L2 types and prototypes +* +* Copyright (C) 2016 Mauro Carvalho Chehab <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +/** +* enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER +* +* @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a +* RF connector entity. +* @TUNER_PAD_OUTPUT: Tuner output pad. This is actually more complex than +* a single pad output, as, in addition to luminance and +* chrominance IF a tuner may have internally an +* audio decoder (like xc3028) or it may produce an audio +* IF that will be used by an audio decoder like msp34xx. +* It may also have an IF-PLL demodulator on it, like +* tuners with tda9887. Yet, currently, we don't need to +* represent all the dirty details, as this is transparent +* for the V4L2 API usage. So, let's represent all kinds +* of different outputs as a single source pad. +* @TUNER_NUM_PADS: Number of pads of the tuner. +*/ +enum tuner_pad_index { +TUNER_PAD_RF_INPUT , +TUNER_PAD_OUTPUT , +TUNER_NUM_PADS +};
Signature · 1 line
2.5.0
PATCH 5/13 v4l2-mc.h: Split audio from baseband output
In reply to Mauro Carvalho ChehabAnalog TV tuners have a separate output pad for the audio IF or audio sampled data. This pad is connected to a different chipset.
Add an extra pad for it and improve the documentation.
--- drivers/media/v4l2-core/tuner-core.c | 1 + include/media/v4l2-mc.h | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-)
drivers/media/v4l2-core/tuner-core.c +1 -0
@@ -698,6 +698,7 @@ register_client:#if defined(CONFIG_MEDIA_CONTROLLER ) t->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; t->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + t->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; t->sd.entity.function =MEDIA_ENT_F_TUNER ; t->sd.entity.name = t->name;
include/media/v4l2-mc.h +17 -11
@@ -19,20 +19,26 @@* * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a * RF connector entity. -* @TUNER_PAD_OUTPUT: Tuner output pad. This is actually more complex than -* a single pad output, as, in addition to luminance and -* chrominance IF a tuner may have internally an -* audio decoder (like xc3028) or it may produce an audio -* IF that will be used by an audio decoder like msp34xx. -* It may also have an IF-PLL demodulator on it, like -* tuners with tda9887. Yet, currently, we don't need to -* represent all the dirty details, as this is transparent -* for the V4L2 API usage. So, let's represent all kinds -* of different outputs as a single source pad. +* @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video +* chrominance and luminance or the hole bandwidth +* of the signal converted to an Intermediate Frequency +* (IF) or to baseband (on zero-IF tuners). +* @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode +* analog TV signals have an extra pad for audio output. +* Old tuners use an analog stage with a saw filter for +* the audio IF frequency. The output of the pad is, in +* this case, the audio IF, with should be decoded either +* by the bridge chipset (that's the case of cx2388x +* chipsets) or may require an external IF sound +* processor, like msp34xx. On modern silicon tuners, +* the audio IF decoder is usually incorporated at the +* tuner. On such case, the output of this pad is an +* audio sampled data. * @TUNER_NUM_PADS: Number of pads of the tuner. */ enum tuner_pad_index {TUNER_PAD_RF_INPUT ,TUNER_PAD_OUTPUT , +TUNER_PAD_AUD_OUT ,TUNER_NUM_PADS -}; +};
Signature · 1 line
2.5.0
PATCH 7/13 v4l2-mc.h Add pads for audio and video IF-PLL decoders
In reply to Mauro Carvalho ChehabThe audio and video IF-PLL decoders have one sink and one source PAD. Add macro names for those pads and describe what kind of signals are represented at such pads.
--- drivers/media/v4l2-core/tuner-core.c | 27 +++++++++++++++++++++------ include/media/v4l2-mc.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 6 deletions(-)
drivers/media/v4l2-core/tuner-core.c +21 -6
@@ -696,17 +696,32 @@ static int tuner_probe(struct i2c_client *client,/* Should be just before return */ register_client:#if defined(CONFIG_MEDIA_CONTROLLER ) - t->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - t->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; - t->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - t->sd.entity.function =MEDIA_ENT_F_TUNER ; t->sd.entity.name = t->name; +/* +* Handle the special case where the tuner has actually +* two stages: the PLL to tune into a frequency and the +* IF-PLL demodulator (tda988x). +*/ +if (t->type ==TUNER_TDA9887 ) { + t->pad[IF_VID_DEC_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + t->pad[IF_VID_DEC_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + ret =media_entity_pads_init (&t->sd.entity, +IF_VID_DEC_PAD_NUM_PADS , + &t->pad[0 ]); + t->sd.entity.function =MEDIA_ENT_F_IF_VID_DECODER ; + }else { + t->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + t->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + t->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + ret =media_entity_pads_init (&t->sd.entity,TUNER_NUM_PADS , + &t->pad[0 ]); + t->sd.entity.function =MEDIA_ENT_F_TUNER ; + } - ret =media_entity_pads_init (&t->sd.entity,TUNER_NUM_PADS , &t->pad[0 ]);if (ret <0 ) {tuner_err ("failed to initialize media entity!\n" );kfree (t); -return -ENODEV ; +return ret; }#endif /* Sets a default mode */
include/media/v4l2-mc.h +32 -0
@@ -42,3 +42,35 @@ enum tuner_pad_index {TUNER_PAD_AUD_OUT , TUNER_NUM_PADS }; + +/** +* enum if_vid_dec_index - video IF-PLL pad index for +* MEDIA_ENT_F_IF_VID_DECODER +* +* @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad +* @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the +* video chrominance and luminance IF signals. +* @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL. +*/ +enum if_vid_dec_pad_index { +IF_VID_DEC_PAD_IF_INPUT , +IF_VID_DEC_PAD_OUT , +IF_VID_DEC_PAD_NUM_PADS +}; + +/** +* enum if_aud_dec_index - audio/sound IF-PLL pad index for +* MEDIA_ENT_F_IF_AUD_DECODER +* +* @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad +* @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the +* audio sampled stream data, usually connected +* to the bridge bus via an Inter-IC Sound (I2S) +* bus. +* @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL. +*/ +enum if_aud_dec_pad_index { +IF_AUD_DEC_PAD_IF_INPUT , +IF_AUD_DEC_PAD_OUT , +IF_AUD_DEC_PAD_NUM_PADS +};
Signature · 1 line
2.5.0
PATCH 8/13 v4l2-mc: add analog TV demodulator pad index macros
In reply to Mauro Carvalho ChehabWe also need to standardize the PAD index macros for demods, as they all should look the same in a media graph.
--- include/media/v4l2-mc.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/media/v4l2-mc.h +15 -0
@@ -74,3 +74,18 @@ enum if_aud_dec_pad_index {IF_AUD_DEC_PAD_OUT , IF_AUD_DEC_PAD_NUM_PADS }; + +/** +* enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER +* +* @DEMOD_PAD_IF_INPUT: IF input sink pad. +* @DEMOD_PAD_VID_OUT: Video output source pad. +* @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad. +* @DEMOD_NUM_PADS: Maximum number of output pads. +*/ +enum demod_pad_index { +DEMOD_PAD_IF_INPUT , +DEMOD_PAD_VID_OUT , +DEMOD_PAD_VBI_OUT , +DEMOD_NUM_PADS +};
Signature · 1 line
2.5.0
PATCH 10/13 msp3400: initialize MC data
In reply to Mauro Carvalho ChehabAdd pads and set the device type when used with the media controller.
--- drivers/media/i2c/msp3400-driver.c | 14 ++++++++++++++ drivers/media/i2c/msp3400-driver.h | 5 +++++ 2 files changed, 19 insertions(+)
drivers/media/i2c/msp3400-driver.c +14 -0
@@ -688,6 +688,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)int msp_revision;int msp_product, msp_prod_hi, msp_prod_lo;int msp_rom; +#if defined(CONFIG_MEDIA_CONTROLLER ) +int ret; +#endif if (!id)strlcpy (client->name,"msp3400" ,sizeof (client->name));
@@ -704,6 +707,17 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) sd = &state->sd;v4l2_i2c_subdev_init (sd, client, &msp_ops); +#if defined(CONFIG_MEDIA_CONTROLLER ) + state->pads[IF_AUD_DEC_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[IF_AUD_DEC_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + + sd->entity.function =MEDIA_ENT_F_IF_AUD_DECODER ; + + ret =media_entity_pads_init (&sd->entity,2 , state->pads); +if (ret <0 ) +return ret; +#endif + state->v4l2_std =V4L2_STD_NTSC ; state->detected_std =V4L2_STD_ALL ; state->audmode =V4L2_TUNER_MODE_STEREO ;
drivers/media/i2c/msp3400-driver.h +5 -0
@@ -7,6 +7,7 @@#include <media/drv-intf/msp3400.h> #include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> +#include <media/v4l2-mc.h> /* ---------------------------------------------------------------------- */
@@ -102,6 +103,10 @@ struct msp_state {wait_queue_head_t wq; unsigned int restart:1; unsigned int watch_stereo:1; + +#if CONFIG_MEDIA_CONTROLLER +struct media_pad pads[IF_AUD_DEC_PAD_NUM_PADS ]; +#endif };static inline struct msp_state *to_state (struct v4l2_subdev *sd)
Signature · 1 line
2.5.0
PATCH 11/13 tvp5150: identify it as a MEDIA_ENT_F_ATV_DECODER
In reply to Mauro Carvalho ChehabThe tvp5150 is an analog TV decoder. Identify as such at the media graph, or otherwise devices using it would fail.
That avoids the following warning:
[ 1546.669139] usb 2-3.3: Entity type for entity tvp5150 5-005c was not initialized!
--- drivers/media/i2c/tvp5150.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/i2c/tvp5150.c +3 -0
@@ -1319,6 +1319,9 @@ static int tvp5150_probe(struct i2c_client *c, core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; core->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + + sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; + res =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , core->pads);if (res <0 )return res;
Signature · 1 line
2.5.0
PATCH 12/13 saa7115: initialize demod type and add the needed pads
In reply to Mauro Carvalho ChehabThe saa7115 driver is used on several em28xx-based devices. Now that we're about to add MC support to em28xx, we need to be sure that the saa711x demod will be properly mapped at MC.
--- drivers/media/i2c/saa7115.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/media/i2c/saa7115.c +19 -0
@@ -46,6 +46,7 @@#include <linux/videodev2.h> #include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> +#include <media/v4l2-mc.h> #include <media/i2c/saa7115.h> #include <asm/div64.h>
@@ -74,6 +75,9 @@ enum saa711x_model {struct saa711x_state {struct v4l2_subdev sd; +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad pads[DEMOD_NUM_PADS ]; +#endif struct v4l2_ctrl_handler hdl;struct {
@@ -1809,6 +1813,9 @@ static int saa711x_probe(struct i2c_client *client,struct saa7115_platform_data *pdata;int ident;char name[CHIP_VER_SIZE +1 ]; +#if defined(CONFIG_MEDIA_CONTROLLER ) +int ret; +#endif /* Check if the adapter supports the needed features */ if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_BYTE_DATA ))
@@ -1832,6 +1839,18 @@ static int saa711x_probe(struct i2c_client *client, sd = &state->sd;v4l2_i2c_subdev_init (sd, client, &saa711x_ops); +#if defined(CONFIG_MEDIA_CONTROLLER ) + state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + + sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; + + ret =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , state->pads); +if (ret <0 ) +return ret; +#endif +v4l_info (client,"%s found @ 0x%x (%s)\n" , name, client->addr <<1 , client->adapter->name); hdl = &state->hdl;
Signature · 1 line
2.5.0
PATCH 9/13 tvp5150: create the expected number of pads
In reply to Mauro Carvalho ChehabThe tvp5150 doesn't have just one pad. It has 3 ones:
- IF input
- Video output
- VBI output
Fix it and use the macros for the pad indexes.
--- drivers/media/i2c/tvp5150.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/media/i2c/tvp5150.c +8 -3
@@ -16,6 +16,7 @@#include <media/i2c/tvp5150.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-of.h> +#include <media/v4l2-mc.h> #include "tvp5150_reg.h"
@@ -37,7 +38,9 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");struct tvp5150 {struct v4l2_subdev sd; -struct media_pad pad; +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad pads[DEMOD_NUM_PADS ]; +#endif struct v4l2_ctrl_handler hdl;struct v4l2_rect rect;
@@ -1313,8 +1316,10 @@ static int tvp5150_probe(struct i2c_client *c, sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;#if defined(CONFIG_MEDIA_CONTROLLER ) - core->pad.flags =MEDIA_PAD_FL_SOURCE ; - res =media_entity_pads_init (&sd->entity,1 , &core->pad); + core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + core->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + res =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , core->pads);if (res <0 )return res;#endif
Signature · 1 line
2.5.0
PATCH 3/13 tuner.h: rename TUNER_PAD_IF_OUTPUT to TUNER_PAD_OUTPUT
In reply to Mauro Carvalho ChehabThe output of a tuner is not only IF frequencies. They may also output audio on some of its pins. So, rename the PAD name to make it clearer and add a proper documentation about that at tuner.h.
No functional changes.
--- drivers/media/dvb-core/dvbdev.c | 2 +- drivers/media/usb/au0828/au0828-core.c | 2 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 2 +- drivers/media/v4l2-core/tuner-core.c | 2 +- include/media/tuner.h | 21 ++++++++++++++++++--- 6 files changed, 23 insertions(+), 8 deletions(-)
drivers/media/dvb-core/dvbdev.c +1 -1
@@ -661,7 +661,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,if (ntuner && ndemod) { ret =media_create_pad_links (mdev,MEDIA_ENT_F_TUNER , - tuner,TUNER_PAD_IF_OUTPUT , + tuner,TUNER_PAD_OUTPUT ,MEDIA_ENT_F_DTV_DEMOD , demod,0 ,MEDIA_LNK_FL_ENABLED , false);
drivers/media/usb/au0828/au0828-core.c +1 -1
@@ -276,7 +276,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)return -EINVAL ;if (tuner) { - ret =media_create_pad_link (tuner,TUNER_PAD_IF_OUTPUT , + ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , decoder,0 ,MEDIA_LNK_FL_ENABLED );if (ret)
drivers/media/usb/cx231xx/cx231xx-cards.c +1 -1
@@ -1259,7 +1259,7 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)return 0 ;if (tuner) { - ret =media_create_pad_link (tuner,TUNER_PAD_IF_OUTPUT , decoder,0 , + ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , decoder,0 ,MEDIA_LNK_FL_ENABLED );if (ret <0 )return ret;
drivers/media/usb/dvb-usb-v2/mxl111sf.c +1 -1
@@ -888,7 +888,7 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap) state->tuner.function =MEDIA_ENT_F_TUNER ; state->tuner.name ="mxl111sf tuner" ; state->tuner_pads[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->tuner_pads[TUNER_PAD_IF_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->tuner_pads[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_pads_init (&state->tuner,TUNER_NUM_PADS , state->tuner_pads);
drivers/media/v4l2-core/tuner-core.c +1 -1
@@ -697,7 +697,7 @@ static int tuner_probe(struct i2c_client *client, register_client:#if defined(CONFIG_MEDIA_CONTROLLER ) t->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - t->pad[TUNER_PAD_IF_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + t->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; t->sd.entity.function =MEDIA_ENT_F_TUNER ; t->sd.entity.name = t->name;
include/media/tuner.h +18 -3
@@ -21,11 +21,26 @@#include <linux/videodev2.h> -/* Tuner PADs */ -/* FIXME: is this the right place for it? */ +/** +* enum tuner_pad_index - tuner pad index +* +* @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a +* RF connector entity. +* @TUNER_PAD_OUTPUT: Tuner output pad. This is actually more complex than +* a single pad output, as, in addition to luminance and +* chrominance IF a tuner may have internally an +* audio decoder (like xc3028) or it may produce an audio +* IF that will be used by an audio decoder like msp34xx. +* It may also have an IF-PLL demodulator on it, like +* tuners with tda9887. Yet, currently, we don't need to +* represent all the dirty details, as this is transparent +* for the V4L2 API usage. So, let's represent all kinds +* of different outputs as a single source pad. +* @TUNER_NUM_PADS: Number of pads of the tuner. +*/ enum tuner_pad_index {TUNER_PAD_RF_INPUT , -TUNER_PAD_IF_OUTPUT , +TUNER_PAD_OUTPUT ,TUNER_NUM_PADS };
Signature · 1 line
2.5.0
PATCH 13/13 em28xx: add media controller support
In reply to Mauro Carvalho ChehabAdd the needed bits to make em28xx to create a media controller graph.
--- drivers/media/usb/em28xx/em28xx-cards.c | 55 ++++++- drivers/media/usb/em28xx/em28xx-dvb.c | 10 ++ drivers/media/usb/em28xx/em28xx-video.c | 271 +++++++++++++++++++++++++++++++- drivers/media/usb/em28xx/em28xx.h | 13 +- 4 files changed, 339 insertions(+), 10 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +53 -2
@@ -3012,6 +3012,48 @@ static void flush_request_modules(struct em28xx *dev)flush_work (&dev->request_module_wk); } +static int em28xx_media_device_init (struct em28xx *dev, +struct usb_device *udev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *mdev; + + mdev =kzalloc (sizeof (*mdev),GFP_KERNEL ); +if (!mdev) +return -ENOMEM ; + + mdev->dev = &udev->dev; + +if (!dev->name) +strlcpy (mdev->model,"unknown em28xx" ,sizeof (mdev->model)); +else +strlcpy (mdev->model, dev->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 ; + +media_device_init (mdev); + + dev->media_dev = mdev; +#endif +return 0 ; +} + +static void em28xx_unregister_media_device (struct em28xx *dev) +{ + +#ifdef CONFIG_MEDIA_CONTROLLER +if (dev->media_dev) { +media_device_unregister (dev->media_dev); +media_device_cleanup (dev->media_dev); +kfree (dev->media_dev); + dev->media_dev =NULL ; + } +#endif +} +/* * em28xx_release_resources() * unregisters the v4l2,i2c and usb devices
@@ -3023,6 +3065,8 @@ static void em28xx_release_resources(struct em28xx *dev)mutex_lock (&dev->lock); +em28xx_unregister_media_device (dev); +if (dev->def_i2c_bus)em28xx_i2c_unregister (dev,1 );em28xx_i2c_unregister (dev,0 );
@@ -3167,6 +3211,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,*/ snprintf (dev->name,sizeof (dev->name),"%s #%d" , chip_name, dev->devno); +em28xx_media_device_init (dev, udev); +if (dev->is_audio_only) { retval =em28xx_audio_setup (dev);if (retval)
@@ -3501,9 +3547,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,request_modules (dev); -/* Should be the last thing to do, to avoid newer udev's to -open the device before fully initializing it +/* +* Do it at the end, to reduce dynamic configuration changes during +* the device init. Yet, as request_modules() can be async, the +* topology will likely change after the load of the em28xx subdrivers. */ +#ifdef CONFIG_MEDIA_CONTROLLER + retval =media_device_register (dev->media_dev); +#endif return 0 ;
drivers/media/usb/em28xx/em28xx-dvb.c +10 -0
@@ -916,6 +916,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, dev->name, result); goto fail_adapter; } +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->adapter.mdev = dev->media_dev; +#endif /* Ensure all frontends negotiate bus access */ dvb->fe[0 ]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
@@ -994,8 +997,15 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,/* register network adapter */ dvb_net_init (&dvb->adapter, &dvb->net, &dvb->demux.dmx); + + result =dvb_create_media_graph (&dvb->adapter, false); +if (result <0 ) + goto fail_create_graph; +return 0 ; +fail_create_graph: +dvb_net_release (&dvb->net); fail_fe_conn: dvb->demux.dmx.remove_frontend (&dvb->demux.dmx, &dvb->fe_mem); fail_fe_mem:
drivers/media/usb/em28xx/em28xx-video.c +264 -7
307 lines not on this page · raw message
drivers/media/usb/em28xx/em28xx.h +12 -1
@@ -26,7 +26,7 @@#ifndef _EM28XX_H#define _EM28XX_H -#define EM28XX_VERSION "0.2.1" +#define EM28XX_VERSION "0.2.2"#define DRIVER_DESC "Empia em28xx device driver"#include <linux/workqueue.h>
@@ -552,6 +552,11 @@ struct em28xx_v4l2 {bool top_field;int vbi_read;unsigned int field_count; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad video_pad, vbi_pad; +struct media_entity *decoder; +#endif };struct em28xx_audio {
@@ -712,6 +717,12 @@ struct em28xx {/* Snapshot button input device */ char snapshot_button_path[30 ];/* path of the input dev */ struct input_dev *sbutton_input_dev; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *media_dev; +struct media_entity input_ent[MAX_EM28XX_INPUT ]; +struct media_pad input_pad[MAX_EM28XX_INPUT ]; +#endif };#define kref_to_dev (d) container_of(d, struct em28xx, ref)
Signature · 1 line
2.5.0
Em Fri, 29 Jan 2016 10:10:50 -0200
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 45 lines
This series add MC support to the em28xx driver. Among the hybrid TV USB drivers, this is the most complex one, as there are lots of different hardware options that are compatible with this driver.
Yet, it is used with only two analog TV demod drivers (tvp5150 and saa7115) and, optionally, one IF-PLL audio decoder (msp3400). It means that there aren't many I2C drivers that need to be touched.
The PCI drivers are a way more complex, as they may have audio processors and may use a wide range of other I2C drivers. So, it is wise to implement MC support at em28xx before those, as it helps to address some issues before extending MC to the wild.
The two patches in this series are actually unrelated to MC. The first one is a cleanup at em28xx, and the second patch fixes one KASAN error.
The next patches make the Media Controller aware of the existence of IF-PLL drivers, commonly found on older designs. They also standardize the pad index for tuners, IF-PLLs and demods.
Finally, MC support for tda9887, tvp5150, saa7115 and msp3400 is added, making those drivers to properly report the MC function supported by the driver and creating the source/sink pads for them.
The last patch finally add em28xx MC support.
I opted to not add any helper function for now at
v4l2-mc.c, putting all needed code at em28xx, because I didn't want to cause hard to find conflicts with Shuah's patches, that are touching the routines at au0828. After having Shuah patches merged, I'll work to move the generic code tov4l2-mc.c(yet to be created).This series was tested on the following devices:
Hauppauge HVR-950 (2040:6513):
https://mchehab.fedorapeople.org/mc-next-gen/hvr_950.pngHaupauge WinTV USB2 (2040:4200):
https://mchehab.fedorapeople.org/mc-next-gen/wintv_usb2.pngKWorld USB ATSC TV Stick UB435-Q V3 (1b80:e34c):
https://mchehab.fedorapeople.org/mc-next-gen/kworld_435q.pngPCTV 261e (2013:0258):
https://mchehab.fedorapeople.org/mc-next-gen/pctv_261e.png
Quoted 7 lines
PCTV 290e (2013:024f):
https://mchehab.fedorapeople.org/mc-next-gen/pctv_290e.pngPixelview PlayTV USB2 (eb1a:2821):
https://mchehab.fedorapeople.org/mc-next-gen/playtv_usb.png(an extra patch was needed for it to detect the tuner - I'll send it in separate)
Tested also on a pure S-Video/Composite capture card:
Terratec Grabster AV350 (0ccd:0084):
https://mchehab.fedorapeople.org/mc-next-gen/terratec_av350.png
This board actually have also a Scart interface, but switching between Scart and Video is done via a manual switch. So, the driver is actually unable to detect if the input is coming from Composite/S-Video or from scart.
Regards,
Mauro
PATCH v2 13/13 ] [media] em28xx: add media controller support
In reply to Mauro Carvalho ChehabAdd the needed bits to make em28xx to create a media controller graph.
--- drivers/media/usb/em28xx/em28xx-camera.c | 4 + drivers/media/usb/em28xx/em28xx-cards.c | 55 +++++- drivers/media/usb/em28xx/em28xx-dvb.c | 10 ++ drivers/media/usb/em28xx/em28xx-video.c | 294 ++++++++++++++++++++++++++++++- drivers/media/usb/em28xx/em28xx.h | 13 +- 5 files changed, 366 insertions(+), 10 deletions(-)
drivers/media/usb/em28xx/em28xx-camera.c +4 -0
@@ -64,6 +64,8 @@ static int em28xx_initialize_mt9m111(struct em28xx *dev)i2c_master_send (&dev->i2c_client[dev->def_i2c_bus], ®s[i][0 ],3 ); +/* FIXME: This won't be creating a sensor at the media graph */ +return 0 ; }
@@ -91,6 +93,8 @@ static int em28xx_initialize_mt9m001(struct em28xx *dev)i2c_master_send (&dev->i2c_client[dev->def_i2c_bus], ®s[i][0 ],3 ); +/* FIXME: This won't be creating a sensor at the media graph */ +return 0 ; }
drivers/media/usb/em28xx/em28xx-cards.c +53 -2
80 lines not on this page · raw message
drivers/media/usb/em28xx/em28xx-dvb.c +10 -0
@@ -916,6 +916,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, dev->name, result); goto fail_adapter; } +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->adapter.mdev = dev->media_dev; +#endif /* Ensure all frontends negotiate bus access */ dvb->fe[0 ]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
@@ -994,8 +997,15 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,/* register network adapter */ dvb_net_init (&dvb->adapter, &dvb->net, &dvb->demux.dmx); + + result =dvb_create_media_graph (&dvb->adapter, false); +if (result <0 ) + goto fail_create_graph; +return 0 ; +fail_create_graph: +dvb_net_release (&dvb->net); fail_fe_conn: dvb->demux.dmx.remove_frontend (&dvb->demux.dmx, &dvb->fe_mem); fail_fe_mem:
drivers/media/usb/em28xx/em28xx-video.c +287 -7
330 lines not on this page · raw message
drivers/media/usb/em28xx/em28xx.h +12 -1
@@ -26,7 +26,7 @@#ifndef _EM28XX_H#define _EM28XX_H -#define EM28XX_VERSION "0.2.1" +#define EM28XX_VERSION "0.2.2"#define DRIVER_DESC "Empia em28xx device driver"#include <linux/workqueue.h>
@@ -552,6 +552,11 @@ struct em28xx_v4l2 {bool top_field;int vbi_read;unsigned int field_count; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad video_pad, vbi_pad; +struct media_entity *decoder; +#endif };struct em28xx_audio {
@@ -712,6 +717,12 @@ struct em28xx {/* Snapshot button input device */ char snapshot_button_path[30 ];/* path of the input dev */ struct input_dev *sbutton_input_dev; + +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_device *media_dev; +struct media_entity input_ent[MAX_EM28XX_INPUT ]; +struct media_pad input_pad[MAX_EM28XX_INPUT ]; +#endif };#define kref_to_dev (d) container_of(d, struct em28xx, ref)
Signature · 1 line
2.5.0
Em Fri, 29 Jan 2016 10:37:40 -0200
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 58 lines
Em Fri, 29 Jan 2016 10:10:50 -0200
Mauro Carvalho Chehab <[email protected]> escreveu:Quoted 45 lines
This series add MC support to the em28xx driver. Among the hybrid TV USB drivers, this is the most complex one, as there are lots of different hardware options that are compatible with this driver.
Yet, it is used with only two analog TV demod drivers (tvp5150 and saa7115) and, optionally, one IF-PLL audio decoder (msp3400). It means that there aren't many I2C drivers that need to be touched.
The PCI drivers are a way more complex, as they may have audio processors and may use a wide range of other I2C drivers. So, it is wise to implement MC support at em28xx before those, as it helps to address some issues before extending MC to the wild.
The two patches in this series are actually unrelated to MC. The first one is a cleanup at em28xx, and the second patch fixes one KASAN error.
The next patches make the Media Controller aware of the existence of IF-PLL drivers, commonly found on older designs. They also standardize the pad index for tuners, IF-PLLs and demods.
Finally, MC support for tda9887, tvp5150, saa7115 and msp3400 is added, making those drivers to properly report the MC function supported by the driver and creating the source/sink pads for them.
The last patch finally add em28xx MC support.
I opted to not add any helper function for now at
v4l2-mc.c, putting all needed code at em28xx, because I didn't want to cause hard to find conflicts with Shuah's patches, that are touching the routines at au0828. After having Shuah patches merged, I'll work to move the generic code tov4l2-mc.c(yet to be created).This series was tested on the following devices:
Hauppauge HVR-950 (2040:6513):
https://mchehab.fedorapeople.org/mc-next-gen/hvr_950.pngHaupauge WinTV USB2 (2040:4200):
https://mchehab.fedorapeople.org/mc-next-gen/wintv_usb2.pngKWorld USB ATSC TV Stick UB435-Q V3 (1b80:e34c):
https://mchehab.fedorapeople.org/mc-next-gen/kworld_435q.pngPCTV 261e (2013:0258):
https://mchehab.fedorapeople.org/mc-next-gen/pctv_261e.pngQuoted 7 lines
PCTV 290e (2013:024f):
https://mchehab.fedorapeople.org/mc-next-gen/pctv_290e.pngPixelview PlayTV USB2 (eb1a:2821):
https://mchehab.fedorapeople.org/mc-next-gen/playtv_usb.png(an extra patch was needed for it to detect the tuner - I'll send it in separate)
Tested also on a pure S-Video/Composite capture card:
Quoted 7 lines
Terratec Grabster AV350 (0ccd:0084):
https://mchehab.fedorapeople.org/mc-next-gen/terratec_av350.pngThis board actually have also a Scart interface, but switching between Scart and Video is done via a manual switch. So, the driver is actually unable to detect if the input is coming from Composite/S-Video or from scart.
Tested also at:
Terratec Grabby (0ccd:0096):
https://mchehab.fedorapeople.org/mc-next-gen/terratec_grabby.png
Silvercrest Webcam (eb1a:2820):
https://mchehab.fedorapeople.org/mc-next-gen/silvercrest.png
Webcam support was added on [PATCH v2 13/13].
Terratec Cinergy HTC(0ccd:00b2):
https://mchehab.fedorapeople.org/mc-next-gen/terratec_cinergy_htc.png
All patches needed for the above devices to work properly are at:
https://git.linuxtv.org/mchehab/experimental.git/log/?h=mc_em28xx
Regards,
Mauro
Re: [PATCH 09/13] [media] tvp5150: create the expected number of pads
In reply to Mauro Carvalho ChehabHello Mauro,
Quoted 39 lines · Mauro Carvalho Chehab
The tvp5150 doesn't have just one pad. It has 3 ones:
- IF input
- Video output
- VBI outputFix it and use the macros for the pad indexes.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/i2c/tvp5150.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/media/i2c/tvp5150.c +4
-1@@ -16,6 +16,7 @@#include <media/i2c/tvp5150.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-of.h> +#include <media/v4l2-mc.h> #include "tvp5150_reg.h" @@ -37,7 +38,9 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");struct tvp5150 {struct v4l2_subdev sd; -struct media_pad pad; +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_pad pads[DEMOD_NUM_PADS ]; +#endif struct v4l2_ctrl_handler hdl;struct v4l2_rect rect;@@ -1313,8 +1316,10 @@ static int tvp5150_probe(struct i2c_client *c, sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;
drivers/media/i2c/tvp5150.c static int tvp5150_probe(struct i2c_client *c, · line 1325
Quoted 10 lines
drivers/media/i2c/tvp5150.c +4
-2#if defined(CONFIG_MEDIA_CONTROLLER ) - core->pad.flags =MEDIA_PAD_FL_SOURCE ; - res =media_entity_pads_init (&sd->entity,1 , &core->pad); + core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + core->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + res =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , core->pads);if (res <0 )return res;#endif
The patch looks good to me.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America
Re: [PATCH 11/13] [media] tvp5150: identify it as a MEDIA_ENT_F_ATV_DECODER
In reply to Mauro Carvalho ChehabHello Mauro,
Quoted 17 lines · Mauro Carvalho Chehab
The tvp5150 is an analog TV decoder. Identify as such at the media graph, or otherwise devices using it would fail.
That avoids the following warning:
[ 1546.669139] usb 2-3.3: Entity type for entity tvp5150 5-005c was not initialized!Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/i2c/tvp5150.c | 3 +++ 1 file changed, 3 insertions(+)drivers/media/i2c/tvp5150.c +0
-0
drivers/media/i2c/tvp5150.c static int tvp5150_probe(struct i2c_client *c, · line 1327
Quoted 9 lines
drivers/media/i2c/tvp5150.c +3
-0@@ -1319,6 +1319,9 @@ static int tvp5150_probe(struct i2c_client *c, core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; core->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + + sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; + res =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , core->pads);if (res <0 )return res;
Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America