diff options
Diffstat (limited to 'drivers/media')
325 files changed, 13159 insertions, 6697 deletions
diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c index be763150b8aa..c07b9db51b05 100644 --- a/drivers/media/common/cx2341x.c +++ b/drivers/media/common/cx2341x.c | |||
@@ -931,6 +931,35 @@ static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params) | |||
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | /* Check for correctness of the ctrl's value based on the data from | ||
935 | struct v4l2_queryctrl and the available menu items. Note that | ||
936 | menu_items may be NULL, in that case it is ignored. */ | ||
937 | static int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, | ||
938 | const char * const *menu_items) | ||
939 | { | ||
940 | if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED) | ||
941 | return -EINVAL; | ||
942 | if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED) | ||
943 | return -EBUSY; | ||
944 | if (qctrl->type == V4L2_CTRL_TYPE_STRING) | ||
945 | return 0; | ||
946 | if (qctrl->type == V4L2_CTRL_TYPE_BUTTON || | ||
947 | qctrl->type == V4L2_CTRL_TYPE_INTEGER64 || | ||
948 | qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) | ||
949 | return 0; | ||
950 | if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum) | ||
951 | return -ERANGE; | ||
952 | if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) { | ||
953 | if (menu_items[ctrl->value] == NULL || | ||
954 | menu_items[ctrl->value][0] == '\0') | ||
955 | return -EINVAL; | ||
956 | } | ||
957 | if (qctrl->type == V4L2_CTRL_TYPE_BITMASK && | ||
958 | (ctrl->value & ~qctrl->maximum)) | ||
959 | return -ERANGE; | ||
960 | return 0; | ||
961 | } | ||
962 | |||
934 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, | 963 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, |
935 | struct v4l2_ext_controls *ctrls, unsigned int cmd) | 964 | struct v4l2_ext_controls *ctrls, unsigned int cmd) |
936 | { | 965 | { |
diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c index 4418119cf707..1ff9f5323bc3 100644 --- a/drivers/media/common/saa7146/saa7146_core.c +++ b/drivers/media/common/saa7146/saa7146_core.c | |||
@@ -71,7 +71,7 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev, | |||
71 | if (saa7146_read(dev, MC2) & 2) | 71 | if (saa7146_read(dev, MC2) & 2) |
72 | break; | 72 | break; |
73 | if (err) { | 73 | if (err) { |
74 | pr_err("%s: %s timed out while waiting for registers getting programmed\n", | 74 | pr_debug("%s: %s timed out while waiting for registers getting programmed\n", |
75 | dev->name, __func__); | 75 | dev->name, __func__); |
76 | return -ETIMEDOUT; | 76 | return -ETIMEDOUT; |
77 | } | 77 | } |
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c index 273043ea8f47..35d0e887bd65 100644 --- a/drivers/media/common/siano/smsir.c +++ b/drivers/media/common/siano/smsir.c | |||
@@ -107,8 +107,7 @@ int sms_ir_init(struct smscore_device_t *coredev) | |||
107 | 107 | ||
108 | void sms_ir_exit(struct smscore_device_t *coredev) | 108 | void sms_ir_exit(struct smscore_device_t *coredev) |
109 | { | 109 | { |
110 | if (coredev->ir.dev) | 110 | rc_unregister_device(coredev->ir.dev); |
111 | rc_unregister_device(coredev->ir.dev); | ||
112 | 111 | ||
113 | sms_log(""); | 112 | sms_log(""); |
114 | } | 113 | } |
diff --git a/drivers/media/common/tveeprom.c b/drivers/media/common/tveeprom.c index c7dace671a9d..47da0378cad8 100644 --- a/drivers/media/common/tveeprom.c +++ b/drivers/media/common/tveeprom.c | |||
@@ -286,9 +286,17 @@ static const struct { | |||
286 | { TUNER_ABSENT, "Xceive XC5200C"}, | 286 | { TUNER_ABSENT, "Xceive XC5200C"}, |
287 | { TUNER_ABSENT, "NXP 18273"}, | 287 | { TUNER_ABSENT, "NXP 18273"}, |
288 | { TUNER_ABSENT, "Montage M88TS2022"}, | 288 | { TUNER_ABSENT, "Montage M88TS2022"}, |
289 | /* 180-189 */ | 289 | /* 180-188 */ |
290 | { TUNER_ABSENT, "NXP 18272M"}, | 290 | { TUNER_ABSENT, "NXP 18272M"}, |
291 | { TUNER_ABSENT, "NXP 18272S"}, | 291 | { TUNER_ABSENT, "NXP 18272S"}, |
292 | |||
293 | { TUNER_ABSENT, "Mirics MSi003"}, | ||
294 | { TUNER_ABSENT, "MaxLinear MxL256"}, | ||
295 | { TUNER_ABSENT, "SiLabs Si2158"}, | ||
296 | { TUNER_ABSENT, "SiLabs Si2178"}, | ||
297 | { TUNER_ABSENT, "SiLabs Si2157"}, | ||
298 | { TUNER_ABSENT, "SiLabs Si2177"}, | ||
299 | { TUNER_ABSENT, "ITE IT9137FN"}, | ||
292 | }; | 300 | }; |
293 | 301 | ||
294 | /* Use TVEEPROM_AUDPROC_INTERNAL for those audio 'chips' that are | 302 | /* Use TVEEPROM_AUDPROC_INTERNAL for those audio 'chips' that are |
@@ -351,6 +359,16 @@ static const struct { | |||
351 | { TVEEPROM_AUDPROC_INTERNAL, "CX23887" }, | 359 | { TVEEPROM_AUDPROC_INTERNAL, "CX23887" }, |
352 | { TVEEPROM_AUDPROC_INTERNAL, "SAA7164" }, | 360 | { TVEEPROM_AUDPROC_INTERNAL, "SAA7164" }, |
353 | { TVEEPROM_AUDPROC_INTERNAL, "AU8522" }, | 361 | { TVEEPROM_AUDPROC_INTERNAL, "AU8522" }, |
362 | /* 45-49 */ | ||
363 | { TVEEPROM_AUDPROC_INTERNAL, "AVF4910B" }, | ||
364 | { TVEEPROM_AUDPROC_INTERNAL, "SAA7231" }, | ||
365 | { TVEEPROM_AUDPROC_INTERNAL, "CX23102" }, | ||
366 | { TVEEPROM_AUDPROC_INTERNAL, "SAA7163" }, | ||
367 | { TVEEPROM_AUDPROC_OTHER, "AK4113" }, | ||
368 | /* 50-52 */ | ||
369 | { TVEEPROM_AUDPROC_OTHER, "CS5340" }, | ||
370 | { TVEEPROM_AUDPROC_OTHER, "CS8416" }, | ||
371 | { TVEEPROM_AUDPROC_OTHER, "CX20810" }, | ||
354 | }; | 372 | }; |
355 | 373 | ||
356 | /* This list is supplied by Hauppauge. Thanks! */ | 374 | /* This list is supplied by Hauppauge. Thanks! */ |
@@ -371,8 +389,12 @@ static const char *decoderIC[] = { | |||
371 | "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", | 389 | "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", |
372 | /* 35-39 */ | 390 | /* 35-39 */ |
373 | "SAA7131", "CX25837", "CX23887", "CX23885A", "CX23887A", | 391 | "SAA7131", "CX25837", "CX23887", "CX23885A", "CX23887A", |
374 | /* 40-42 */ | 392 | /* 40-44 */ |
375 | "SAA7164", "CX23885B", "AU8522" | 393 | "SAA7164", "CX23885B", "AU8522", "ADV7401", "AVF4910B", |
394 | /* 45-49 */ | ||
395 | "SAA7231", "CX23102", "SAA7163", "ADV7441A", "ADV7181C", | ||
396 | /* 50-53 */ | ||
397 | "CX25836", "TDA9955", "TDA19977", "ADV7842" | ||
376 | }; | 398 | }; |
377 | 399 | ||
378 | static int hasRadioTuner(int tunerType) | 400 | static int hasRadioTuner(int tunerType) |
@@ -548,10 +570,10 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, | |||
548 | tvee->serial_number = | 570 | tvee->serial_number = |
549 | eeprom_data[i+5] + | 571 | eeprom_data[i+5] + |
550 | (eeprom_data[i+6] << 8) + | 572 | (eeprom_data[i+6] << 8) + |
551 | (eeprom_data[i+7] << 16); | 573 | (eeprom_data[i+7] << 16)+ |
574 | (eeprom_data[i+8] << 24); | ||
552 | 575 | ||
553 | if ((eeprom_data[i + 8] & 0xf0) && | 576 | if (eeprom_data[i + 8] == 0xf0) { |
554 | (tvee->serial_number < 0xffffff)) { | ||
555 | tvee->MAC_address[0] = 0x00; | 577 | tvee->MAC_address[0] = 0x00; |
556 | tvee->MAC_address[1] = 0x0D; | 578 | tvee->MAC_address[1] = 0x0D; |
557 | tvee->MAC_address[2] = 0xFE; | 579 | tvee->MAC_address[2] = 0xFE; |
@@ -696,7 +718,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, | |||
696 | } | 718 | } |
697 | } | 719 | } |
698 | 720 | ||
699 | tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", | 721 | tveeprom_info("Hauppauge model %d, rev %s, serial# %u\n", |
700 | tvee->model, tvee->rev_str, tvee->serial_number); | 722 | tvee->model, tvee->rev_str, tvee->serial_number); |
701 | if (tvee->has_MAC_address == 1) | 723 | if (tvee->has_MAC_address == 1) |
702 | tveeprom_info("MAC address is %pM\n", tvee->MAC_address); | 724 | tveeprom_info("MAC address is %pM\n", tvee->MAC_address); |
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h index e07a84e7bc56..80ab8d0ff6e0 100644 --- a/drivers/media/dvb-core/dvb-usb-ids.h +++ b/drivers/media/dvb-core/dvb-usb-ids.h | |||
@@ -356,6 +356,7 @@ | |||
356 | #define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807 | 356 | #define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807 |
357 | #define USB_PID_SONY_PLAYTV 0x0003 | 357 | #define USB_PID_SONY_PLAYTV 0x0003 |
358 | #define USB_PID_MYGICA_D689 0xd811 | 358 | #define USB_PID_MYGICA_D689 0xd811 |
359 | #define USB_PID_MYGICA_T230 0xc688 | ||
359 | #define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011 | 360 | #define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011 |
360 | #define USB_PID_ELGATO_EYETV_DTT 0x0021 | 361 | #define USB_PID_ELGATO_EYETV_DTT 0x0021 |
361 | #define USB_PID_ELGATO_EYETV_DTT_2 0x003f | 362 | #define USB_PID_ELGATO_EYETV_DTT_2 0x003f |
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c index 059e6117f22b..e4041f074909 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c | |||
@@ -379,7 +379,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) | |||
379 | /* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */ | 379 | /* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */ |
380 | if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) { | 380 | if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) { |
381 | printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n", | 381 | printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n", |
382 | priv->ts_count, ts[0], ts[1] & TS_TEI >> 7, ts[3] & 0xC0 >> 6); | 382 | priv->ts_count, ts[0], |
383 | (ts[1] & TS_TEI) >> 7, | ||
384 | (ts[3] & TS_SC) >> 6); | ||
383 | 385 | ||
384 | /* Drop partly decoded SNDU, reset state, resync on PUSI. */ | 386 | /* Drop partly decoded SNDU, reset state, resync on PUSI. */ |
385 | if (priv->ule_skb) { | 387 | if (priv->ule_skb) { |
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig index 5a134547e325..6c75418222e2 100644 --- a/drivers/media/dvb-frontends/Kconfig +++ b/drivers/media/dvb-frontends/Kconfig | |||
@@ -648,12 +648,15 @@ config DVB_MB86A20S | |||
648 | A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator. | 648 | A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator. |
649 | Say Y when you want to support this frontend. | 649 | Say Y when you want to support this frontend. |
650 | 650 | ||
651 | comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends" | ||
652 | depends on DVB_CORE | ||
653 | |||
651 | config DVB_TC90522 | 654 | config DVB_TC90522 |
652 | tristate "Toshiba TC90522" | 655 | tristate "Toshiba TC90522" |
653 | depends on DVB_CORE && I2C | 656 | depends on DVB_CORE && I2C |
654 | default m if !MEDIA_SUBDRV_AUTOSELECT | 657 | default m if !MEDIA_SUBDRV_AUTOSELECT |
655 | help | 658 | help |
656 | A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator. | 659 | Toshiba TC90522 2xISDB-S 8PSK + 2xISDB-T OFDM demodulator. |
657 | Say Y when you want to support this frontend. | 660 | Say Y when you want to support this frontend. |
658 | 661 | ||
659 | comment "Digital terrestrial only tuners/PLL" | 662 | comment "Digital terrestrial only tuners/PLL" |
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c index 63a89c1c59ff..82ce47bdf5dc 100644 --- a/drivers/media/dvb-frontends/af9033.c +++ b/drivers/media/dvb-frontends/af9033.c | |||
@@ -291,6 +291,12 @@ static int af9033_init(struct dvb_frontend *fe) | |||
291 | if (clock_adc_lut[i].clock == dev->cfg.clock) | 291 | if (clock_adc_lut[i].clock == dev->cfg.clock) |
292 | break; | 292 | break; |
293 | } | 293 | } |
294 | if (i == ARRAY_SIZE(clock_adc_lut)) { | ||
295 | dev_err(&dev->client->dev, | ||
296 | "Couldn't find ADC config for clock=%d\n", | ||
297 | dev->cfg.clock); | ||
298 | goto err; | ||
299 | } | ||
294 | 300 | ||
295 | adc_cw = af9033_div(dev, clock_adc_lut[i].adc, 1000000ul, 19ul); | 301 | adc_cw = af9033_div(dev, clock_adc_lut[i].adc, 1000000ul, 19ul); |
296 | buf[0] = (adc_cw >> 0) & 0xff; | 302 | buf[0] = (adc_cw >> 0) & 0xff; |
@@ -580,7 +586,15 @@ static int af9033_set_frontend(struct dvb_frontend *fe) | |||
580 | break; | 586 | break; |
581 | } | 587 | } |
582 | } | 588 | } |
583 | ret = af9033_wr_regs(dev, 0x800001, | 589 | if (i == ARRAY_SIZE(coeff_lut)) { |
590 | dev_err(&dev->client->dev, | ||
591 | "Couldn't find LUT config for clock=%d\n", | ||
592 | dev->cfg.clock); | ||
593 | ret = -EINVAL; | ||
594 | goto err; | ||
595 | } | ||
596 | |||
597 | ret = af9033_wr_regs(dev, 0x800001, | ||
584 | coeff_lut[i].val, sizeof(coeff_lut[i].val)); | 598 | coeff_lut[i].val, sizeof(coeff_lut[i].val)); |
585 | } | 599 | } |
586 | 600 | ||
@@ -592,6 +606,13 @@ static int af9033_set_frontend(struct dvb_frontend *fe) | |||
592 | if (clock_adc_lut[i].clock == dev->cfg.clock) | 606 | if (clock_adc_lut[i].clock == dev->cfg.clock) |
593 | break; | 607 | break; |
594 | } | 608 | } |
609 | if (i == ARRAY_SIZE(clock_adc_lut)) { | ||
610 | dev_err(&dev->client->dev, | ||
611 | "Couldn't find ADC clock for clock=%d\n", | ||
612 | dev->cfg.clock); | ||
613 | ret = -EINVAL; | ||
614 | goto err; | ||
615 | } | ||
595 | adc_freq = clock_adc_lut[i].adc; | 616 | adc_freq = clock_adc_lut[i].adc; |
596 | 617 | ||
597 | /* get used IF frequency */ | 618 | /* get used IF frequency */ |
@@ -849,29 +870,97 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
849 | { | 870 | { |
850 | struct af9033_dev *dev = fe->demodulator_priv; | 871 | struct af9033_dev *dev = fe->demodulator_priv; |
851 | struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; | 872 | struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; |
873 | int ret; | ||
874 | u8 u8tmp; | ||
852 | 875 | ||
853 | /* use DVBv5 CNR */ | 876 | /* use DVBv5 CNR */ |
854 | if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) | 877 | if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) { |
855 | *snr = div_s64(c->cnr.stat[0].svalue, 100); /* 1000x => 10x */ | 878 | /* Return 0.1 dB for AF9030 and 0-0xffff for IT9130. */ |
856 | else | 879 | if (dev->is_af9035) { |
880 | /* 1000x => 10x (0.1 dB) */ | ||
881 | *snr = div_s64(c->cnr.stat[0].svalue, 100); | ||
882 | } else { | ||
883 | /* 1000x => 1x (1 dB) */ | ||
884 | *snr = div_s64(c->cnr.stat[0].svalue, 1000); | ||
885 | |||
886 | /* read current modulation */ | ||
887 | ret = af9033_rd_reg(dev, 0x80f903, &u8tmp); | ||
888 | if (ret) | ||
889 | goto err; | ||
890 | |||
891 | /* scale value to 0x0000-0xffff */ | ||
892 | switch ((u8tmp >> 0) & 3) { | ||
893 | case 0: | ||
894 | *snr = *snr * 0xffff / 23; | ||
895 | break; | ||
896 | case 1: | ||
897 | *snr = *snr * 0xffff / 26; | ||
898 | break; | ||
899 | case 2: | ||
900 | *snr = *snr * 0xffff / 32; | ||
901 | break; | ||
902 | default: | ||
903 | goto err; | ||
904 | } | ||
905 | } | ||
906 | } else { | ||
857 | *snr = 0; | 907 | *snr = 0; |
908 | } | ||
858 | 909 | ||
859 | return 0; | 910 | return 0; |
911 | |||
912 | err: | ||
913 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
914 | |||
915 | return ret; | ||
860 | } | 916 | } |
861 | 917 | ||
862 | static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | 918 | static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
863 | { | 919 | { |
864 | struct af9033_dev *dev = fe->demodulator_priv; | 920 | struct af9033_dev *dev = fe->demodulator_priv; |
865 | int ret; | 921 | struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; |
866 | u8 strength2; | 922 | int ret, tmp, power_real; |
923 | u8 u8tmp, gain_offset, buf[7]; | ||
867 | 924 | ||
868 | /* read signal strength of 0-100 scale */ | 925 | if (dev->is_af9035) { |
869 | ret = af9033_rd_reg(dev, 0x800048, &strength2); | 926 | /* read signal strength of 0-100 scale */ |
870 | if (ret < 0) | 927 | ret = af9033_rd_reg(dev, 0x800048, &u8tmp); |
871 | goto err; | 928 | if (ret < 0) |
929 | goto err; | ||
930 | |||
931 | /* scale value to 0x0000-0xffff */ | ||
932 | *strength = u8tmp * 0xffff / 100; | ||
933 | } else { | ||
934 | ret = af9033_rd_reg(dev, 0x8000f7, &u8tmp); | ||
935 | if (ret < 0) | ||
936 | goto err; | ||
937 | |||
938 | ret = af9033_rd_regs(dev, 0x80f900, buf, 7); | ||
939 | if (ret < 0) | ||
940 | goto err; | ||
941 | |||
942 | if (c->frequency <= 300000000) | ||
943 | gain_offset = 7; /* VHF */ | ||
944 | else | ||
945 | gain_offset = 4; /* UHF */ | ||
946 | |||
947 | power_real = (u8tmp - 100 - gain_offset) - | ||
948 | power_reference[((buf[3] >> 0) & 3)][((buf[6] >> 0) & 7)]; | ||
949 | |||
950 | if (power_real < -15) | ||
951 | tmp = 0; | ||
952 | else if ((power_real >= -15) && (power_real < 0)) | ||
953 | tmp = (2 * (power_real + 15)) / 3; | ||
954 | else if ((power_real >= 0) && (power_real < 20)) | ||
955 | tmp = 4 * power_real + 10; | ||
956 | else if ((power_real >= 20) && (power_real < 35)) | ||
957 | tmp = (2 * (power_real - 20)) / 3 + 90; | ||
958 | else | ||
959 | tmp = 100; | ||
872 | 960 | ||
873 | /* scale value to 0x0000-0xffff */ | 961 | /* scale value to 0x0000-0xffff */ |
874 | *strength = strength2 * 0xffff / 100; | 962 | *strength = tmp * 0xffff / 100; |
963 | } | ||
875 | 964 | ||
876 | return 0; | 965 | return 0; |
877 | 966 | ||
@@ -1011,6 +1100,33 @@ static void af9033_stat_work(struct work_struct *work) | |||
1011 | 1100 | ||
1012 | snr_val = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0); | 1101 | snr_val = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0); |
1013 | 1102 | ||
1103 | /* read superframe number */ | ||
1104 | ret = af9033_rd_reg(dev, 0x80f78b, &u8tmp); | ||
1105 | if (ret) | ||
1106 | goto err; | ||
1107 | |||
1108 | if (u8tmp) | ||
1109 | snr_val /= u8tmp; | ||
1110 | |||
1111 | /* read current transmission mode */ | ||
1112 | ret = af9033_rd_reg(dev, 0x80f900, &u8tmp); | ||
1113 | if (ret) | ||
1114 | goto err; | ||
1115 | |||
1116 | switch ((u8tmp >> 0) & 3) { | ||
1117 | case 0: | ||
1118 | snr_val *= 4; | ||
1119 | break; | ||
1120 | case 1: | ||
1121 | snr_val *= 1; | ||
1122 | break; | ||
1123 | case 2: | ||
1124 | snr_val *= 2; | ||
1125 | break; | ||
1126 | default: | ||
1127 | goto err_schedule_delayed_work; | ||
1128 | } | ||
1129 | |||
1014 | /* read current modulation */ | 1130 | /* read current modulation */ |
1015 | ret = af9033_rd_reg(dev, 0x80f903, &u8tmp); | 1131 | ret = af9033_rd_reg(dev, 0x80f903, &u8tmp); |
1016 | if (ret) | 1132 | if (ret) |
diff --git a/drivers/media/dvb-frontends/af9033_priv.h b/drivers/media/dvb-frontends/af9033_priv.h index c12c92cb5855..8e23275148ed 100644 --- a/drivers/media/dvb-frontends/af9033_priv.h +++ b/drivers/media/dvb-frontends/af9033_priv.h | |||
@@ -181,7 +181,10 @@ static const struct val_snr qam64_snr_lut[] = { | |||
181 | { 0x05570d, 26 }, | 181 | { 0x05570d, 26 }, |
182 | { 0x059feb, 27 }, | 182 | { 0x059feb, 27 }, |
183 | { 0x05bf38, 28 }, | 183 | { 0x05bf38, 28 }, |
184 | { 0xffffff, 29 }, | 184 | { 0x05f78f, 29 }, |
185 | { 0x0612c3, 30 }, | ||
186 | { 0x0626be, 31 }, | ||
187 | { 0xffffff, 32 }, | ||
185 | }; | 188 | }; |
186 | 189 | ||
187 | static const struct reg_val ofsm_init[] = { | 190 | static const struct reg_val ofsm_init[] = { |
@@ -2051,4 +2054,10 @@ static const struct reg_val tuner_init_it9135_62[] = { | |||
2051 | { 0x80fd8b, 0x00 }, | 2054 | { 0x80fd8b, 0x00 }, |
2052 | }; | 2055 | }; |
2053 | 2056 | ||
2057 | /* NorDig power reference table */ | ||
2058 | static const int power_reference[][5] = { | ||
2059 | {-93, -91, -90, -89, -88}, /* QPSK 1/2 ~ 7/8 */ | ||
2060 | {-87, -85, -84, -83, -82}, /* 16QAM 1/2 ~ 7/8 */ | ||
2061 | {-82, -80, -78, -77, -76}, /* 64QAM 1/2 ~ 7/8 */ | ||
2062 | }; | ||
2054 | #endif /* AF9033_PRIV_H */ | 2063 | #endif /* AF9033_PRIV_H */ |
diff --git a/drivers/media/dvb-frontends/au8522_dig.c b/drivers/media/dvb-frontends/au8522_dig.c index a68974f6d708..5d06c99b0e97 100644 --- a/drivers/media/dvb-frontends/au8522_dig.c +++ b/drivers/media/dvb-frontends/au8522_dig.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "au8522_priv.h" | 29 | #include "au8522_priv.h" |
30 | 30 | ||
31 | static int debug; | 31 | static int debug; |
32 | static int zv_mode = 1; /* default to on */ | ||
32 | 33 | ||
33 | #define dprintk(arg...)\ | 34 | #define dprintk(arg...)\ |
34 | do { if (debug)\ | 35 | do { if (debug)\ |
@@ -469,6 +470,87 @@ static struct { | |||
469 | { 0x8526, 0x01 }, | 470 | { 0x8526, 0x01 }, |
470 | }; | 471 | }; |
471 | 472 | ||
473 | static struct { | ||
474 | u16 reg; | ||
475 | u16 data; | ||
476 | } QAM256_mod_tab_zv_mode[] = { | ||
477 | { 0x80a3, 0x09 }, | ||
478 | { 0x80a4, 0x00 }, | ||
479 | { 0x8081, 0xc4 }, | ||
480 | { 0x80a5, 0x40 }, | ||
481 | { 0x80b5, 0xfb }, | ||
482 | { 0x80b6, 0x8e }, | ||
483 | { 0x80b7, 0x39 }, | ||
484 | { 0x80aa, 0x77 }, | ||
485 | { 0x80ad, 0x77 }, | ||
486 | { 0x80a6, 0x67 }, | ||
487 | { 0x8262, 0x20 }, | ||
488 | { 0x821c, 0x30 }, | ||
489 | { 0x80b8, 0x3e }, | ||
490 | { 0x80b9, 0xf0 }, | ||
491 | { 0x80ba, 0x01 }, | ||
492 | { 0x80bb, 0x18 }, | ||
493 | { 0x80bc, 0x50 }, | ||
494 | { 0x80bd, 0x00 }, | ||
495 | { 0x80be, 0xea }, | ||
496 | { 0x80bf, 0xef }, | ||
497 | { 0x80c0, 0xfc }, | ||
498 | { 0x80c1, 0xbd }, | ||
499 | { 0x80c2, 0x1f }, | ||
500 | { 0x80c3, 0xfc }, | ||
501 | { 0x80c4, 0xdd }, | ||
502 | { 0x80c5, 0xaf }, | ||
503 | { 0x80c6, 0x00 }, | ||
504 | { 0x80c7, 0x38 }, | ||
505 | { 0x80c8, 0x30 }, | ||
506 | { 0x80c9, 0x05 }, | ||
507 | { 0x80ca, 0x4a }, | ||
508 | { 0x80cb, 0xd0 }, | ||
509 | { 0x80cc, 0x01 }, | ||
510 | { 0x80cd, 0xd9 }, | ||
511 | { 0x80ce, 0x6f }, | ||
512 | { 0x80cf, 0xf9 }, | ||
513 | { 0x80d0, 0x70 }, | ||
514 | { 0x80d1, 0xdf }, | ||
515 | { 0x80d2, 0xf7 }, | ||
516 | { 0x80d3, 0xc2 }, | ||
517 | { 0x80d4, 0xdf }, | ||
518 | { 0x80d5, 0x02 }, | ||
519 | { 0x80d6, 0x9a }, | ||
520 | { 0x80d7, 0xd0 }, | ||
521 | { 0x8250, 0x0d }, | ||
522 | { 0x8251, 0xcd }, | ||
523 | { 0x8252, 0xe0 }, | ||
524 | { 0x8253, 0x05 }, | ||
525 | { 0x8254, 0xa7 }, | ||
526 | { 0x8255, 0xff }, | ||
527 | { 0x8256, 0xed }, | ||
528 | { 0x8257, 0x5b }, | ||
529 | { 0x8258, 0xae }, | ||
530 | { 0x8259, 0xe6 }, | ||
531 | { 0x825a, 0x3d }, | ||
532 | { 0x825b, 0x0f }, | ||
533 | { 0x825c, 0x0d }, | ||
534 | { 0x825d, 0xea }, | ||
535 | { 0x825e, 0xf2 }, | ||
536 | { 0x825f, 0x51 }, | ||
537 | { 0x8260, 0xf5 }, | ||
538 | { 0x8261, 0x06 }, | ||
539 | { 0x821a, 0x01 }, | ||
540 | { 0x8546, 0x40 }, | ||
541 | { 0x8210, 0x26 }, | ||
542 | { 0x8211, 0xf6 }, | ||
543 | { 0x8212, 0x84 }, | ||
544 | { 0x8213, 0x02 }, | ||
545 | { 0x8502, 0x01 }, | ||
546 | { 0x8121, 0x04 }, | ||
547 | { 0x8122, 0x04 }, | ||
548 | { 0x852e, 0x10 }, | ||
549 | { 0x80a4, 0xca }, | ||
550 | { 0x80a7, 0x40 }, | ||
551 | { 0x8526, 0x01 }, | ||
552 | }; | ||
553 | |||
472 | static int au8522_enable_modulation(struct dvb_frontend *fe, | 554 | static int au8522_enable_modulation(struct dvb_frontend *fe, |
473 | fe_modulation_t m) | 555 | fe_modulation_t m) |
474 | { | 556 | { |
@@ -495,12 +577,23 @@ static int au8522_enable_modulation(struct dvb_frontend *fe, | |||
495 | au8522_set_if(fe, state->config->qam_if); | 577 | au8522_set_if(fe, state->config->qam_if); |
496 | break; | 578 | break; |
497 | case QAM_256: | 579 | case QAM_256: |
498 | dprintk("%s() QAM 256\n", __func__); | 580 | if (zv_mode) { |
499 | for (i = 0; i < ARRAY_SIZE(QAM256_mod_tab); i++) | 581 | dprintk("%s() QAM 256 (zv_mode)\n", __func__); |
500 | au8522_writereg(state, | 582 | for (i = 0; i < ARRAY_SIZE(QAM256_mod_tab_zv_mode); i++) |
501 | QAM256_mod_tab[i].reg, | 583 | au8522_writereg(state, |
502 | QAM256_mod_tab[i].data); | 584 | QAM256_mod_tab_zv_mode[i].reg, |
503 | au8522_set_if(fe, state->config->qam_if); | 585 | QAM256_mod_tab_zv_mode[i].data); |
586 | au8522_set_if(fe, state->config->qam_if); | ||
587 | msleep(100); | ||
588 | au8522_writereg(state, 0x821a, 0x00); | ||
589 | } else { | ||
590 | dprintk("%s() QAM 256\n", __func__); | ||
591 | for (i = 0; i < ARRAY_SIZE(QAM256_mod_tab); i++) | ||
592 | au8522_writereg(state, | ||
593 | QAM256_mod_tab[i].reg, | ||
594 | QAM256_mod_tab[i].data); | ||
595 | au8522_set_if(fe, state->config->qam_if); | ||
596 | } | ||
504 | break; | 597 | break; |
505 | default: | 598 | default: |
506 | dprintk("%s() Invalid modulation\n", __func__); | 599 | dprintk("%s() Invalid modulation\n", __func__); |
@@ -537,7 +630,12 @@ static int au8522_set_frontend(struct dvb_frontend *fe) | |||
537 | return ret; | 630 | return ret; |
538 | 631 | ||
539 | /* Allow the tuner to settle */ | 632 | /* Allow the tuner to settle */ |
540 | msleep(100); | 633 | if (zv_mode) { |
634 | dprintk("%s() increase tuner settling time for zv_mode\n", | ||
635 | __func__); | ||
636 | msleep(250); | ||
637 | } else | ||
638 | msleep(100); | ||
541 | 639 | ||
542 | au8522_enable_modulation(fe, c->modulation); | 640 | au8522_enable_modulation(fe, c->modulation); |
543 | 641 | ||
@@ -823,6 +921,11 @@ static struct dvb_frontend_ops au8522_ops = { | |||
823 | module_param(debug, int, 0644); | 921 | module_param(debug, int, 0644); |
824 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | 922 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); |
825 | 923 | ||
924 | module_param(zv_mode, int, 0644); | ||
925 | MODULE_PARM_DESC(zv_mode, "Turn on/off ZeeVee modulator compatability mode (default:on).\n" | ||
926 | "\t\ton - modified AU8522 QAM256 initialization.\n" | ||
927 | "\t\tProvides faster lock when using ZeeVee modulator based sources"); | ||
928 | |||
826 | MODULE_DESCRIPTION("Auvitek AU8522 QAM-B/ATSC Demodulator driver"); | 929 | MODULE_DESCRIPTION("Auvitek AU8522 QAM-B/ATSC Demodulator driver"); |
827 | MODULE_AUTHOR("Steven Toth"); | 930 | MODULE_AUTHOR("Steven Toth"); |
828 | MODULE_LICENSE("GPL"); | 931 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/dvb-frontends/cx22700.c b/drivers/media/dvb-frontends/cx22700.c index 3d399d9a6343..86563260d0f2 100644 --- a/drivers/media/dvb-frontends/cx22700.c +++ b/drivers/media/dvb-frontends/cx22700.c | |||
@@ -169,6 +169,9 @@ static int cx22700_set_tps(struct cx22700_state *state, | |||
169 | 169 | ||
170 | cx22700_writereg (state, 0x04, val); | 170 | cx22700_writereg (state, 0x04, val); |
171 | 171 | ||
172 | if (p->code_rate_HP - FEC_1_2 >= sizeof(fec_tab) || | ||
173 | p->code_rate_LP - FEC_1_2 >= sizeof(fec_tab)) | ||
174 | return -EINVAL; | ||
172 | val = fec_tab[p->code_rate_HP - FEC_1_2] << 3; | 175 | val = fec_tab[p->code_rate_HP - FEC_1_2] << 3; |
173 | val |= fec_tab[p->code_rate_LP - FEC_1_2]; | 176 | val |= fec_tab[p->code_rate_LP - FEC_1_2]; |
174 | 177 | ||
diff --git a/drivers/media/dvb-frontends/cx24110.c b/drivers/media/dvb-frontends/cx24110.c index 95b981cd7115..7b510f2ae20f 100644 --- a/drivers/media/dvb-frontends/cx24110.c +++ b/drivers/media/dvb-frontends/cx24110.c | |||
@@ -177,47 +177,45 @@ static int cx24110_set_inversion (struct cx24110_state* state, fe_spectral_inver | |||
177 | return 0; | 177 | return 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | static int cx24110_set_fec (struct cx24110_state* state, fe_code_rate_t fec) | 180 | static int cx24110_set_fec(struct cx24110_state* state, fe_code_rate_t fec) |
181 | { | 181 | { |
182 | /* fixme (low): error handling */ | 182 | static const int rate[FEC_AUTO] = {-1, 1, 2, 3, 5, 7, -1}; |
183 | 183 | static const int g1[FEC_AUTO] = {-1, 0x01, 0x02, 0x05, 0x15, 0x45, -1}; | |
184 | static const int rate[]={-1,1,2,3,5,7,-1}; | 184 | static const int g2[FEC_AUTO] = {-1, 0x01, 0x03, 0x06, 0x1a, 0x7a, -1}; |
185 | static const int g1[]={-1,0x01,0x02,0x05,0x15,0x45,-1}; | ||
186 | static const int g2[]={-1,0x01,0x03,0x06,0x1a,0x7a,-1}; | ||
187 | 185 | ||
188 | /* Well, the AutoAcq engine of the cx24106 and 24110 automatically | 186 | /* Well, the AutoAcq engine of the cx24106 and 24110 automatically |
189 | searches all enabled viterbi rates, and can handle non-standard | 187 | searches all enabled viterbi rates, and can handle non-standard |
190 | rates as well. */ | 188 | rates as well. */ |
191 | 189 | ||
192 | if (fec>FEC_AUTO) | 190 | if (fec > FEC_AUTO) |
193 | fec=FEC_AUTO; | 191 | fec = FEC_AUTO; |
194 | 192 | ||
195 | if (fec==FEC_AUTO) { /* (re-)establish AutoAcq behaviour */ | 193 | if (fec == FEC_AUTO) { /* (re-)establish AutoAcq behaviour */ |
196 | cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xdf); | 194 | cx24110_writereg(state, 0x37, cx24110_readreg(state, 0x37) & 0xdf); |
197 | /* clear AcqVitDis bit */ | 195 | /* clear AcqVitDis bit */ |
198 | cx24110_writereg(state,0x18,0xae); | 196 | cx24110_writereg(state, 0x18, 0xae); |
199 | /* allow all DVB standard code rates */ | 197 | /* allow all DVB standard code rates */ |
200 | cx24110_writereg(state,0x05,(cx24110_readreg(state,0x05)&0xf0)|0x3); | 198 | cx24110_writereg(state, 0x05, (cx24110_readreg(state, 0x05) & 0xf0) | 0x3); |
201 | /* set nominal Viterbi rate 3/4 */ | 199 | /* set nominal Viterbi rate 3/4 */ |
202 | cx24110_writereg(state,0x22,(cx24110_readreg(state,0x22)&0xf0)|0x3); | 200 | cx24110_writereg(state, 0x22, (cx24110_readreg(state, 0x22) & 0xf0) | 0x3); |
203 | /* set current Viterbi rate 3/4 */ | 201 | /* set current Viterbi rate 3/4 */ |
204 | cx24110_writereg(state,0x1a,0x05); cx24110_writereg(state,0x1b,0x06); | 202 | cx24110_writereg(state, 0x1a, 0x05); |
203 | cx24110_writereg(state, 0x1b, 0x06); | ||
205 | /* set the puncture registers for code rate 3/4 */ | 204 | /* set the puncture registers for code rate 3/4 */ |
206 | return 0; | 205 | return 0; |
207 | } else { | 206 | } else { |
208 | cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x20); | 207 | cx24110_writereg(state, 0x37, cx24110_readreg(state, 0x37) | 0x20); |
209 | /* set AcqVitDis bit */ | 208 | /* set AcqVitDis bit */ |
210 | if(rate[fec]>0) { | 209 | if (rate[fec] < 0) |
211 | cx24110_writereg(state,0x05,(cx24110_readreg(state,0x05)&0xf0)|rate[fec]); | 210 | return -EINVAL; |
212 | /* set nominal Viterbi rate */ | 211 | |
213 | cx24110_writereg(state,0x22,(cx24110_readreg(state,0x22)&0xf0)|rate[fec]); | 212 | cx24110_writereg(state, 0x05, (cx24110_readreg(state, 0x05) & 0xf0) | rate[fec]); |
214 | /* set current Viterbi rate */ | 213 | /* set nominal Viterbi rate */ |
215 | cx24110_writereg(state,0x1a,g1[fec]); | 214 | cx24110_writereg(state, 0x22, (cx24110_readreg(state, 0x22) & 0xf0) | rate[fec]); |
216 | cx24110_writereg(state,0x1b,g2[fec]); | 215 | /* set current Viterbi rate */ |
217 | /* not sure if this is the right way: I always used AutoAcq mode */ | 216 | cx24110_writereg(state, 0x1a, g1[fec]); |
218 | } else | 217 | cx24110_writereg(state, 0x1b, g2[fec]); |
219 | return -EOPNOTSUPP; | 218 | /* not sure if this is the right way: I always used AutoAcq mode */ |
220 | /* fixme (low): which is the correct return code? */ | ||
221 | } | 219 | } |
222 | return 0; | 220 | return 0; |
223 | } | 221 | } |
diff --git a/drivers/media/dvb-frontends/cx24117.c b/drivers/media/dvb-frontends/cx24117.c index a6c3c9e2e897..acb965ce0358 100644 --- a/drivers/media/dvb-frontends/cx24117.c +++ b/drivers/media/dvb-frontends/cx24117.c | |||
@@ -459,7 +459,7 @@ static int cx24117_firmware_ondemand(struct dvb_frontend *fe) | |||
459 | if (state->priv->skip_fw_load) | 459 | if (state->priv->skip_fw_load) |
460 | return 0; | 460 | return 0; |
461 | 461 | ||
462 | /* check if firmware if already running */ | 462 | /* check if firmware is already running */ |
463 | if (cx24117_readreg(state, 0xeb) != 0xa) { | 463 | if (cx24117_readreg(state, 0xeb) != 0xa) { |
464 | /* Load firmware */ | 464 | /* Load firmware */ |
465 | /* request the firmware, this will block until loaded */ | 465 | /* request the firmware, this will block until loaded */ |
diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c index 589134e95175..c505d696f92d 100644 --- a/drivers/media/dvb-frontends/dib7000p.c +++ b/drivers/media/dvb-frontends/dib7000p.c | |||
@@ -1780,7 +1780,7 @@ static u32 interpolate_value(u32 value, struct linear_segments *segments, | |||
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | /* FIXME: may require changes - this one was borrowed from dib8000 */ | 1782 | /* FIXME: may require changes - this one was borrowed from dib8000 */ |
1783 | static u32 dib7000p_get_time_us(struct dvb_frontend *demod, int layer) | 1783 | static u32 dib7000p_get_time_us(struct dvb_frontend *demod) |
1784 | { | 1784 | { |
1785 | struct dtv_frontend_properties *c = &demod->dtv_property_cache; | 1785 | struct dtv_frontend_properties *c = &demod->dtv_property_cache; |
1786 | u64 time_us, tmp64; | 1786 | u64 time_us, tmp64; |
@@ -1881,7 +1881,6 @@ static int dib7000p_get_stats(struct dvb_frontend *demod, fe_status_t stat) | |||
1881 | { | 1881 | { |
1882 | struct dib7000p_state *state = demod->demodulator_priv; | 1882 | struct dib7000p_state *state = demod->demodulator_priv; |
1883 | struct dtv_frontend_properties *c = &demod->dtv_property_cache; | 1883 | struct dtv_frontend_properties *c = &demod->dtv_property_cache; |
1884 | int i; | ||
1885 | int show_per_stats = 0; | 1884 | int show_per_stats = 0; |
1886 | u32 time_us = 0, val, snr; | 1885 | u32 time_us = 0, val, snr; |
1887 | u64 blocks, ucb; | 1886 | u64 blocks, ucb; |
@@ -1935,7 +1934,7 @@ static int dib7000p_get_stats(struct dvb_frontend *demod, fe_status_t stat) | |||
1935 | 1934 | ||
1936 | /* Estimate the number of packets based on bitrate */ | 1935 | /* Estimate the number of packets based on bitrate */ |
1937 | if (!time_us) | 1936 | if (!time_us) |
1938 | time_us = dib7000p_get_time_us(demod, -1); | 1937 | time_us = dib7000p_get_time_us(demod); |
1939 | 1938 | ||
1940 | if (time_us) { | 1939 | if (time_us) { |
1941 | blocks = 1250000ULL * 1000000ULL; | 1940 | blocks = 1250000ULL * 1000000ULL; |
@@ -1949,7 +1948,7 @@ static int dib7000p_get_stats(struct dvb_frontend *demod, fe_status_t stat) | |||
1949 | 1948 | ||
1950 | /* Get post-BER measures */ | 1949 | /* Get post-BER measures */ |
1951 | if (time_after(jiffies, state->ber_jiffies_stats)) { | 1950 | if (time_after(jiffies, state->ber_jiffies_stats)) { |
1952 | time_us = dib7000p_get_time_us(demod, -1); | 1951 | time_us = dib7000p_get_time_us(demod); |
1953 | state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); | 1952 | state->ber_jiffies_stats = jiffies + msecs_to_jiffies((time_us + 500) / 1000); |
1954 | 1953 | ||
1955 | dprintk("Next all layers stats available in %u us.", time_us); | 1954 | dprintk("Next all layers stats available in %u us.", time_us); |
@@ -1969,7 +1968,7 @@ static int dib7000p_get_stats(struct dvb_frontend *demod, fe_status_t stat) | |||
1969 | c->block_error.stat[0].scale = FE_SCALE_COUNTER; | 1968 | c->block_error.stat[0].scale = FE_SCALE_COUNTER; |
1970 | c->block_error.stat[0].uvalue += val; | 1969 | c->block_error.stat[0].uvalue += val; |
1971 | 1970 | ||
1972 | time_us = dib7000p_get_time_us(demod, i); | 1971 | time_us = dib7000p_get_time_us(demod); |
1973 | if (time_us) { | 1972 | if (time_us) { |
1974 | blocks = 1250000ULL * 1000000ULL; | 1973 | blocks = 1250000ULL * 1000000ULL; |
1975 | do_div(blocks, time_us * 8 * 204); | 1974 | do_div(blocks, time_us * 8 * 204); |
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index 5ec221ffdfca..2bfa7a435974 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c | |||
@@ -12255,8 +12255,7 @@ static void drx39xxj_release(struct dvb_frontend *fe) | |||
12255 | kfree(demod->my_ext_attr); | 12255 | kfree(demod->my_ext_attr); |
12256 | kfree(demod->my_common_attr); | 12256 | kfree(demod->my_common_attr); |
12257 | kfree(demod->my_i2c_dev_addr); | 12257 | kfree(demod->my_i2c_dev_addr); |
12258 | if (demod->firmware) | 12258 | release_firmware(demod->firmware); |
12259 | release_firmware(demod->firmware); | ||
12260 | kfree(demod); | 12259 | kfree(demod); |
12261 | kfree(state); | 12260 | kfree(state); |
12262 | } | 12261 | } |
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 672195147d01..d46cf5f7cd2e 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c | |||
@@ -166,9 +166,9 @@ static unsigned int debug; | |||
166 | module_param(debug, int, 0644); | 166 | module_param(debug, int, 0644); |
167 | MODULE_PARM_DESC(debug, "enable debug messages"); | 167 | MODULE_PARM_DESC(debug, "enable debug messages"); |
168 | 168 | ||
169 | #define dprintk(level, fmt, arg...) do { \ | 169 | #define dprintk(level, fmt, arg...) do { \ |
170 | if (debug >= level) \ | 170 | if (debug >= level) \ |
171 | pr_debug(fmt, ##arg); \ | 171 | printk(KERN_DEBUG KBUILD_MODNAME ": %s " fmt, __func__, ##arg); \ |
172 | } while (0) | 172 | } while (0) |
173 | 173 | ||
174 | 174 | ||
@@ -6310,8 +6310,7 @@ static void drxk_release(struct dvb_frontend *fe) | |||
6310 | struct drxk_state *state = fe->demodulator_priv; | 6310 | struct drxk_state *state = fe->demodulator_priv; |
6311 | 6311 | ||
6312 | dprintk(1, "\n"); | 6312 | dprintk(1, "\n"); |
6313 | if (state->fw) | 6313 | release_firmware(state->fw); |
6314 | release_firmware(state->fw); | ||
6315 | 6314 | ||
6316 | kfree(state); | 6315 | kfree(state); |
6317 | } | 6316 | } |
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c index 81657e94c5a4..ba4ee0b48834 100644 --- a/drivers/media/dvb-frontends/m88ds3103.c +++ b/drivers/media/dvb-frontends/m88ds3103.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Montage M88DS3103 demodulator driver | 2 | * Montage M88DS3103/M88RS6000 demodulator driver |
3 | * | 3 | * |
4 | * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> |
5 | * | 5 | * |
@@ -162,7 +162,7 @@ static int m88ds3103_wr_reg_val_tab(struct m88ds3103_priv *priv, | |||
162 | 162 | ||
163 | dev_dbg(&priv->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len); | 163 | dev_dbg(&priv->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len); |
164 | 164 | ||
165 | if (tab_len > 83) { | 165 | if (tab_len > 86) { |
166 | ret = -EINVAL; | 166 | ret = -EINVAL; |
167 | goto err; | 167 | goto err; |
168 | } | 168 | } |
@@ -245,9 +245,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
245 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 245 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
246 | int ret, len; | 246 | int ret, len; |
247 | const struct m88ds3103_reg_val *init; | 247 | const struct m88ds3103_reg_val *init; |
248 | u8 u8tmp, u8tmp1, u8tmp2; | 248 | u8 u8tmp, u8tmp1 = 0, u8tmp2 = 0; /* silence compiler warning */ |
249 | u8 buf[2]; | 249 | u8 buf[3]; |
250 | u16 u16tmp, divide_ratio; | 250 | u16 u16tmp, divide_ratio = 0; |
251 | u32 tuner_frequency, target_mclk; | 251 | u32 tuner_frequency, target_mclk; |
252 | s32 s32tmp; | 252 | s32 s32tmp; |
253 | 253 | ||
@@ -262,6 +262,22 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
262 | goto err; | 262 | goto err; |
263 | } | 263 | } |
264 | 264 | ||
265 | /* reset */ | ||
266 | ret = m88ds3103_wr_reg(priv, 0x07, 0x80); | ||
267 | if (ret) | ||
268 | goto err; | ||
269 | |||
270 | ret = m88ds3103_wr_reg(priv, 0x07, 0x00); | ||
271 | if (ret) | ||
272 | goto err; | ||
273 | |||
274 | /* Disable demod clock path */ | ||
275 | if (priv->chip_id == M88RS6000_CHIP_ID) { | ||
276 | ret = m88ds3103_wr_reg(priv, 0x06, 0xe0); | ||
277 | if (ret) | ||
278 | goto err; | ||
279 | } | ||
280 | |||
265 | /* program tuner */ | 281 | /* program tuner */ |
266 | if (fe->ops.tuner_ops.set_params) { | 282 | if (fe->ops.tuner_ops.set_params) { |
267 | ret = fe->ops.tuner_ops.set_params(fe); | 283 | ret = fe->ops.tuner_ops.set_params(fe); |
@@ -282,49 +298,44 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
282 | tuner_frequency = c->frequency; | 298 | tuner_frequency = c->frequency; |
283 | } | 299 | } |
284 | 300 | ||
285 | /* reset */ | 301 | /* select M88RS6000 demod main mclk and ts mclk from tuner die. */ |
286 | ret = m88ds3103_wr_reg(priv, 0x07, 0x80); | 302 | if (priv->chip_id == M88RS6000_CHIP_ID) { |
287 | if (ret) | 303 | if (c->symbol_rate > 45010000) |
288 | goto err; | 304 | priv->mclk_khz = 110250; |
289 | 305 | else | |
290 | ret = m88ds3103_wr_reg(priv, 0x07, 0x00); | 306 | priv->mclk_khz = 96000; |
291 | if (ret) | ||
292 | goto err; | ||
293 | |||
294 | ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); | ||
295 | if (ret) | ||
296 | goto err; | ||
297 | 307 | ||
298 | ret = m88ds3103_wr_reg(priv, 0x00, 0x01); | 308 | if (c->delivery_system == SYS_DVBS) |
299 | if (ret) | 309 | target_mclk = 96000; |
300 | goto err; | 310 | else |
311 | target_mclk = 144000; | ||
301 | 312 | ||
302 | switch (c->delivery_system) { | 313 | /* Enable demod clock path */ |
303 | case SYS_DVBS: | 314 | ret = m88ds3103_wr_reg(priv, 0x06, 0x00); |
304 | len = ARRAY_SIZE(m88ds3103_dvbs_init_reg_vals); | 315 | if (ret) |
305 | init = m88ds3103_dvbs_init_reg_vals; | 316 | goto err; |
306 | target_mclk = 96000; | 317 | usleep_range(10000, 20000); |
307 | break; | 318 | } else { |
308 | case SYS_DVBS2: | 319 | /* set M88DS3103 mclk and ts mclk. */ |
309 | len = ARRAY_SIZE(m88ds3103_dvbs2_init_reg_vals); | 320 | priv->mclk_khz = 96000; |
310 | init = m88ds3103_dvbs2_init_reg_vals; | ||
311 | 321 | ||
312 | switch (priv->cfg->ts_mode) { | 322 | switch (priv->cfg->ts_mode) { |
313 | case M88DS3103_TS_SERIAL: | 323 | case M88DS3103_TS_SERIAL: |
314 | case M88DS3103_TS_SERIAL_D7: | 324 | case M88DS3103_TS_SERIAL_D7: |
315 | if (c->symbol_rate < 18000000) | 325 | target_mclk = priv->cfg->ts_clk; |
316 | target_mclk = 96000; | ||
317 | else | ||
318 | target_mclk = 144000; | ||
319 | break; | 326 | break; |
320 | case M88DS3103_TS_PARALLEL: | 327 | case M88DS3103_TS_PARALLEL: |
321 | case M88DS3103_TS_CI: | 328 | case M88DS3103_TS_CI: |
322 | if (c->symbol_rate < 18000000) | 329 | if (c->delivery_system == SYS_DVBS) |
323 | target_mclk = 96000; | 330 | target_mclk = 96000; |
324 | else if (c->symbol_rate < 28000000) | 331 | else { |
325 | target_mclk = 144000; | 332 | if (c->symbol_rate < 18000000) |
326 | else | 333 | target_mclk = 96000; |
327 | target_mclk = 192000; | 334 | else if (c->symbol_rate < 28000000) |
335 | target_mclk = 144000; | ||
336 | else | ||
337 | target_mclk = 192000; | ||
338 | } | ||
328 | break; | 339 | break; |
329 | default: | 340 | default: |
330 | dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", | 341 | dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", |
@@ -332,6 +343,55 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
332 | ret = -EINVAL; | 343 | ret = -EINVAL; |
333 | goto err; | 344 | goto err; |
334 | } | 345 | } |
346 | |||
347 | switch (target_mclk) { | ||
348 | case 96000: | ||
349 | u8tmp1 = 0x02; /* 0b10 */ | ||
350 | u8tmp2 = 0x01; /* 0b01 */ | ||
351 | break; | ||
352 | case 144000: | ||
353 | u8tmp1 = 0x00; /* 0b00 */ | ||
354 | u8tmp2 = 0x01; /* 0b01 */ | ||
355 | break; | ||
356 | case 192000: | ||
357 | u8tmp1 = 0x03; /* 0b11 */ | ||
358 | u8tmp2 = 0x00; /* 0b00 */ | ||
359 | break; | ||
360 | } | ||
361 | ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0); | ||
362 | if (ret) | ||
363 | goto err; | ||
364 | ret = m88ds3103_wr_reg_mask(priv, 0x24, u8tmp2 << 6, 0xc0); | ||
365 | if (ret) | ||
366 | goto err; | ||
367 | } | ||
368 | |||
369 | ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); | ||
370 | if (ret) | ||
371 | goto err; | ||
372 | |||
373 | ret = m88ds3103_wr_reg(priv, 0x00, 0x01); | ||
374 | if (ret) | ||
375 | goto err; | ||
376 | |||
377 | switch (c->delivery_system) { | ||
378 | case SYS_DVBS: | ||
379 | if (priv->chip_id == M88RS6000_CHIP_ID) { | ||
380 | len = ARRAY_SIZE(m88rs6000_dvbs_init_reg_vals); | ||
381 | init = m88rs6000_dvbs_init_reg_vals; | ||
382 | } else { | ||
383 | len = ARRAY_SIZE(m88ds3103_dvbs_init_reg_vals); | ||
384 | init = m88ds3103_dvbs_init_reg_vals; | ||
385 | } | ||
386 | break; | ||
387 | case SYS_DVBS2: | ||
388 | if (priv->chip_id == M88RS6000_CHIP_ID) { | ||
389 | len = ARRAY_SIZE(m88rs6000_dvbs2_init_reg_vals); | ||
390 | init = m88rs6000_dvbs2_init_reg_vals; | ||
391 | } else { | ||
392 | len = ARRAY_SIZE(m88ds3103_dvbs2_init_reg_vals); | ||
393 | init = m88ds3103_dvbs2_init_reg_vals; | ||
394 | } | ||
335 | break; | 395 | break; |
336 | default: | 396 | default: |
337 | dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", | 397 | dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", |
@@ -347,7 +407,30 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
347 | goto err; | 407 | goto err; |
348 | } | 408 | } |
349 | 409 | ||
350 | u8tmp1 = 0; /* silence compiler warning */ | 410 | if (priv->chip_id == M88RS6000_CHIP_ID) { |
411 | if ((c->delivery_system == SYS_DVBS2) | ||
412 | && ((c->symbol_rate / 1000) <= 5000)) { | ||
413 | ret = m88ds3103_wr_reg(priv, 0xc0, 0x04); | ||
414 | if (ret) | ||
415 | goto err; | ||
416 | buf[0] = 0x09; | ||
417 | buf[1] = 0x22; | ||
418 | buf[2] = 0x88; | ||
419 | ret = m88ds3103_wr_regs(priv, 0x8a, buf, 3); | ||
420 | if (ret) | ||
421 | goto err; | ||
422 | } | ||
423 | ret = m88ds3103_wr_reg_mask(priv, 0x9d, 0x08, 0x08); | ||
424 | if (ret) | ||
425 | goto err; | ||
426 | ret = m88ds3103_wr_reg(priv, 0xf1, 0x01); | ||
427 | if (ret) | ||
428 | goto err; | ||
429 | ret = m88ds3103_wr_reg_mask(priv, 0x30, 0x80, 0x80); | ||
430 | if (ret) | ||
431 | goto err; | ||
432 | } | ||
433 | |||
351 | switch (priv->cfg->ts_mode) { | 434 | switch (priv->cfg->ts_mode) { |
352 | case M88DS3103_TS_SERIAL: | 435 | case M88DS3103_TS_SERIAL: |
353 | u8tmp1 = 0x00; | 436 | u8tmp1 = 0x00; |
@@ -383,16 +466,15 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
383 | ret = m88ds3103_wr_reg_mask(priv, 0x29, u8tmp1, 0x20); | 466 | ret = m88ds3103_wr_reg_mask(priv, 0x29, u8tmp1, 0x20); |
384 | if (ret) | 467 | if (ret) |
385 | goto err; | 468 | goto err; |
386 | } | ||
387 | |||
388 | if (priv->cfg->ts_clk) { | ||
389 | divide_ratio = DIV_ROUND_UP(target_mclk, priv->cfg->ts_clk); | ||
390 | u8tmp1 = divide_ratio / 2; | ||
391 | u8tmp2 = DIV_ROUND_UP(divide_ratio, 2); | ||
392 | } else { | ||
393 | divide_ratio = 0; | ||
394 | u8tmp1 = 0; | 469 | u8tmp1 = 0; |
395 | u8tmp2 = 0; | 470 | u8tmp2 = 0; |
471 | break; | ||
472 | default: | ||
473 | if (priv->cfg->ts_clk) { | ||
474 | divide_ratio = DIV_ROUND_UP(target_mclk, priv->cfg->ts_clk); | ||
475 | u8tmp1 = divide_ratio / 2; | ||
476 | u8tmp2 = DIV_ROUND_UP(divide_ratio, 2); | ||
477 | } | ||
396 | } | 478 | } |
397 | 479 | ||
398 | dev_dbg(&priv->i2c->dev, | 480 | dev_dbg(&priv->i2c->dev, |
@@ -420,29 +502,6 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
420 | if (ret) | 502 | if (ret) |
421 | goto err; | 503 | goto err; |
422 | 504 | ||
423 | switch (target_mclk) { | ||
424 | case 96000: | ||
425 | u8tmp1 = 0x02; /* 0b10 */ | ||
426 | u8tmp2 = 0x01; /* 0b01 */ | ||
427 | break; | ||
428 | case 144000: | ||
429 | u8tmp1 = 0x00; /* 0b00 */ | ||
430 | u8tmp2 = 0x01; /* 0b01 */ | ||
431 | break; | ||
432 | case 192000: | ||
433 | u8tmp1 = 0x03; /* 0b11 */ | ||
434 | u8tmp2 = 0x00; /* 0b00 */ | ||
435 | break; | ||
436 | } | ||
437 | |||
438 | ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0); | ||
439 | if (ret) | ||
440 | goto err; | ||
441 | |||
442 | ret = m88ds3103_wr_reg_mask(priv, 0x24, u8tmp2 << 6, 0xc0); | ||
443 | if (ret) | ||
444 | goto err; | ||
445 | |||
446 | if (c->symbol_rate <= 3000000) | 505 | if (c->symbol_rate <= 3000000) |
447 | u8tmp = 0x20; | 506 | u8tmp = 0x20; |
448 | else if (c->symbol_rate <= 10000000) | 507 | else if (c->symbol_rate <= 10000000) |
@@ -466,7 +525,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
466 | if (ret) | 525 | if (ret) |
467 | goto err; | 526 | goto err; |
468 | 527 | ||
469 | u16tmp = DIV_ROUND_CLOSEST((c->symbol_rate / 1000) << 15, M88DS3103_MCLK_KHZ / 2); | 528 | u16tmp = DIV_ROUND_CLOSEST((c->symbol_rate / 1000) << 15, priv->mclk_khz / 2); |
470 | buf[0] = (u16tmp >> 0) & 0xff; | 529 | buf[0] = (u16tmp >> 0) & 0xff; |
471 | buf[1] = (u16tmp >> 8) & 0xff; | 530 | buf[1] = (u16tmp >> 8) & 0xff; |
472 | ret = m88ds3103_wr_regs(priv, 0x61, buf, 2); | 531 | ret = m88ds3103_wr_regs(priv, 0x61, buf, 2); |
@@ -489,7 +548,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
489 | (tuner_frequency - c->frequency)); | 548 | (tuner_frequency - c->frequency)); |
490 | 549 | ||
491 | s32tmp = 0x10000 * (tuner_frequency - c->frequency); | 550 | s32tmp = 0x10000 * (tuner_frequency - c->frequency); |
492 | s32tmp = DIV_ROUND_CLOSEST(s32tmp, M88DS3103_MCLK_KHZ); | 551 | s32tmp = DIV_ROUND_CLOSEST(s32tmp, priv->mclk_khz); |
493 | if (s32tmp < 0) | 552 | if (s32tmp < 0) |
494 | s32tmp += 0x10000; | 553 | s32tmp += 0x10000; |
495 | 554 | ||
@@ -520,7 +579,7 @@ static int m88ds3103_init(struct dvb_frontend *fe) | |||
520 | struct m88ds3103_priv *priv = fe->demodulator_priv; | 579 | struct m88ds3103_priv *priv = fe->demodulator_priv; |
521 | int ret, len, remaining; | 580 | int ret, len, remaining; |
522 | const struct firmware *fw = NULL; | 581 | const struct firmware *fw = NULL; |
523 | u8 *fw_file = M88DS3103_FIRMWARE; | 582 | u8 *fw_file; |
524 | u8 u8tmp; | 583 | u8 u8tmp; |
525 | 584 | ||
526 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); | 585 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); |
@@ -541,15 +600,6 @@ static int m88ds3103_init(struct dvb_frontend *fe) | |||
541 | if (ret) | 600 | if (ret) |
542 | goto err; | 601 | goto err; |
543 | 602 | ||
544 | /* reset */ | ||
545 | ret = m88ds3103_wr_reg(priv, 0x07, 0x60); | ||
546 | if (ret) | ||
547 | goto err; | ||
548 | |||
549 | ret = m88ds3103_wr_reg(priv, 0x07, 0x00); | ||
550 | if (ret) | ||
551 | goto err; | ||
552 | |||
553 | /* firmware status */ | 603 | /* firmware status */ |
554 | ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); | 604 | ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); |
555 | if (ret) | 605 | if (ret) |
@@ -560,10 +610,23 @@ static int m88ds3103_init(struct dvb_frontend *fe) | |||
560 | if (u8tmp) | 610 | if (u8tmp) |
561 | goto skip_fw_download; | 611 | goto skip_fw_download; |
562 | 612 | ||
613 | /* global reset, global diseqc reset, golbal fec reset */ | ||
614 | ret = m88ds3103_wr_reg(priv, 0x07, 0xe0); | ||
615 | if (ret) | ||
616 | goto err; | ||
617 | |||
618 | ret = m88ds3103_wr_reg(priv, 0x07, 0x00); | ||
619 | if (ret) | ||
620 | goto err; | ||
621 | |||
563 | /* cold state - try to download firmware */ | 622 | /* cold state - try to download firmware */ |
564 | dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state\n", | 623 | dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state\n", |
565 | KBUILD_MODNAME, m88ds3103_ops.info.name); | 624 | KBUILD_MODNAME, m88ds3103_ops.info.name); |
566 | 625 | ||
626 | if (priv->chip_id == M88RS6000_CHIP_ID) | ||
627 | fw_file = M88RS6000_FIRMWARE; | ||
628 | else | ||
629 | fw_file = M88DS3103_FIRMWARE; | ||
567 | /* request the firmware, this will block and timeout */ | 630 | /* request the firmware, this will block and timeout */ |
568 | ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); | 631 | ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); |
569 | if (ret) { | 632 | if (ret) { |
@@ -577,7 +640,7 @@ static int m88ds3103_init(struct dvb_frontend *fe) | |||
577 | 640 | ||
578 | ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); | 641 | ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); |
579 | if (ret) | 642 | if (ret) |
580 | goto err; | 643 | goto error_fw_release; |
581 | 644 | ||
582 | for (remaining = fw->size; remaining > 0; | 645 | for (remaining = fw->size; remaining > 0; |
583 | remaining -= (priv->cfg->i2c_wr_max - 1)) { | 646 | remaining -= (priv->cfg->i2c_wr_max - 1)) { |
@@ -591,13 +654,13 @@ static int m88ds3103_init(struct dvb_frontend *fe) | |||
591 | dev_err(&priv->i2c->dev, | 654 | dev_err(&priv->i2c->dev, |
592 | "%s: firmware download failed=%d\n", | 655 | "%s: firmware download failed=%d\n", |
593 | KBUILD_MODNAME, ret); | 656 | KBUILD_MODNAME, ret); |
594 | goto err; | 657 | goto error_fw_release; |
595 | } | 658 | } |
596 | } | 659 | } |
597 | 660 | ||
598 | ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); | 661 | ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); |
599 | if (ret) | 662 | if (ret) |
600 | goto err; | 663 | goto error_fw_release; |
601 | 664 | ||
602 | release_firmware(fw); | 665 | release_firmware(fw); |
603 | fw = NULL; | 666 | fw = NULL; |
@@ -623,10 +686,10 @@ skip_fw_download: | |||
623 | priv->warm = true; | 686 | priv->warm = true; |
624 | 687 | ||
625 | return 0; | 688 | return 0; |
626 | err: | ||
627 | if (fw) | ||
628 | release_firmware(fw); | ||
629 | 689 | ||
690 | error_fw_release: | ||
691 | release_firmware(fw); | ||
692 | err: | ||
630 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); | 693 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
631 | return ret; | 694 | return ret; |
632 | } | 695 | } |
@@ -635,13 +698,18 @@ static int m88ds3103_sleep(struct dvb_frontend *fe) | |||
635 | { | 698 | { |
636 | struct m88ds3103_priv *priv = fe->demodulator_priv; | 699 | struct m88ds3103_priv *priv = fe->demodulator_priv; |
637 | int ret; | 700 | int ret; |
701 | u8 u8tmp; | ||
638 | 702 | ||
639 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); | 703 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); |
640 | 704 | ||
641 | priv->delivery_system = SYS_UNDEFINED; | 705 | priv->delivery_system = SYS_UNDEFINED; |
642 | 706 | ||
643 | /* TS Hi-Z */ | 707 | /* TS Hi-Z */ |
644 | ret = m88ds3103_wr_reg_mask(priv, 0x27, 0x00, 0x01); | 708 | if (priv->chip_id == M88RS6000_CHIP_ID) |
709 | u8tmp = 0x29; | ||
710 | else | ||
711 | u8tmp = 0x27; | ||
712 | ret = m88ds3103_wr_reg_mask(priv, u8tmp, 0x00, 0x01); | ||
645 | if (ret) | 713 | if (ret) |
646 | goto err; | 714 | goto err; |
647 | 715 | ||
@@ -830,7 +898,7 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe) | |||
830 | goto err; | 898 | goto err; |
831 | 899 | ||
832 | c->symbol_rate = 1ull * ((buf[1] << 8) | (buf[0] << 0)) * | 900 | c->symbol_rate = 1ull * ((buf[1] << 8) | (buf[0] << 0)) * |
833 | M88DS3103_MCLK_KHZ * 1000 / 0x10000; | 901 | priv->mclk_khz * 1000 / 0x10000; |
834 | 902 | ||
835 | return 0; | 903 | return 0; |
836 | err: | 904 | err: |
@@ -1310,18 +1378,22 @@ struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg, | |||
1310 | priv->i2c = i2c; | 1378 | priv->i2c = i2c; |
1311 | mutex_init(&priv->i2c_mutex); | 1379 | mutex_init(&priv->i2c_mutex); |
1312 | 1380 | ||
1313 | ret = m88ds3103_rd_reg(priv, 0x01, &chip_id); | 1381 | /* 0x00: chip id[6:0], 0x01: chip ver[7:0], 0x02: chip ver[15:8] */ |
1382 | ret = m88ds3103_rd_reg(priv, 0x00, &chip_id); | ||
1314 | if (ret) | 1383 | if (ret) |
1315 | goto err; | 1384 | goto err; |
1316 | 1385 | ||
1317 | dev_dbg(&priv->i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); | 1386 | chip_id >>= 1; |
1387 | dev_info(&priv->i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); | ||
1318 | 1388 | ||
1319 | switch (chip_id) { | 1389 | switch (chip_id) { |
1320 | case 0xd0: | 1390 | case M88RS6000_CHIP_ID: |
1391 | case M88DS3103_CHIP_ID: | ||
1321 | break; | 1392 | break; |
1322 | default: | 1393 | default: |
1323 | goto err; | 1394 | goto err; |
1324 | } | 1395 | } |
1396 | priv->chip_id = chip_id; | ||
1325 | 1397 | ||
1326 | switch (priv->cfg->clock_out) { | 1398 | switch (priv->cfg->clock_out) { |
1327 | case M88DS3103_CLOCK_OUT_DISABLED: | 1399 | case M88DS3103_CLOCK_OUT_DISABLED: |
@@ -1337,6 +1409,11 @@ struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg, | |||
1337 | goto err; | 1409 | goto err; |
1338 | } | 1410 | } |
1339 | 1411 | ||
1412 | /* 0x29 register is defined differently for m88rs6000. */ | ||
1413 | /* set internal tuner address to 0x21 */ | ||
1414 | if (chip_id == M88RS6000_CHIP_ID) | ||
1415 | u8tmp = 0x00; | ||
1416 | |||
1340 | ret = m88ds3103_wr_reg(priv, 0x29, u8tmp); | 1417 | ret = m88ds3103_wr_reg(priv, 0x29, u8tmp); |
1341 | if (ret) | 1418 | if (ret) |
1342 | goto err; | 1419 | goto err; |
@@ -1364,6 +1441,9 @@ struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg, | |||
1364 | 1441 | ||
1365 | /* create dvb_frontend */ | 1442 | /* create dvb_frontend */ |
1366 | memcpy(&priv->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops)); | 1443 | memcpy(&priv->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops)); |
1444 | if (priv->chip_id == M88RS6000_CHIP_ID) | ||
1445 | strncpy(priv->fe.ops.info.name, | ||
1446 | "Montage M88RS6000", sizeof(priv->fe.ops.info.name)); | ||
1367 | priv->fe.demodulator_priv = priv; | 1447 | priv->fe.demodulator_priv = priv; |
1368 | 1448 | ||
1369 | return &priv->fe; | 1449 | return &priv->fe; |
@@ -1423,3 +1503,4 @@ MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | |||
1423 | MODULE_DESCRIPTION("Montage M88DS3103 DVB-S/S2 demodulator driver"); | 1503 | MODULE_DESCRIPTION("Montage M88DS3103 DVB-S/S2 demodulator driver"); |
1424 | MODULE_LICENSE("GPL"); | 1504 | MODULE_LICENSE("GPL"); |
1425 | MODULE_FIRMWARE(M88DS3103_FIRMWARE); | 1505 | MODULE_FIRMWARE(M88DS3103_FIRMWARE); |
1506 | MODULE_FIRMWARE(M88RS6000_FIRMWARE); | ||
diff --git a/drivers/media/dvb-frontends/m88ds3103_priv.h b/drivers/media/dvb-frontends/m88ds3103_priv.h index 9169fdd143cf..a2c0958111f8 100644 --- a/drivers/media/dvb-frontends/m88ds3103_priv.h +++ b/drivers/media/dvb-frontends/m88ds3103_priv.h | |||
@@ -25,7 +25,10 @@ | |||
25 | #include <linux/math64.h> | 25 | #include <linux/math64.h> |
26 | 26 | ||
27 | #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw" | 27 | #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw" |
28 | #define M88RS6000_FIRMWARE "dvb-demod-m88rs6000.fw" | ||
28 | #define M88DS3103_MCLK_KHZ 96000 | 29 | #define M88DS3103_MCLK_KHZ 96000 |
30 | #define M88RS6000_CHIP_ID 0x74 | ||
31 | #define M88DS3103_CHIP_ID 0x70 | ||
29 | 32 | ||
30 | struct m88ds3103_priv { | 33 | struct m88ds3103_priv { |
31 | struct i2c_adapter *i2c; | 34 | struct i2c_adapter *i2c; |
@@ -38,6 +41,10 @@ struct m88ds3103_priv { | |||
38 | u32 ber; | 41 | u32 ber; |
39 | bool warm; /* FW running */ | 42 | bool warm; /* FW running */ |
40 | struct i2c_adapter *i2c_adapter; | 43 | struct i2c_adapter *i2c_adapter; |
44 | /* auto detect chip id to do different config */ | ||
45 | u8 chip_id; | ||
46 | /* main mclk is calculated for M88RS6000 dynamically */ | ||
47 | u32 mclk_khz; | ||
41 | }; | 48 | }; |
42 | 49 | ||
43 | struct m88ds3103_reg_val { | 50 | struct m88ds3103_reg_val { |
@@ -214,4 +221,178 @@ static const struct m88ds3103_reg_val m88ds3103_dvbs2_init_reg_vals[] = { | |||
214 | {0xb8, 0x00}, | 221 | {0xb8, 0x00}, |
215 | }; | 222 | }; |
216 | 223 | ||
224 | static const struct m88ds3103_reg_val m88rs6000_dvbs_init_reg_vals[] = { | ||
225 | {0x23, 0x07}, | ||
226 | {0x08, 0x03}, | ||
227 | {0x0c, 0x02}, | ||
228 | {0x20, 0x00}, | ||
229 | {0x21, 0x54}, | ||
230 | {0x25, 0x82}, | ||
231 | {0x27, 0x31}, | ||
232 | {0x30, 0x08}, | ||
233 | {0x31, 0x40}, | ||
234 | {0x32, 0x32}, | ||
235 | {0x33, 0x35}, | ||
236 | {0x35, 0xff}, | ||
237 | {0x3a, 0x00}, | ||
238 | {0x37, 0x10}, | ||
239 | {0x38, 0x10}, | ||
240 | {0x39, 0x02}, | ||
241 | {0x42, 0x60}, | ||
242 | {0x4a, 0x80}, | ||
243 | {0x4b, 0x04}, | ||
244 | {0x4d, 0x91}, | ||
245 | {0x5d, 0xc8}, | ||
246 | {0x50, 0x36}, | ||
247 | {0x51, 0x36}, | ||
248 | {0x52, 0x36}, | ||
249 | {0x53, 0x36}, | ||
250 | {0x63, 0x0f}, | ||
251 | {0x64, 0x30}, | ||
252 | {0x65, 0x40}, | ||
253 | {0x68, 0x26}, | ||
254 | {0x69, 0x4c}, | ||
255 | {0x70, 0x20}, | ||
256 | {0x71, 0x70}, | ||
257 | {0x72, 0x04}, | ||
258 | {0x73, 0x00}, | ||
259 | {0x70, 0x40}, | ||
260 | {0x71, 0x70}, | ||
261 | {0x72, 0x04}, | ||
262 | {0x73, 0x00}, | ||
263 | {0x70, 0x60}, | ||
264 | {0x71, 0x70}, | ||
265 | {0x72, 0x04}, | ||
266 | {0x73, 0x00}, | ||
267 | {0x70, 0x80}, | ||
268 | {0x71, 0x70}, | ||
269 | {0x72, 0x04}, | ||
270 | {0x73, 0x00}, | ||
271 | {0x70, 0xa0}, | ||
272 | {0x71, 0x70}, | ||
273 | {0x72, 0x04}, | ||
274 | {0x73, 0x00}, | ||
275 | {0x70, 0x1f}, | ||
276 | {0x76, 0x38}, | ||
277 | {0x77, 0xa6}, | ||
278 | {0x78, 0x0c}, | ||
279 | {0x79, 0x80}, | ||
280 | {0x7f, 0x14}, | ||
281 | {0x7c, 0x00}, | ||
282 | {0xae, 0x82}, | ||
283 | {0x80, 0x64}, | ||
284 | {0x81, 0x66}, | ||
285 | {0x82, 0x44}, | ||
286 | {0x85, 0x04}, | ||
287 | {0xcd, 0xf4}, | ||
288 | {0x90, 0x33}, | ||
289 | {0xa0, 0x44}, | ||
290 | {0xbe, 0x00}, | ||
291 | {0xc0, 0x08}, | ||
292 | {0xc3, 0x10}, | ||
293 | {0xc4, 0x08}, | ||
294 | {0xc5, 0xf0}, | ||
295 | {0xc6, 0xff}, | ||
296 | {0xc7, 0x00}, | ||
297 | {0xc8, 0x1a}, | ||
298 | {0xc9, 0x80}, | ||
299 | {0xe0, 0xf8}, | ||
300 | {0xe6, 0x8b}, | ||
301 | {0xd0, 0x40}, | ||
302 | {0xf8, 0x20}, | ||
303 | {0xfa, 0x0f}, | ||
304 | {0x00, 0x00}, | ||
305 | {0xbd, 0x01}, | ||
306 | {0xb8, 0x00}, | ||
307 | {0x29, 0x11}, | ||
308 | }; | ||
309 | |||
310 | static const struct m88ds3103_reg_val m88rs6000_dvbs2_init_reg_vals[] = { | ||
311 | {0x23, 0x07}, | ||
312 | {0x08, 0x07}, | ||
313 | {0x0c, 0x02}, | ||
314 | {0x20, 0x00}, | ||
315 | {0x21, 0x54}, | ||
316 | {0x25, 0x82}, | ||
317 | {0x27, 0x31}, | ||
318 | {0x30, 0x08}, | ||
319 | {0x32, 0x32}, | ||
320 | {0x33, 0x35}, | ||
321 | {0x35, 0xff}, | ||
322 | {0x3a, 0x00}, | ||
323 | {0x37, 0x10}, | ||
324 | {0x38, 0x10}, | ||
325 | {0x39, 0x02}, | ||
326 | {0x42, 0x60}, | ||
327 | {0x4a, 0x80}, | ||
328 | {0x4b, 0x04}, | ||
329 | {0x4d, 0x91}, | ||
330 | {0x5d, 0xc8}, | ||
331 | {0x50, 0x36}, | ||
332 | {0x51, 0x36}, | ||
333 | {0x52, 0x36}, | ||
334 | {0x53, 0x36}, | ||
335 | {0x63, 0x0f}, | ||
336 | {0x64, 0x10}, | ||
337 | {0x65, 0x20}, | ||
338 | {0x68, 0x46}, | ||
339 | {0x69, 0xcd}, | ||
340 | {0x70, 0x20}, | ||
341 | {0x71, 0x70}, | ||
342 | {0x72, 0x04}, | ||
343 | {0x73, 0x00}, | ||
344 | {0x70, 0x40}, | ||
345 | {0x71, 0x70}, | ||
346 | {0x72, 0x04}, | ||
347 | {0x73, 0x00}, | ||
348 | {0x70, 0x60}, | ||
349 | {0x71, 0x70}, | ||
350 | {0x72, 0x04}, | ||
351 | {0x73, 0x00}, | ||
352 | {0x70, 0x80}, | ||
353 | {0x71, 0x70}, | ||
354 | {0x72, 0x04}, | ||
355 | {0x73, 0x00}, | ||
356 | {0x70, 0xa0}, | ||
357 | {0x71, 0x70}, | ||
358 | {0x72, 0x04}, | ||
359 | {0x73, 0x00}, | ||
360 | {0x70, 0x1f}, | ||
361 | {0x76, 0x38}, | ||
362 | {0x77, 0xa6}, | ||
363 | {0x78, 0x0c}, | ||
364 | {0x79, 0x80}, | ||
365 | {0x7f, 0x14}, | ||
366 | {0x85, 0x08}, | ||
367 | {0xcd, 0xf4}, | ||
368 | {0x90, 0x33}, | ||
369 | {0x86, 0x00}, | ||
370 | {0x87, 0x0f}, | ||
371 | {0x89, 0x00}, | ||
372 | {0x8b, 0x44}, | ||
373 | {0x8c, 0x66}, | ||
374 | {0x9d, 0xc1}, | ||
375 | {0x8a, 0x10}, | ||
376 | {0xad, 0x40}, | ||
377 | {0xa0, 0x44}, | ||
378 | {0xbe, 0x00}, | ||
379 | {0xc0, 0x08}, | ||
380 | {0xc1, 0x10}, | ||
381 | {0xc2, 0x08}, | ||
382 | {0xc3, 0x10}, | ||
383 | {0xc4, 0x08}, | ||
384 | {0xc5, 0xf0}, | ||
385 | {0xc6, 0xff}, | ||
386 | {0xc7, 0x00}, | ||
387 | {0xc8, 0x1a}, | ||
388 | {0xc9, 0x80}, | ||
389 | {0xca, 0x23}, | ||
390 | {0xcb, 0x24}, | ||
391 | {0xcc, 0xf4}, | ||
392 | {0xce, 0x74}, | ||
393 | {0x00, 0x00}, | ||
394 | {0xbd, 0x01}, | ||
395 | {0xb8, 0x00}, | ||
396 | {0x29, 0x01}, | ||
397 | }; | ||
217 | #endif | 398 | #endif |
diff --git a/drivers/media/dvb-frontends/mn88472.h b/drivers/media/dvb-frontends/mn88472.h new file mode 100644 index 000000000000..da4558bce60f --- /dev/null +++ b/drivers/media/dvb-frontends/mn88472.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Panasonic MN88472 DVB-T/T2/C demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef MN88472_H | ||
18 | #define MN88472_H | ||
19 | |||
20 | #include <linux/dvb/frontend.h> | ||
21 | |||
22 | struct mn88472_config { | ||
23 | /* | ||
24 | * Max num of bytes given I2C adapter could write at once. | ||
25 | * Default: none | ||
26 | */ | ||
27 | u16 i2c_wr_max; | ||
28 | |||
29 | |||
30 | /* Everything after that is returned by the driver. */ | ||
31 | |||
32 | /* | ||
33 | * DVB frontend. | ||
34 | */ | ||
35 | struct dvb_frontend **fe; | ||
36 | }; | ||
37 | |||
38 | #endif | ||
diff --git a/drivers/media/dvb-frontends/mn88473.h b/drivers/media/dvb-frontends/mn88473.h new file mode 100644 index 000000000000..a373ec93cbe0 --- /dev/null +++ b/drivers/media/dvb-frontends/mn88473.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Panasonic MN88473 DVB-T/T2/C demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef MN88473_H | ||
18 | #define MN88473_H | ||
19 | |||
20 | #include <linux/dvb/frontend.h> | ||
21 | |||
22 | struct mn88473_config { | ||
23 | /* | ||
24 | * Max num of bytes given I2C adapter could write at once. | ||
25 | * Default: none | ||
26 | */ | ||
27 | u16 i2c_wr_max; | ||
28 | |||
29 | |||
30 | /* Everything after that is returned by the driver. */ | ||
31 | |||
32 | /* | ||
33 | * DVB frontend. | ||
34 | */ | ||
35 | struct dvb_frontend **fe; | ||
36 | }; | ||
37 | |||
38 | #endif | ||
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c index eb737cf29a36..9026e1aee163 100644 --- a/drivers/media/dvb-frontends/rtl2832.c +++ b/drivers/media/dvb-frontends/rtl2832.c | |||
@@ -258,13 +258,11 @@ static int rtl2832_rd_regs(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val, | |||
258 | return rtl2832_rd(priv, reg, val, len); | 258 | return rtl2832_rd(priv, reg, val, len); |
259 | } | 259 | } |
260 | 260 | ||
261 | #if 0 /* currently not used */ | ||
262 | /* write single register */ | 261 | /* write single register */ |
263 | static int rtl2832_wr_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 val) | 262 | static int rtl2832_wr_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 val) |
264 | { | 263 | { |
265 | return rtl2832_wr_regs(priv, reg, page, &val, 1); | 264 | return rtl2832_wr_regs(priv, reg, page, &val, 1); |
266 | } | 265 | } |
267 | #endif | ||
268 | 266 | ||
269 | /* read single register */ | 267 | /* read single register */ |
270 | static int rtl2832_rd_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val) | 268 | static int rtl2832_rd_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val) |
@@ -599,6 +597,11 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe) | |||
599 | if (fe->ops.tuner_ops.set_params) | 597 | if (fe->ops.tuner_ops.set_params) |
600 | fe->ops.tuner_ops.set_params(fe); | 598 | fe->ops.tuner_ops.set_params(fe); |
601 | 599 | ||
600 | /* PIP mode related */ | ||
601 | ret = rtl2832_wr_regs(priv, 0x92, 1, "\x00\x0f\xff", 3); | ||
602 | if (ret) | ||
603 | goto err; | ||
604 | |||
602 | /* If the frontend has get_if_frequency(), use it */ | 605 | /* If the frontend has get_if_frequency(), use it */ |
603 | if (fe->ops.tuner_ops.get_if_frequency) { | 606 | if (fe->ops.tuner_ops.get_if_frequency) { |
604 | u32 if_freq; | 607 | u32 if_freq; |
@@ -661,7 +664,6 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe) | |||
661 | if (ret) | 664 | if (ret) |
662 | goto err; | 665 | goto err; |
663 | 666 | ||
664 | |||
665 | /* soft reset */ | 667 | /* soft reset */ |
666 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x1); | 668 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x1); |
667 | if (ret) | 669 | if (ret) |
@@ -1020,6 +1022,58 @@ static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv, | |||
1020 | return 0; | 1022 | return 0; |
1021 | } | 1023 | } |
1022 | 1024 | ||
1025 | int rtl2832_enable_external_ts_if(struct dvb_frontend *fe) | ||
1026 | { | ||
1027 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
1028 | int ret; | ||
1029 | |||
1030 | dev_dbg(&priv->i2c->dev, "%s: setting PIP mode\n", __func__); | ||
1031 | |||
1032 | ret = rtl2832_wr_regs(priv, 0x0c, 1, "\x5f\xff", 2); | ||
1033 | if (ret) | ||
1034 | goto err; | ||
1035 | |||
1036 | ret = rtl2832_wr_demod_reg(priv, DVBT_PIP_ON, 0x1); | ||
1037 | if (ret) | ||
1038 | goto err; | ||
1039 | |||
1040 | ret = rtl2832_wr_reg(priv, 0xbc, 0, 0x18); | ||
1041 | if (ret) | ||
1042 | goto err; | ||
1043 | |||
1044 | ret = rtl2832_wr_reg(priv, 0x22, 0, 0x01); | ||
1045 | if (ret) | ||
1046 | goto err; | ||
1047 | |||
1048 | ret = rtl2832_wr_reg(priv, 0x26, 0, 0x1f); | ||
1049 | if (ret) | ||
1050 | goto err; | ||
1051 | |||
1052 | ret = rtl2832_wr_reg(priv, 0x27, 0, 0xff); | ||
1053 | if (ret) | ||
1054 | goto err; | ||
1055 | |||
1056 | ret = rtl2832_wr_regs(priv, 0x92, 1, "\x7f\xf7\xff", 3); | ||
1057 | if (ret) | ||
1058 | goto err; | ||
1059 | |||
1060 | /* soft reset */ | ||
1061 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x1); | ||
1062 | if (ret) | ||
1063 | goto err; | ||
1064 | |||
1065 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x0); | ||
1066 | if (ret) | ||
1067 | goto err; | ||
1068 | |||
1069 | return 0; | ||
1070 | err: | ||
1071 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); | ||
1072 | return ret; | ||
1073 | |||
1074 | } | ||
1075 | EXPORT_SYMBOL(rtl2832_enable_external_ts_if); | ||
1076 | |||
1023 | struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe) | 1077 | struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe) |
1024 | { | 1078 | { |
1025 | struct rtl2832_priv *priv = fe->demodulator_priv; | 1079 | struct rtl2832_priv *priv = fe->demodulator_priv; |
diff --git a/drivers/media/dvb-frontends/rtl2832.h b/drivers/media/dvb-frontends/rtl2832.h index cb3b6b0775b8..5254c1dfc8de 100644 --- a/drivers/media/dvb-frontends/rtl2832.h +++ b/drivers/media/dvb-frontends/rtl2832.h | |||
@@ -64,6 +64,10 @@ extern struct i2c_adapter *rtl2832_get_private_i2c_adapter( | |||
64 | struct dvb_frontend *fe | 64 | struct dvb_frontend *fe |
65 | ); | 65 | ); |
66 | 66 | ||
67 | extern int rtl2832_enable_external_ts_if( | ||
68 | struct dvb_frontend *fe | ||
69 | ); | ||
70 | |||
67 | #else | 71 | #else |
68 | 72 | ||
69 | static inline struct dvb_frontend *rtl2832_attach( | 73 | static inline struct dvb_frontend *rtl2832_attach( |
@@ -89,6 +93,13 @@ static inline struct i2c_adapter *rtl2832_get_private_i2c_adapter( | |||
89 | return NULL; | 93 | return NULL; |
90 | } | 94 | } |
91 | 95 | ||
96 | static inline int rtl2832_enable_external_ts_if( | ||
97 | struct dvb_frontend *fe | ||
98 | ) | ||
99 | { | ||
100 | return -ENODEV; | ||
101 | } | ||
102 | |||
92 | #endif | 103 | #endif |
93 | 104 | ||
94 | 105 | ||
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c index 7bf98cf6bbe1..2896b47c29d8 100644 --- a/drivers/media/dvb-frontends/rtl2832_sdr.c +++ b/drivers/media/dvb-frontends/rtl2832_sdr.c | |||
@@ -1013,6 +1013,10 @@ static int rtl2832_sdr_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
1013 | if (s->d->props->power_ctrl) | 1013 | if (s->d->props->power_ctrl) |
1014 | s->d->props->power_ctrl(s->d, 1); | 1014 | s->d->props->power_ctrl(s->d, 1); |
1015 | 1015 | ||
1016 | /* enable ADC */ | ||
1017 | if (s->d->props->frontend_ctrl) | ||
1018 | s->d->props->frontend_ctrl(s->fe, 1); | ||
1019 | |||
1016 | set_bit(POWER_ON, &s->flags); | 1020 | set_bit(POWER_ON, &s->flags); |
1017 | 1021 | ||
1018 | ret = rtl2832_sdr_set_tuner(s); | 1022 | ret = rtl2832_sdr_set_tuner(s); |
@@ -1064,6 +1068,10 @@ static void rtl2832_sdr_stop_streaming(struct vb2_queue *vq) | |||
1064 | 1068 | ||
1065 | clear_bit(POWER_ON, &s->flags); | 1069 | clear_bit(POWER_ON, &s->flags); |
1066 | 1070 | ||
1071 | /* disable ADC */ | ||
1072 | if (s->d->props->frontend_ctrl) | ||
1073 | s->d->props->frontend_ctrl(s->fe, 0); | ||
1074 | |||
1067 | if (s->d->props->power_ctrl) | 1075 | if (s->d->props->power_ctrl) |
1068 | s->d->props->power_ctrl(s->d, 0); | 1076 | s->d->props->power_ctrl(s->d, 0); |
1069 | 1077 | ||
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 1cd93be281ed..ce9ab442b4b6 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c | |||
@@ -308,14 +308,16 @@ static int si2168_set_frontend(struct dvb_frontend *fe) | |||
308 | if (ret) | 308 | if (ret) |
309 | goto err; | 309 | goto err; |
310 | 310 | ||
311 | memcpy(cmd.args, "\x14\x00\x09\x10\xe3\x18", 6); | 311 | memcpy(cmd.args, "\x14\x00\x09\x10\xe3\x08", 6); |
312 | cmd.args[5] |= s->ts_clock_inv ? 0x00 : 0x10; | ||
312 | cmd.wlen = 6; | 313 | cmd.wlen = 6; |
313 | cmd.rlen = 4; | 314 | cmd.rlen = 4; |
314 | ret = si2168_cmd_execute(s, &cmd); | 315 | ret = si2168_cmd_execute(s, &cmd); |
315 | if (ret) | 316 | if (ret) |
316 | goto err; | 317 | goto err; |
317 | 318 | ||
318 | memcpy(cmd.args, "\x14\x00\x08\x10\xd7\x15", 6); | 319 | memcpy(cmd.args, "\x14\x00\x08\x10\xd7\x05", 6); |
320 | cmd.args[5] |= s->ts_clock_inv ? 0x00 : 0x10; | ||
319 | cmd.wlen = 6; | 321 | cmd.wlen = 6; |
320 | cmd.rlen = 4; | 322 | cmd.rlen = 4; |
321 | ret = si2168_cmd_execute(s, &cmd); | 323 | ret = si2168_cmd_execute(s, &cmd); |
@@ -453,27 +455,45 @@ static int si2168_init(struct dvb_frontend *fe) | |||
453 | dev_err(&s->client->dev, | 455 | dev_err(&s->client->dev, |
454 | "firmware file '%s' not found\n", | 456 | "firmware file '%s' not found\n", |
455 | fw_file); | 457 | fw_file); |
456 | goto err; | 458 | goto error_fw_release; |
457 | } | 459 | } |
458 | } | 460 | } |
459 | 461 | ||
460 | dev_info(&s->client->dev, "downloading firmware from file '%s'\n", | 462 | dev_info(&s->client->dev, "downloading firmware from file '%s'\n", |
461 | fw_file); | 463 | fw_file); |
462 | 464 | ||
463 | for (remaining = fw->size; remaining > 0; remaining -= i2c_wr_max) { | 465 | if ((fw->size % 17 == 0) && (fw->data[0] > 5)) { |
464 | len = remaining; | 466 | /* firmware is in the new format */ |
465 | if (len > i2c_wr_max) | 467 | for (remaining = fw->size; remaining > 0; remaining -= 17) { |
466 | len = i2c_wr_max; | 468 | len = fw->data[fw->size - remaining]; |
467 | 469 | memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); | |
468 | memcpy(cmd.args, &fw->data[fw->size - remaining], len); | 470 | cmd.wlen = len; |
469 | cmd.wlen = len; | 471 | cmd.rlen = 1; |
470 | cmd.rlen = 1; | 472 | ret = si2168_cmd_execute(s, &cmd); |
471 | ret = si2168_cmd_execute(s, &cmd); | 473 | if (ret) { |
472 | if (ret) { | 474 | dev_err(&s->client->dev, |
473 | dev_err(&s->client->dev, | 475 | "firmware download failed=%d\n", |
474 | "firmware download failed=%d\n", | 476 | ret); |
475 | ret); | 477 | goto error_fw_release; |
476 | goto err; | 478 | } |
479 | } | ||
480 | } else { | ||
481 | /* firmware is in the old format */ | ||
482 | for (remaining = fw->size; remaining > 0; remaining -= i2c_wr_max) { | ||
483 | len = remaining; | ||
484 | if (len > i2c_wr_max) | ||
485 | len = i2c_wr_max; | ||
486 | |||
487 | memcpy(cmd.args, &fw->data[fw->size - remaining], len); | ||
488 | cmd.wlen = len; | ||
489 | cmd.rlen = 1; | ||
490 | ret = si2168_cmd_execute(s, &cmd); | ||
491 | if (ret) { | ||
492 | dev_err(&s->client->dev, | ||
493 | "firmware download failed=%d\n", | ||
494 | ret); | ||
495 | goto error_fw_release; | ||
496 | } | ||
477 | } | 497 | } |
478 | } | 498 | } |
479 | 499 | ||
@@ -487,6 +507,17 @@ static int si2168_init(struct dvb_frontend *fe) | |||
487 | if (ret) | 507 | if (ret) |
488 | goto err; | 508 | goto err; |
489 | 509 | ||
510 | /* query firmware version */ | ||
511 | memcpy(cmd.args, "\x11", 1); | ||
512 | cmd.wlen = 1; | ||
513 | cmd.rlen = 10; | ||
514 | ret = si2168_cmd_execute(s, &cmd); | ||
515 | if (ret) | ||
516 | goto err; | ||
517 | |||
518 | dev_dbg(&s->client->dev, "firmware version: %c.%c.%d\n", | ||
519 | cmd.args[6], cmd.args[7], cmd.args[8]); | ||
520 | |||
490 | /* set ts mode */ | 521 | /* set ts mode */ |
491 | memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6); | 522 | memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6); |
492 | cmd.args[4] |= s->ts_mode; | 523 | cmd.args[4] |= s->ts_mode; |
@@ -498,17 +529,16 @@ static int si2168_init(struct dvb_frontend *fe) | |||
498 | 529 | ||
499 | s->fw_loaded = true; | 530 | s->fw_loaded = true; |
500 | 531 | ||
501 | warm: | ||
502 | dev_info(&s->client->dev, "found a '%s' in warm state\n", | 532 | dev_info(&s->client->dev, "found a '%s' in warm state\n", |
503 | si2168_ops.info.name); | 533 | si2168_ops.info.name); |
504 | 534 | warm: | |
505 | s->active = true; | 535 | s->active = true; |
506 | 536 | ||
507 | return 0; | 537 | return 0; |
508 | err: | ||
509 | if (fw) | ||
510 | release_firmware(fw); | ||
511 | 538 | ||
539 | error_fw_release: | ||
540 | release_firmware(fw); | ||
541 | err: | ||
512 | dev_dbg(&s->client->dev, "failed=%d\n", ret); | 542 | dev_dbg(&s->client->dev, "failed=%d\n", ret); |
513 | return ret; | 543 | return ret; |
514 | } | 544 | } |
@@ -670,6 +700,7 @@ static int si2168_probe(struct i2c_client *client, | |||
670 | *config->i2c_adapter = s->adapter; | 700 | *config->i2c_adapter = s->adapter; |
671 | *config->fe = &s->fe; | 701 | *config->fe = &s->fe; |
672 | s->ts_mode = config->ts_mode; | 702 | s->ts_mode = config->ts_mode; |
703 | s->ts_clock_inv = config->ts_clock_inv; | ||
673 | s->fw_loaded = false; | 704 | s->fw_loaded = false; |
674 | 705 | ||
675 | i2c_set_clientdata(client, s); | 706 | i2c_set_clientdata(client, s); |
diff --git a/drivers/media/dvb-frontends/si2168.h b/drivers/media/dvb-frontends/si2168.h index e086d6719451..87bc12146667 100644 --- a/drivers/media/dvb-frontends/si2168.h +++ b/drivers/media/dvb-frontends/si2168.h | |||
@@ -37,6 +37,10 @@ struct si2168_config { | |||
37 | 37 | ||
38 | /* TS mode */ | 38 | /* TS mode */ |
39 | u8 ts_mode; | 39 | u8 ts_mode; |
40 | |||
41 | /* TS clock inverted */ | ||
42 | bool ts_clock_inv; | ||
43 | |||
40 | }; | 44 | }; |
41 | 45 | ||
42 | #define SI2168_TS_PARALLEL 0x06 | 46 | #define SI2168_TS_PARALLEL 0x06 |
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h index e13983ed4be1..60bc3349b6c3 100644 --- a/drivers/media/dvb-frontends/si2168_priv.h +++ b/drivers/media/dvb-frontends/si2168_priv.h | |||
@@ -38,6 +38,7 @@ struct si2168 { | |||
38 | bool active; | 38 | bool active; |
39 | bool fw_loaded; | 39 | bool fw_loaded; |
40 | u8 ts_mode; | 40 | u8 ts_mode; |
41 | bool ts_clock_inv; | ||
41 | }; | 42 | }; |
42 | 43 | ||
43 | /* firmare command struct */ | 44 | /* firmare command struct */ |
diff --git a/drivers/media/dvb-frontends/sp2.c b/drivers/media/dvb-frontends/sp2.c index 15bf4318cb74..cc1ef966f99f 100644 --- a/drivers/media/dvb-frontends/sp2.c +++ b/drivers/media/dvb-frontends/sp2.c | |||
@@ -92,6 +92,9 @@ static int sp2_write_i2c(struct sp2 *s, u8 reg, u8 *buf, int len) | |||
92 | return -EIO; | 92 | return -EIO; |
93 | } | 93 | } |
94 | 94 | ||
95 | dev_dbg(&s->client->dev, "addr=0x%04x, reg = 0x%02x, data = %*ph\n", | ||
96 | client->addr, reg, len, buf); | ||
97 | |||
95 | return 0; | 98 | return 0; |
96 | } | 99 | } |
97 | 100 | ||
@@ -103,9 +106,6 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, u8 acs, | |||
103 | int mem, ret; | 106 | int mem, ret; |
104 | int (*ci_op_cam)(void*, u8, int, u8, int*) = s->ci_control; | 107 | int (*ci_op_cam)(void*, u8, int, u8, int*) = s->ci_control; |
105 | 108 | ||
106 | dev_dbg(&s->client->dev, "slot=%d, acs=0x%02x, addr=0x%04x, data = 0x%02x", | ||
107 | slot, acs, addr, data); | ||
108 | |||
109 | if (slot != 0) | 109 | if (slot != 0) |
110 | return -EINVAL; | 110 | return -EINVAL; |
111 | 111 | ||
@@ -140,13 +140,16 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, u8 acs, | |||
140 | if (ret) | 140 | if (ret) |
141 | return ret; | 141 | return ret; |
142 | 142 | ||
143 | if (read) { | 143 | dev_dbg(&s->client->dev, "%s: slot=%d, addr=0x%04x, %s, data=%x", |
144 | dev_dbg(&s->client->dev, "cam read, addr=0x%04x, data = 0x%04x", | 144 | (read) ? "read" : "write", slot, addr, |
145 | addr, mem); | 145 | (acs == SP2_CI_ATTR_ACS) ? "attr" : "io", |
146 | (read) ? mem : data); | ||
147 | |||
148 | if (read) | ||
146 | return mem; | 149 | return mem; |
147 | } else { | 150 | else |
148 | return 0; | 151 | return 0; |
149 | } | 152 | |
150 | } | 153 | } |
151 | 154 | ||
152 | int sp2_ci_read_attribute_mem(struct dvb_ca_en50221 *en50221, | 155 | int sp2_ci_read_attribute_mem(struct dvb_ca_en50221 *en50221, |
@@ -407,7 +410,7 @@ err: | |||
407 | 410 | ||
408 | static int sp2_remove(struct i2c_client *client) | 411 | static int sp2_remove(struct i2c_client *client) |
409 | { | 412 | { |
410 | struct si2157 *s = i2c_get_clientdata(client); | 413 | struct sp2 *s = i2c_get_clientdata(client); |
411 | 414 | ||
412 | dev_dbg(&client->dev, "\n"); | 415 | dev_dbg(&client->dev, "\n"); |
413 | 416 | ||
diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 07cd5ea7a038..19646fbb061d 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c | |||
@@ -705,7 +705,7 @@ static int stb0899_send_diseqc_msg(struct dvb_frontend *fe, struct dvb_diseqc_ma | |||
705 | struct stb0899_state *state = fe->demodulator_priv; | 705 | struct stb0899_state *state = fe->demodulator_priv; |
706 | u8 reg, i; | 706 | u8 reg, i; |
707 | 707 | ||
708 | if (cmd->msg_len > 8) | 708 | if (cmd->msg_len > sizeof(cmd->msg)) |
709 | return -EINVAL; | 709 | return -EINVAL; |
710 | 710 | ||
711 | /* enable FIFO precharge */ | 711 | /* enable FIFO precharge */ |
diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c index 23e872f84742..0b2a934f53e5 100644 --- a/drivers/media/dvb-frontends/stv090x.c +++ b/drivers/media/dvb-frontends/stv090x.c | |||
@@ -2146,7 +2146,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) | |||
2146 | 2146 | ||
2147 | u32 reg; | 2147 | u32 reg; |
2148 | s32 car_step, steps, cur_step, dir, freq, timeout_lock; | 2148 | s32 car_step, steps, cur_step, dir, freq, timeout_lock; |
2149 | int lock = 0; | 2149 | int lock; |
2150 | 2150 | ||
2151 | if (state->srate >= 10000000) | 2151 | if (state->srate >= 10000000) |
2152 | timeout_lock = timeout_dmd / 3; | 2152 | timeout_lock = timeout_dmd / 3; |
@@ -2154,98 +2154,96 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) | |||
2154 | timeout_lock = timeout_dmd / 2; | 2154 | timeout_lock = timeout_dmd / 2; |
2155 | 2155 | ||
2156 | lock = stv090x_get_dmdlock(state, timeout_lock); /* cold start wait */ | 2156 | lock = stv090x_get_dmdlock(state, timeout_lock); /* cold start wait */ |
2157 | if (!lock) { | 2157 | if (lock) |
2158 | if (state->srate >= 10000000) { | 2158 | return lock; |
2159 | if (stv090x_chk_tmg(state)) { | ||
2160 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) | ||
2161 | goto err; | ||
2162 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0) | ||
2163 | goto err; | ||
2164 | lock = stv090x_get_dmdlock(state, timeout_dmd); | ||
2165 | } else { | ||
2166 | lock = 0; | ||
2167 | } | ||
2168 | } else { | ||
2169 | if (state->srate <= 4000000) | ||
2170 | car_step = 1000; | ||
2171 | else if (state->srate <= 7000000) | ||
2172 | car_step = 2000; | ||
2173 | else if (state->srate <= 10000000) | ||
2174 | car_step = 3000; | ||
2175 | else | ||
2176 | car_step = 5000; | ||
2177 | |||
2178 | steps = (state->search_range / 1000) / car_step; | ||
2179 | steps /= 2; | ||
2180 | steps = 2 * (steps + 1); | ||
2181 | if (steps < 0) | ||
2182 | steps = 2; | ||
2183 | else if (steps > 12) | ||
2184 | steps = 12; | ||
2185 | |||
2186 | cur_step = 1; | ||
2187 | dir = 1; | ||
2188 | |||
2189 | if (!lock) { | ||
2190 | freq = state->frequency; | ||
2191 | state->tuner_bw = stv090x_car_width(state->srate, state->rolloff) + state->srate; | ||
2192 | while ((cur_step <= steps) && (!lock)) { | ||
2193 | if (dir > 0) | ||
2194 | freq += cur_step * car_step; | ||
2195 | else | ||
2196 | freq -= cur_step * car_step; | ||
2197 | |||
2198 | /* Setup tuner */ | ||
2199 | if (stv090x_i2c_gate_ctrl(state, 1) < 0) | ||
2200 | goto err; | ||
2201 | 2159 | ||
2202 | if (state->config->tuner_set_frequency) { | 2160 | if (state->srate >= 10000000) { |
2203 | if (state->config->tuner_set_frequency(fe, freq) < 0) | 2161 | if (stv090x_chk_tmg(state)) { |
2204 | goto err_gateoff; | 2162 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) |
2205 | } | 2163 | goto err; |
2164 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0) | ||
2165 | goto err; | ||
2166 | return stv090x_get_dmdlock(state, timeout_dmd); | ||
2167 | } | ||
2168 | return 0; | ||
2169 | } | ||
2206 | 2170 | ||
2207 | if (state->config->tuner_set_bandwidth) { | 2171 | if (state->srate <= 4000000) |
2208 | if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0) | 2172 | car_step = 1000; |
2209 | goto err_gateoff; | 2173 | else if (state->srate <= 7000000) |
2210 | } | 2174 | car_step = 2000; |
2175 | else if (state->srate <= 10000000) | ||
2176 | car_step = 3000; | ||
2177 | else | ||
2178 | car_step = 5000; | ||
2211 | 2179 | ||
2212 | if (stv090x_i2c_gate_ctrl(state, 0) < 0) | 2180 | steps = (state->search_range / 1000) / car_step; |
2213 | goto err; | 2181 | steps /= 2; |
2182 | steps = 2 * (steps + 1); | ||
2183 | if (steps < 0) | ||
2184 | steps = 2; | ||
2185 | else if (steps > 12) | ||
2186 | steps = 12; | ||
2214 | 2187 | ||
2215 | msleep(50); | 2188 | cur_step = 1; |
2189 | dir = 1; | ||
2216 | 2190 | ||
2217 | if (stv090x_i2c_gate_ctrl(state, 1) < 0) | 2191 | freq = state->frequency; |
2218 | goto err; | 2192 | state->tuner_bw = stv090x_car_width(state->srate, state->rolloff) + state->srate; |
2193 | while ((cur_step <= steps) && (!lock)) { | ||
2194 | if (dir > 0) | ||
2195 | freq += cur_step * car_step; | ||
2196 | else | ||
2197 | freq -= cur_step * car_step; | ||
2219 | 2198 | ||
2220 | if (state->config->tuner_get_status) { | 2199 | /* Setup tuner */ |
2221 | if (state->config->tuner_get_status(fe, ®) < 0) | 2200 | if (stv090x_i2c_gate_ctrl(state, 1) < 0) |
2222 | goto err_gateoff; | 2201 | goto err; |
2223 | } | ||
2224 | 2202 | ||
2225 | if (reg) | 2203 | if (state->config->tuner_set_frequency) { |
2226 | dprintk(FE_DEBUG, 1, "Tuner phase locked"); | 2204 | if (state->config->tuner_set_frequency(fe, freq) < 0) |
2227 | else | 2205 | goto err_gateoff; |
2228 | dprintk(FE_DEBUG, 1, "Tuner unlocked"); | 2206 | } |
2229 | 2207 | ||
2230 | if (stv090x_i2c_gate_ctrl(state, 0) < 0) | 2208 | if (state->config->tuner_set_bandwidth) { |
2231 | goto err; | 2209 | if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0) |
2210 | goto err_gateoff; | ||
2211 | } | ||
2232 | 2212 | ||
2233 | STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); | 2213 | if (stv090x_i2c_gate_ctrl(state, 0) < 0) |
2234 | if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) | 2214 | goto err; |
2235 | goto err; | ||
2236 | if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) | ||
2237 | goto err; | ||
2238 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) | ||
2239 | goto err; | ||
2240 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0) | ||
2241 | goto err; | ||
2242 | lock = stv090x_get_dmdlock(state, (timeout_dmd / 3)); | ||
2243 | 2215 | ||
2244 | dir *= -1; | 2216 | msleep(50); |
2245 | cur_step++; | 2217 | |
2246 | } | 2218 | if (stv090x_i2c_gate_ctrl(state, 1) < 0) |
2247 | } | 2219 | goto err; |
2220 | |||
2221 | if (state->config->tuner_get_status) { | ||
2222 | if (state->config->tuner_get_status(fe, ®) < 0) | ||
2223 | goto err_gateoff; | ||
2248 | } | 2224 | } |
2225 | |||
2226 | if (reg) | ||
2227 | dprintk(FE_DEBUG, 1, "Tuner phase locked"); | ||
2228 | else | ||
2229 | dprintk(FE_DEBUG, 1, "Tuner unlocked"); | ||
2230 | |||
2231 | if (stv090x_i2c_gate_ctrl(state, 0) < 0) | ||
2232 | goto err; | ||
2233 | |||
2234 | STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); | ||
2235 | if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) | ||
2236 | goto err; | ||
2237 | if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) | ||
2238 | goto err; | ||
2239 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) | ||
2240 | goto err; | ||
2241 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0) | ||
2242 | goto err; | ||
2243 | lock = stv090x_get_dmdlock(state, (timeout_dmd / 3)); | ||
2244 | |||
2245 | dir *= -1; | ||
2246 | cur_step++; | ||
2249 | } | 2247 | } |
2250 | 2248 | ||
2251 | return lock; | 2249 | return lock; |
@@ -2663,13 +2661,9 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st | |||
2663 | return STV090x_RANGEOK; | 2661 | return STV090x_RANGEOK; |
2664 | else if (abs(offst_freq) <= (stv090x_car_width(state->srate, state->rolloff) / 2000)) | 2662 | else if (abs(offst_freq) <= (stv090x_car_width(state->srate, state->rolloff) / 2000)) |
2665 | return STV090x_RANGEOK; | 2663 | return STV090x_RANGEOK; |
2666 | else | ||
2667 | return STV090x_OUTOFRANGE; /* Out of Range */ | ||
2668 | } else { | 2664 | } else { |
2669 | if (abs(offst_freq) <= ((state->search_range / 2000) + 500)) | 2665 | if (abs(offst_freq) <= ((state->search_range / 2000) + 500)) |
2670 | return STV090x_RANGEOK; | 2666 | return STV090x_RANGEOK; |
2671 | else | ||
2672 | return STV090x_OUTOFRANGE; | ||
2673 | } | 2667 | } |
2674 | 2668 | ||
2675 | return STV090x_OUTOFRANGE; | 2669 | return STV090x_OUTOFRANGE; |
@@ -2789,6 +2783,12 @@ static u8 stv090x_optimize_carloop(struct stv090x_state *state, enum stv090x_mod | |||
2789 | aclc = car_loop[i].crl_pilots_off_30; | 2783 | aclc = car_loop[i].crl_pilots_off_30; |
2790 | } | 2784 | } |
2791 | } else { /* 16APSK and 32APSK */ | 2785 | } else { /* 16APSK and 32APSK */ |
2786 | /* | ||
2787 | * This should never happen in practice, except if | ||
2788 | * something is really wrong at the car_loop table. | ||
2789 | */ | ||
2790 | if (i >= 11) | ||
2791 | i = 10; | ||
2792 | if (state->srate <= 3000000) | 2792 | if (state->srate <= 3000000) |
2793 | aclc = car_loop_apsk_low[i].crl_pilots_on_2; | 2793 | aclc = car_loop_apsk_low[i].crl_pilots_on_2; |
2794 | else if (state->srate <= 7000000) | 2794 | else if (state->srate <= 7000000) |
@@ -3470,7 +3470,20 @@ static enum dvbfe_search stv090x_search(struct dvb_frontend *fe) | |||
3470 | if (props->frequency == 0) | 3470 | if (props->frequency == 0) |
3471 | return DVBFE_ALGO_SEARCH_INVALID; | 3471 | return DVBFE_ALGO_SEARCH_INVALID; |
3472 | 3472 | ||
3473 | state->delsys = props->delivery_system; | 3473 | switch (props->delivery_system) { |
3474 | case SYS_DSS: | ||
3475 | state->delsys = STV090x_DSS; | ||
3476 | break; | ||
3477 | case SYS_DVBS: | ||
3478 | state->delsys = STV090x_DVBS1; | ||
3479 | break; | ||
3480 | case SYS_DVBS2: | ||
3481 | state->delsys = STV090x_DVBS2; | ||
3482 | break; | ||
3483 | default: | ||
3484 | return DVBFE_ALGO_SEARCH_INVALID; | ||
3485 | } | ||
3486 | |||
3474 | state->frequency = props->frequency; | 3487 | state->frequency = props->frequency; |
3475 | state->srate = props->symbol_rate; | 3488 | state->srate = props->symbol_rate; |
3476 | state->search_mode = STV090x_SEARCH_AUTO; | 3489 | state->search_mode = STV090x_SEARCH_AUTO; |
@@ -4859,8 +4872,8 @@ err: | |||
4859 | return -1; | 4872 | return -1; |
4860 | } | 4873 | } |
4861 | 4874 | ||
4862 | int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value, | 4875 | static int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir, |
4863 | u8 xor_value) | 4876 | u8 value, u8 xor_value) |
4864 | { | 4877 | { |
4865 | struct stv090x_state *state = fe->demodulator_priv; | 4878 | struct stv090x_state *state = fe->demodulator_priv; |
4866 | u8 reg = 0; | 4879 | u8 reg = 0; |
@@ -4871,7 +4884,6 @@ int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value, | |||
4871 | 4884 | ||
4872 | return stv090x_write_reg(state, STV090x_GPIOxCFG(gpio), reg); | 4885 | return stv090x_write_reg(state, STV090x_GPIOxCFG(gpio), reg); |
4873 | } | 4886 | } |
4874 | EXPORT_SYMBOL(stv090x_set_gpio); | ||
4875 | 4887 | ||
4876 | static struct dvb_frontend_ops stv090x_ops = { | 4888 | static struct dvb_frontend_ops stv090x_ops = { |
4877 | .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, | 4889 | .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, |
@@ -4908,7 +4920,7 @@ static struct dvb_frontend_ops stv090x_ops = { | |||
4908 | }; | 4920 | }; |
4909 | 4921 | ||
4910 | 4922 | ||
4911 | struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, | 4923 | struct dvb_frontend *stv090x_attach(struct stv090x_config *config, |
4912 | struct i2c_adapter *i2c, | 4924 | struct i2c_adapter *i2c, |
4913 | enum stv090x_demodulator demod) | 4925 | enum stv090x_demodulator demod) |
4914 | { | 4926 | { |
@@ -4969,6 +4981,8 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, | |||
4969 | if (config->diseqc_envelope_mode) | 4981 | if (config->diseqc_envelope_mode) |
4970 | stv090x_send_diseqc_burst(&state->frontend, SEC_MINI_A); | 4982 | stv090x_send_diseqc_burst(&state->frontend, SEC_MINI_A); |
4971 | 4983 | ||
4984 | config->set_gpio = stv090x_set_gpio; | ||
4985 | |||
4972 | dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x", | 4986 | dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x", |
4973 | state->device == STV0900 ? "STV0900" : "STV0903", | 4987 | state->device == STV0900 ? "STV0900" : "STV0903", |
4974 | demod, | 4988 | demod, |
diff --git a/drivers/media/dvb-frontends/stv090x.h b/drivers/media/dvb-frontends/stv090x.h index 0bd6adcfee8a..742eeda99000 100644 --- a/drivers/media/dvb-frontends/stv090x.h +++ b/drivers/media/dvb-frontends/stv090x.h | |||
@@ -89,29 +89,29 @@ struct stv090x_config { | |||
89 | 89 | ||
90 | bool diseqc_envelope_mode; | 90 | bool diseqc_envelope_mode; |
91 | 91 | ||
92 | int (*tuner_init) (struct dvb_frontend *fe); | 92 | int (*tuner_init)(struct dvb_frontend *fe); |
93 | int (*tuner_sleep) (struct dvb_frontend *fe); | 93 | int (*tuner_sleep)(struct dvb_frontend *fe); |
94 | int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode); | 94 | int (*tuner_set_mode)(struct dvb_frontend *fe, enum tuner_mode mode); |
95 | int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency); | 95 | int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency); |
96 | int (*tuner_get_frequency) (struct dvb_frontend *fe, u32 *frequency); | 96 | int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency); |
97 | int (*tuner_set_bandwidth) (struct dvb_frontend *fe, u32 bandwidth); | 97 | int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth); |
98 | int (*tuner_get_bandwidth) (struct dvb_frontend *fe, u32 *bandwidth); | 98 | int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); |
99 | int (*tuner_set_bbgain) (struct dvb_frontend *fe, u32 gain); | 99 | int (*tuner_set_bbgain)(struct dvb_frontend *fe, u32 gain); |
100 | int (*tuner_get_bbgain) (struct dvb_frontend *fe, u32 *gain); | 100 | int (*tuner_get_bbgain)(struct dvb_frontend *fe, u32 *gain); |
101 | int (*tuner_set_refclk) (struct dvb_frontend *fe, u32 refclk); | 101 | int (*tuner_set_refclk)(struct dvb_frontend *fe, u32 refclk); |
102 | int (*tuner_get_status) (struct dvb_frontend *fe, u32 *status); | 102 | int (*tuner_get_status)(struct dvb_frontend *fe, u32 *status); |
103 | void (*tuner_i2c_lock) (struct dvb_frontend *fe, int lock); | 103 | void (*tuner_i2c_lock)(struct dvb_frontend *fe, int lock); |
104 | |||
105 | /* dir = 0 -> output, dir = 1 -> input/open-drain */ | ||
106 | int (*set_gpio)(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value, | ||
107 | u8 xor_value); | ||
104 | }; | 108 | }; |
105 | 109 | ||
106 | #if IS_ENABLED(CONFIG_DVB_STV090x) | 110 | #if IS_ENABLED(CONFIG_DVB_STV090x) |
107 | 111 | ||
108 | extern struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, | 112 | struct dvb_frontend *stv090x_attach(struct stv090x_config *config, |
109 | struct i2c_adapter *i2c, | 113 | struct i2c_adapter *i2c, |
110 | enum stv090x_demodulator demod); | 114 | enum stv090x_demodulator demod); |
111 | |||
112 | /* dir = 0 -> output, dir = 1 -> input/open-drain */ | ||
113 | extern int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, | ||
114 | u8 dir, u8 value, u8 xor_value); | ||
115 | 115 | ||
116 | #else | 116 | #else |
117 | 117 | ||
@@ -123,12 +123,6 @@ static inline struct dvb_frontend *stv090x_attach(const struct stv090x_config *c | |||
123 | return NULL; | 123 | return NULL; |
124 | } | 124 | } |
125 | 125 | ||
126 | static inline int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, | ||
127 | u8 opd, u8 value, u8 xor_value) | ||
128 | { | ||
129 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
130 | return -ENODEV; | ||
131 | } | ||
132 | #endif /* CONFIG_DVB_STV090x */ | 126 | #endif /* CONFIG_DVB_STV090x */ |
133 | 127 | ||
134 | #endif /* __STV090x_H */ | 128 | #endif /* __STV090x_H */ |
diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c index e5ebdbfe8c19..e63f582378bf 100644 --- a/drivers/media/firewire/firedtv-ci.c +++ b/drivers/media/firewire/firedtv-ci.c | |||
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv) | |||
253 | 253 | ||
254 | void fdtv_ca_release(struct firedtv *fdtv) | 254 | void fdtv_ca_release(struct firedtv *fdtv) |
255 | { | 255 | { |
256 | if (fdtv->cadev) | 256 | dvb_unregister_device(fdtv->cadev); |
257 | dvb_unregister_device(fdtv->cadev); | ||
258 | } | 257 | } |
diff --git a/drivers/media/firewire/firedtv.h b/drivers/media/firewire/firedtv.h index c2ba085e0d20..346a85be6de2 100644 --- a/drivers/media/firewire/firedtv.h +++ b/drivers/media/firewire/firedtv.h | |||
@@ -96,7 +96,7 @@ struct firedtv { | |||
96 | 96 | ||
97 | enum model_type type; | 97 | enum model_type type; |
98 | char subunit; | 98 | char subunit; |
99 | char isochannel; | 99 | s8 isochannel; |
100 | struct fdtv_ir_context *ir_context; | 100 | struct fdtv_ir_context *ir_context; |
101 | 101 | ||
102 | fe_sec_voltage_t voltage; | 102 | fe_sec_voltage_t voltage; |
diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c index 04bb29720aaf..40a1a95c7ce9 100644 --- a/drivers/media/i2c/adv7170.c +++ b/drivers/media/i2c/adv7170.c | |||
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev *sd) | |||
63 | 63 | ||
64 | static char *inputs[] = { "pass_through", "play_back" }; | 64 | static char *inputs[] = { "pass_through", "play_back" }; |
65 | 65 | ||
66 | static enum v4l2_mbus_pixelcode adv7170_codes[] = { | 66 | static u32 adv7170_codes[] = { |
67 | V4L2_MBUS_FMT_UYVY8_2X8, | 67 | MEDIA_BUS_FMT_UYVY8_2X8, |
68 | V4L2_MBUS_FMT_UYVY8_1X16, | 68 | MEDIA_BUS_FMT_UYVY8_1X16, |
69 | }; | 69 | }; |
70 | 70 | ||
71 | /* ----------------------------------------------------------------------- */ | 71 | /* ----------------------------------------------------------------------- */ |
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd, | |||
263 | } | 263 | } |
264 | 264 | ||
265 | static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 265 | static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
266 | enum v4l2_mbus_pixelcode *code) | 266 | u32 *code) |
267 | { | 267 | { |
268 | if (index >= ARRAY_SIZE(adv7170_codes)) | 268 | if (index >= ARRAY_SIZE(adv7170_codes)) |
269 | return -EINVAL; | 269 | return -EINVAL; |
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd, | |||
278 | u8 val = adv7170_read(sd, 0x7); | 278 | u8 val = adv7170_read(sd, 0x7); |
279 | 279 | ||
280 | if ((val & 0x40) == (1 << 6)) | 280 | if ((val & 0x40) == (1 << 6)) |
281 | mf->code = V4L2_MBUS_FMT_UYVY8_1X16; | 281 | mf->code = MEDIA_BUS_FMT_UYVY8_1X16; |
282 | else | 282 | else |
283 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 283 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
284 | 284 | ||
285 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; | 285 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; |
286 | mf->width = 0; | 286 | mf->width = 0; |
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd, | |||
297 | int ret; | 297 | int ret; |
298 | 298 | ||
299 | switch (mf->code) { | 299 | switch (mf->code) { |
300 | case V4L2_MBUS_FMT_UYVY8_2X8: | 300 | case MEDIA_BUS_FMT_UYVY8_2X8: |
301 | val &= ~0x40; | 301 | val &= ~0x40; |
302 | break; | 302 | break; |
303 | 303 | ||
304 | case V4L2_MBUS_FMT_UYVY8_1X16: | 304 | case MEDIA_BUS_FMT_UYVY8_1X16: |
305 | val |= 0x40; | 305 | val |= 0x40; |
306 | break; | 306 | break; |
307 | 307 | ||
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c index b88f3b3d5ed9..d220af579a64 100644 --- a/drivers/media/i2c/adv7175.c +++ b/drivers/media/i2c/adv7175.c | |||
@@ -60,9 +60,9 @@ static inline struct adv7175 *to_adv7175(struct v4l2_subdev *sd) | |||
60 | 60 | ||
61 | static char *inputs[] = { "pass_through", "play_back", "color_bar" }; | 61 | static char *inputs[] = { "pass_through", "play_back", "color_bar" }; |
62 | 62 | ||
63 | static enum v4l2_mbus_pixelcode adv7175_codes[] = { | 63 | static u32 adv7175_codes[] = { |
64 | V4L2_MBUS_FMT_UYVY8_2X8, | 64 | MEDIA_BUS_FMT_UYVY8_2X8, |
65 | V4L2_MBUS_FMT_UYVY8_1X16, | 65 | MEDIA_BUS_FMT_UYVY8_1X16, |
66 | }; | 66 | }; |
67 | 67 | ||
68 | /* ----------------------------------------------------------------------- */ | 68 | /* ----------------------------------------------------------------------- */ |
@@ -301,7 +301,7 @@ static int adv7175_s_routing(struct v4l2_subdev *sd, | |||
301 | } | 301 | } |
302 | 302 | ||
303 | static int adv7175_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 303 | static int adv7175_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
304 | enum v4l2_mbus_pixelcode *code) | 304 | u32 *code) |
305 | { | 305 | { |
306 | if (index >= ARRAY_SIZE(adv7175_codes)) | 306 | if (index >= ARRAY_SIZE(adv7175_codes)) |
307 | return -EINVAL; | 307 | return -EINVAL; |
@@ -316,9 +316,9 @@ static int adv7175_g_fmt(struct v4l2_subdev *sd, | |||
316 | u8 val = adv7175_read(sd, 0x7); | 316 | u8 val = adv7175_read(sd, 0x7); |
317 | 317 | ||
318 | if ((val & 0x40) == (1 << 6)) | 318 | if ((val & 0x40) == (1 << 6)) |
319 | mf->code = V4L2_MBUS_FMT_UYVY8_1X16; | 319 | mf->code = MEDIA_BUS_FMT_UYVY8_1X16; |
320 | else | 320 | else |
321 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 321 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
322 | 322 | ||
323 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; | 323 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; |
324 | mf->width = 0; | 324 | mf->width = 0; |
@@ -335,11 +335,11 @@ static int adv7175_s_fmt(struct v4l2_subdev *sd, | |||
335 | int ret; | 335 | int ret; |
336 | 336 | ||
337 | switch (mf->code) { | 337 | switch (mf->code) { |
338 | case V4L2_MBUS_FMT_UYVY8_2X8: | 338 | case MEDIA_BUS_FMT_UYVY8_2X8: |
339 | val &= ~0x40; | 339 | val &= ~0x40; |
340 | break; | 340 | break; |
341 | 341 | ||
342 | case V4L2_MBUS_FMT_UYVY8_1X16: | 342 | case MEDIA_BUS_FMT_UYVY8_1X16: |
343 | val |= 0x40; | 343 | val |= 0x40; |
344 | break; | 344 | break; |
345 | 345 | ||
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 821178dcb08e..bffe6eb528a3 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c | |||
@@ -422,12 +422,12 @@ static void adv7180_exit_controls(struct adv7180_state *state) | |||
422 | } | 422 | } |
423 | 423 | ||
424 | static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, | 424 | static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, |
425 | enum v4l2_mbus_pixelcode *code) | 425 | u32 *code) |
426 | { | 426 | { |
427 | if (index > 0) | 427 | if (index > 0) |
428 | return -EINVAL; | 428 | return -EINVAL; |
429 | 429 | ||
430 | *code = V4L2_MBUS_FMT_YUYV8_2X8; | 430 | *code = MEDIA_BUS_FMT_YUYV8_2X8; |
431 | 431 | ||
432 | return 0; | 432 | return 0; |
433 | } | 433 | } |
@@ -437,7 +437,7 @@ static int adv7180_mbus_fmt(struct v4l2_subdev *sd, | |||
437 | { | 437 | { |
438 | struct adv7180_state *state = to_state(sd); | 438 | struct adv7180_state *state = to_state(sd); |
439 | 439 | ||
440 | fmt->code = V4L2_MBUS_FMT_YUYV8_2X8; | 440 | fmt->code = MEDIA_BUS_FMT_YUYV8_2X8; |
441 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; | 441 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; |
442 | fmt->field = V4L2_FIELD_INTERLACED; | 442 | fmt->field = V4L2_FIELD_INTERLACED; |
443 | fmt->width = 720; | 443 | fmt->width = 720; |
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index df461b07b2f7..28940cc3a766 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c | |||
@@ -421,12 +421,12 @@ static int adv7183_g_input_status(struct v4l2_subdev *sd, u32 *status) | |||
421 | } | 421 | } |
422 | 422 | ||
423 | static int adv7183_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 423 | static int adv7183_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
424 | enum v4l2_mbus_pixelcode *code) | 424 | u32 *code) |
425 | { | 425 | { |
426 | if (index > 0) | 426 | if (index > 0) |
427 | return -EINVAL; | 427 | return -EINVAL; |
428 | 428 | ||
429 | *code = V4L2_MBUS_FMT_UYVY8_2X8; | 429 | *code = MEDIA_BUS_FMT_UYVY8_2X8; |
430 | return 0; | 430 | return 0; |
431 | } | 431 | } |
432 | 432 | ||
@@ -435,7 +435,7 @@ static int adv7183_try_mbus_fmt(struct v4l2_subdev *sd, | |||
435 | { | 435 | { |
436 | struct adv7183 *decoder = to_adv7183(sd); | 436 | struct adv7183 *decoder = to_adv7183(sd); |
437 | 437 | ||
438 | fmt->code = V4L2_MBUS_FMT_UYVY8_2X8; | 438 | fmt->code = MEDIA_BUS_FMT_UYVY8_2X8; |
439 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; | 439 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; |
440 | if (decoder->std & V4L2_STD_525_60) { | 440 | if (decoder->std & V4L2_STD_525_60) { |
441 | fmt->field = V4L2_FIELD_SEQ_TB; | 441 | fmt->field = V4L2_FIELD_SEQ_TB; |
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c index f98acf4aafd4..81736aaf0f31 100644 --- a/drivers/media/i2c/adv7511.c +++ b/drivers/media/i2c/adv7511.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/videodev2.h> | 26 | #include <linux/videodev2.h> |
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/workqueue.h> | 28 | #include <linux/workqueue.h> |
29 | #include <linux/hdmi.h> | ||
29 | #include <linux/v4l2-dv-timings.h> | 30 | #include <linux/v4l2-dv-timings.h> |
30 | #include <media/v4l2-device.h> | 31 | #include <media/v4l2-device.h> |
31 | #include <media/v4l2-common.h> | 32 | #include <media/v4l2-common.h> |
@@ -96,6 +97,10 @@ struct adv7511_state { | |||
96 | bool have_monitor; | 97 | bool have_monitor; |
97 | /* timings from s_dv_timings */ | 98 | /* timings from s_dv_timings */ |
98 | struct v4l2_dv_timings dv_timings; | 99 | struct v4l2_dv_timings dv_timings; |
100 | u32 fmt_code; | ||
101 | u32 colorspace; | ||
102 | u32 ycbcr_enc; | ||
103 | u32 quantization; | ||
99 | /* controls */ | 104 | /* controls */ |
100 | struct v4l2_ctrl *hdmi_mode_ctrl; | 105 | struct v4l2_ctrl *hdmi_mode_ctrl; |
101 | struct v4l2_ctrl *hotplug_ctrl; | 106 | struct v4l2_ctrl *hotplug_ctrl; |
@@ -779,26 +784,234 @@ static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
779 | { | 784 | { |
780 | struct adv7511_state *state = get_adv7511_state(sd); | 785 | struct adv7511_state *state = get_adv7511_state(sd); |
781 | 786 | ||
787 | memset(edid->reserved, 0, sizeof(edid->reserved)); | ||
788 | |||
782 | if (edid->pad != 0) | 789 | if (edid->pad != 0) |
783 | return -EINVAL; | 790 | return -EINVAL; |
784 | if ((edid->blocks == 0) || (edid->blocks > 256)) | 791 | |
785 | return -EINVAL; | 792 | if (edid->start_block == 0 && edid->blocks == 0) { |
786 | if (!state->edid.segments) { | 793 | edid->blocks = state->edid.segments * 2; |
787 | v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n"); | 794 | return 0; |
788 | return -ENODATA; | ||
789 | } | 795 | } |
796 | |||
797 | if (state->edid.segments == 0) | ||
798 | return -ENODATA; | ||
799 | |||
790 | if (edid->start_block >= state->edid.segments * 2) | 800 | if (edid->start_block >= state->edid.segments * 2) |
791 | return -E2BIG; | 801 | return -EINVAL; |
792 | if ((edid->blocks + edid->start_block) >= state->edid.segments * 2) | 802 | |
803 | if (edid->start_block + edid->blocks > state->edid.segments * 2) | ||
793 | edid->blocks = state->edid.segments * 2 - edid->start_block; | 804 | edid->blocks = state->edid.segments * 2 - edid->start_block; |
794 | 805 | ||
795 | memcpy(edid->edid, &state->edid.data[edid->start_block * 128], | 806 | memcpy(edid->edid, &state->edid.data[edid->start_block * 128], |
796 | 128 * edid->blocks); | 807 | 128 * edid->blocks); |
808 | |||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | static int adv7511_enum_mbus_code(struct v4l2_subdev *sd, | ||
813 | struct v4l2_subdev_fh *fh, | ||
814 | struct v4l2_subdev_mbus_code_enum *code) | ||
815 | { | ||
816 | if (code->pad != 0) | ||
817 | return -EINVAL; | ||
818 | |||
819 | switch (code->index) { | ||
820 | case 0: | ||
821 | code->code = MEDIA_BUS_FMT_RGB888_1X24; | ||
822 | break; | ||
823 | case 1: | ||
824 | code->code = MEDIA_BUS_FMT_YUYV8_1X16; | ||
825 | break; | ||
826 | case 2: | ||
827 | code->code = MEDIA_BUS_FMT_UYVY8_1X16; | ||
828 | break; | ||
829 | default: | ||
830 | return -EINVAL; | ||
831 | } | ||
832 | return 0; | ||
833 | } | ||
834 | |||
835 | static void adv7511_fill_format(struct adv7511_state *state, | ||
836 | struct v4l2_mbus_framefmt *format) | ||
837 | { | ||
838 | memset(format, 0, sizeof(*format)); | ||
839 | |||
840 | format->width = state->dv_timings.bt.width; | ||
841 | format->height = state->dv_timings.bt.height; | ||
842 | format->field = V4L2_FIELD_NONE; | ||
843 | } | ||
844 | |||
845 | static int adv7511_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | ||
846 | struct v4l2_subdev_format *format) | ||
847 | { | ||
848 | struct adv7511_state *state = get_adv7511_state(sd); | ||
849 | |||
850 | if (format->pad != 0) | ||
851 | return -EINVAL; | ||
852 | |||
853 | adv7511_fill_format(state, &format->format); | ||
854 | |||
855 | if (format->which == V4L2_SUBDEV_FORMAT_TRY) { | ||
856 | struct v4l2_mbus_framefmt *fmt; | ||
857 | |||
858 | fmt = v4l2_subdev_get_try_format(fh, format->pad); | ||
859 | format->format.code = fmt->code; | ||
860 | format->format.colorspace = fmt->colorspace; | ||
861 | format->format.ycbcr_enc = fmt->ycbcr_enc; | ||
862 | format->format.quantization = fmt->quantization; | ||
863 | } else { | ||
864 | format->format.code = state->fmt_code; | ||
865 | format->format.colorspace = state->colorspace; | ||
866 | format->format.ycbcr_enc = state->ycbcr_enc; | ||
867 | format->format.quantization = state->quantization; | ||
868 | } | ||
869 | |||
870 | return 0; | ||
871 | } | ||
872 | |||
873 | static int adv7511_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | ||
874 | struct v4l2_subdev_format *format) | ||
875 | { | ||
876 | struct adv7511_state *state = get_adv7511_state(sd); | ||
877 | /* | ||
878 | * Bitfield namings come the CEA-861-F standard, table 8 "Auxiliary | ||
879 | * Video Information (AVI) InfoFrame Format" | ||
880 | * | ||
881 | * c = Colorimetry | ||
882 | * ec = Extended Colorimetry | ||
883 | * y = RGB or YCbCr | ||
884 | * q = RGB Quantization Range | ||
885 | * yq = YCC Quantization Range | ||
886 | */ | ||
887 | u8 c = HDMI_COLORIMETRY_NONE; | ||
888 | u8 ec = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; | ||
889 | u8 y = HDMI_COLORSPACE_RGB; | ||
890 | u8 q = HDMI_QUANTIZATION_RANGE_DEFAULT; | ||
891 | u8 yq = HDMI_YCC_QUANTIZATION_RANGE_LIMITED; | ||
892 | |||
893 | if (format->pad != 0) | ||
894 | return -EINVAL; | ||
895 | switch (format->format.code) { | ||
896 | case MEDIA_BUS_FMT_UYVY8_1X16: | ||
897 | case MEDIA_BUS_FMT_YUYV8_1X16: | ||
898 | case MEDIA_BUS_FMT_RGB888_1X24: | ||
899 | break; | ||
900 | default: | ||
901 | return -EINVAL; | ||
902 | } | ||
903 | |||
904 | adv7511_fill_format(state, &format->format); | ||
905 | if (format->which == V4L2_SUBDEV_FORMAT_TRY) { | ||
906 | struct v4l2_mbus_framefmt *fmt; | ||
907 | |||
908 | fmt = v4l2_subdev_get_try_format(fh, format->pad); | ||
909 | fmt->code = format->format.code; | ||
910 | fmt->colorspace = format->format.colorspace; | ||
911 | fmt->ycbcr_enc = format->format.ycbcr_enc; | ||
912 | fmt->quantization = format->format.quantization; | ||
913 | return 0; | ||
914 | } | ||
915 | |||
916 | switch (format->format.code) { | ||
917 | case MEDIA_BUS_FMT_UYVY8_1X16: | ||
918 | adv7511_wr_and_or(sd, 0x15, 0xf0, 0x01); | ||
919 | adv7511_wr_and_or(sd, 0x16, 0x03, 0xb8); | ||
920 | y = HDMI_COLORSPACE_YUV422; | ||
921 | break; | ||
922 | case MEDIA_BUS_FMT_YUYV8_1X16: | ||
923 | adv7511_wr_and_or(sd, 0x15, 0xf0, 0x01); | ||
924 | adv7511_wr_and_or(sd, 0x16, 0x03, 0xbc); | ||
925 | y = HDMI_COLORSPACE_YUV422; | ||
926 | break; | ||
927 | case MEDIA_BUS_FMT_RGB888_1X24: | ||
928 | default: | ||
929 | adv7511_wr_and_or(sd, 0x15, 0xf0, 0x00); | ||
930 | adv7511_wr_and_or(sd, 0x16, 0x03, 0x00); | ||
931 | break; | ||
932 | } | ||
933 | state->fmt_code = format->format.code; | ||
934 | state->colorspace = format->format.colorspace; | ||
935 | state->ycbcr_enc = format->format.ycbcr_enc; | ||
936 | state->quantization = format->format.quantization; | ||
937 | |||
938 | switch (format->format.colorspace) { | ||
939 | case V4L2_COLORSPACE_ADOBERGB: | ||
940 | c = HDMI_COLORIMETRY_EXTENDED; | ||
941 | ec = y ? HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : | ||
942 | HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB; | ||
943 | break; | ||
944 | case V4L2_COLORSPACE_SMPTE170M: | ||
945 | c = y ? HDMI_COLORIMETRY_ITU_601 : HDMI_COLORIMETRY_NONE; | ||
946 | if (y && format->format.ycbcr_enc == V4L2_YCBCR_ENC_XV601) { | ||
947 | c = HDMI_COLORIMETRY_EXTENDED; | ||
948 | ec = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; | ||
949 | } | ||
950 | break; | ||
951 | case V4L2_COLORSPACE_REC709: | ||
952 | c = y ? HDMI_COLORIMETRY_ITU_709 : HDMI_COLORIMETRY_NONE; | ||
953 | if (y && format->format.ycbcr_enc == V4L2_YCBCR_ENC_XV709) { | ||
954 | c = HDMI_COLORIMETRY_EXTENDED; | ||
955 | ec = HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; | ||
956 | } | ||
957 | break; | ||
958 | case V4L2_COLORSPACE_SRGB: | ||
959 | c = y ? HDMI_COLORIMETRY_EXTENDED : HDMI_COLORIMETRY_NONE; | ||
960 | ec = y ? HDMI_EXTENDED_COLORIMETRY_S_YCC_601 : | ||
961 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; | ||
962 | break; | ||
963 | case V4L2_COLORSPACE_BT2020: | ||
964 | c = HDMI_COLORIMETRY_EXTENDED; | ||
965 | if (y && format->format.ycbcr_enc == V4L2_YCBCR_ENC_BT2020_CONST_LUM) | ||
966 | ec = 5; /* Not yet available in hdmi.h */ | ||
967 | else | ||
968 | ec = 6; /* Not yet available in hdmi.h */ | ||
969 | break; | ||
970 | default: | ||
971 | break; | ||
972 | } | ||
973 | |||
974 | /* | ||
975 | * CEA-861-F says that for RGB formats the YCC range must match the | ||
976 | * RGB range, although sources should ignore the YCC range. | ||
977 | * | ||
978 | * The RGB quantization range shouldn't be non-zero if the EDID doesn't | ||
979 | * have the Q bit set in the Video Capabilities Data Block, however this | ||
980 | * isn't checked at the moment. The assumption is that the application | ||
981 | * knows the EDID and can detect this. | ||
982 | * | ||
983 | * The same is true for the YCC quantization range: non-standard YCC | ||
984 | * quantization ranges should only be sent if the EDID has the YQ bit | ||
985 | * set in the Video Capabilities Data Block. | ||
986 | */ | ||
987 | switch (format->format.quantization) { | ||
988 | case V4L2_QUANTIZATION_FULL_RANGE: | ||
989 | q = y ? HDMI_QUANTIZATION_RANGE_DEFAULT : | ||
990 | HDMI_QUANTIZATION_RANGE_FULL; | ||
991 | yq = q ? q - 1 : HDMI_YCC_QUANTIZATION_RANGE_FULL; | ||
992 | break; | ||
993 | case V4L2_QUANTIZATION_LIM_RANGE: | ||
994 | q = y ? HDMI_QUANTIZATION_RANGE_DEFAULT : | ||
995 | HDMI_QUANTIZATION_RANGE_LIMITED; | ||
996 | yq = q ? q - 1 : HDMI_YCC_QUANTIZATION_RANGE_LIMITED; | ||
997 | break; | ||
998 | } | ||
999 | |||
1000 | adv7511_wr_and_or(sd, 0x4a, 0xbf, 0); | ||
1001 | adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5); | ||
1002 | adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6); | ||
1003 | adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2)); | ||
1004 | adv7511_wr_and_or(sd, 0x59, 0x0f, yq << 4); | ||
1005 | adv7511_wr_and_or(sd, 0x4a, 0xff, 1); | ||
1006 | |||
797 | return 0; | 1007 | return 0; |
798 | } | 1008 | } |
799 | 1009 | ||
800 | static const struct v4l2_subdev_pad_ops adv7511_pad_ops = { | 1010 | static const struct v4l2_subdev_pad_ops adv7511_pad_ops = { |
801 | .get_edid = adv7511_get_edid, | 1011 | .get_edid = adv7511_get_edid, |
1012 | .enum_mbus_code = adv7511_enum_mbus_code, | ||
1013 | .get_fmt = adv7511_get_fmt, | ||
1014 | .set_fmt = adv7511_set_fmt, | ||
802 | .enum_dv_timings = adv7511_enum_dv_timings, | 1015 | .enum_dv_timings = adv7511_enum_dv_timings, |
803 | .dv_timings_cap = adv7511_dv_timings_cap, | 1016 | .dv_timings_cap = adv7511_dv_timings_cap, |
804 | }; | 1017 | }; |
@@ -1116,6 +1329,8 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id * | |||
1116 | return -ENODEV; | 1329 | return -ENODEV; |
1117 | } | 1330 | } |
1118 | memcpy(&state->pdata, pdata, sizeof(state->pdata)); | 1331 | memcpy(&state->pdata, pdata, sizeof(state->pdata)); |
1332 | state->fmt_code = MEDIA_BUS_FMT_RGB888_1X24; | ||
1333 | state->colorspace = V4L2_COLORSPACE_SRGB; | ||
1119 | 1334 | ||
1120 | sd = &state->sd; | 1335 | sd = &state->sd; |
1121 | 1336 | ||
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 47795ff71688..e43dd2e2a38a 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c | |||
@@ -88,7 +88,7 @@ struct adv7604_reg_seq { | |||
88 | }; | 88 | }; |
89 | 89 | ||
90 | struct adv7604_format_info { | 90 | struct adv7604_format_info { |
91 | enum v4l2_mbus_pixelcode code; | 91 | u32 code; |
92 | u8 op_ch_sel; | 92 | u8 op_ch_sel; |
93 | bool rgb_out; | 93 | bool rgb_out; |
94 | bool swap_cb_cr; | 94 | bool swap_cb_cr; |
@@ -749,77 +749,77 @@ static void adv7604_write_reg_seq(struct v4l2_subdev *sd, | |||
749 | */ | 749 | */ |
750 | 750 | ||
751 | static const struct adv7604_format_info adv7604_formats[] = { | 751 | static const struct adv7604_format_info adv7604_formats[] = { |
752 | { V4L2_MBUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false, | 752 | { MEDIA_BUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false, |
753 | ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT }, | 753 | ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT }, |
754 | { V4L2_MBUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false, | 754 | { MEDIA_BUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false, |
755 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, | 755 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, |
756 | { V4L2_MBUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true, | 756 | { MEDIA_BUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true, |
757 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, | 757 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, |
758 | { V4L2_MBUS_FMT_YUYV10_2X10, ADV7604_OP_CH_SEL_RGB, false, false, | 758 | { MEDIA_BUS_FMT_YUYV10_2X10, ADV7604_OP_CH_SEL_RGB, false, false, |
759 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT }, | 759 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT }, |
760 | { V4L2_MBUS_FMT_YVYU10_2X10, ADV7604_OP_CH_SEL_RGB, false, true, | 760 | { MEDIA_BUS_FMT_YVYU10_2X10, ADV7604_OP_CH_SEL_RGB, false, true, |
761 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT }, | 761 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_10BIT }, |
762 | { V4L2_MBUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false, | 762 | { MEDIA_BUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false, |
763 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, | 763 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, |
764 | { V4L2_MBUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true, | 764 | { MEDIA_BUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true, |
765 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, | 765 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, |
766 | { V4L2_MBUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false, | 766 | { MEDIA_BUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false, |
767 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 767 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
768 | { V4L2_MBUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true, | 768 | { MEDIA_BUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true, |
769 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 769 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
770 | { V4L2_MBUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false, | 770 | { MEDIA_BUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false, |
771 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 771 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
772 | { V4L2_MBUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true, | 772 | { MEDIA_BUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true, |
773 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 773 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
774 | { V4L2_MBUS_FMT_UYVY10_1X20, ADV7604_OP_CH_SEL_RBG, false, false, | 774 | { MEDIA_BUS_FMT_UYVY10_1X20, ADV7604_OP_CH_SEL_RBG, false, false, |
775 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, | 775 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, |
776 | { V4L2_MBUS_FMT_VYUY10_1X20, ADV7604_OP_CH_SEL_RBG, false, true, | 776 | { MEDIA_BUS_FMT_VYUY10_1X20, ADV7604_OP_CH_SEL_RBG, false, true, |
777 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, | 777 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, |
778 | { V4L2_MBUS_FMT_YUYV10_1X20, ADV7604_OP_CH_SEL_RGB, false, false, | 778 | { MEDIA_BUS_FMT_YUYV10_1X20, ADV7604_OP_CH_SEL_RGB, false, false, |
779 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, | 779 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, |
780 | { V4L2_MBUS_FMT_YVYU10_1X20, ADV7604_OP_CH_SEL_RGB, false, true, | 780 | { MEDIA_BUS_FMT_YVYU10_1X20, ADV7604_OP_CH_SEL_RGB, false, true, |
781 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, | 781 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_10BIT }, |
782 | { V4L2_MBUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false, | 782 | { MEDIA_BUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false, |
783 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 783 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
784 | { V4L2_MBUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true, | 784 | { MEDIA_BUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true, |
785 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 785 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
786 | { V4L2_MBUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false, | 786 | { MEDIA_BUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false, |
787 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 787 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
788 | { V4L2_MBUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true, | 788 | { MEDIA_BUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true, |
789 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 789 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
790 | }; | 790 | }; |
791 | 791 | ||
792 | static const struct adv7604_format_info adv7611_formats[] = { | 792 | static const struct adv7604_format_info adv7611_formats[] = { |
793 | { V4L2_MBUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false, | 793 | { MEDIA_BUS_FMT_RGB888_1X24, ADV7604_OP_CH_SEL_RGB, true, false, |
794 | ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT }, | 794 | ADV7604_OP_MODE_SEL_SDR_444 | ADV7604_OP_FORMAT_SEL_8BIT }, |
795 | { V4L2_MBUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false, | 795 | { MEDIA_BUS_FMT_YUYV8_2X8, ADV7604_OP_CH_SEL_RGB, false, false, |
796 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, | 796 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, |
797 | { V4L2_MBUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true, | 797 | { MEDIA_BUS_FMT_YVYU8_2X8, ADV7604_OP_CH_SEL_RGB, false, true, |
798 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, | 798 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_8BIT }, |
799 | { V4L2_MBUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false, | 799 | { MEDIA_BUS_FMT_YUYV12_2X12, ADV7604_OP_CH_SEL_RGB, false, false, |
800 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, | 800 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, |
801 | { V4L2_MBUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true, | 801 | { MEDIA_BUS_FMT_YVYU12_2X12, ADV7604_OP_CH_SEL_RGB, false, true, |
802 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, | 802 | ADV7604_OP_MODE_SEL_SDR_422 | ADV7604_OP_FORMAT_SEL_12BIT }, |
803 | { V4L2_MBUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false, | 803 | { MEDIA_BUS_FMT_UYVY8_1X16, ADV7604_OP_CH_SEL_RBG, false, false, |
804 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 804 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
805 | { V4L2_MBUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true, | 805 | { MEDIA_BUS_FMT_VYUY8_1X16, ADV7604_OP_CH_SEL_RBG, false, true, |
806 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 806 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
807 | { V4L2_MBUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false, | 807 | { MEDIA_BUS_FMT_YUYV8_1X16, ADV7604_OP_CH_SEL_RGB, false, false, |
808 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 808 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
809 | { V4L2_MBUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true, | 809 | { MEDIA_BUS_FMT_YVYU8_1X16, ADV7604_OP_CH_SEL_RGB, false, true, |
810 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, | 810 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_8BIT }, |
811 | { V4L2_MBUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false, | 811 | { MEDIA_BUS_FMT_UYVY12_1X24, ADV7604_OP_CH_SEL_RBG, false, false, |
812 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 812 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
813 | { V4L2_MBUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true, | 813 | { MEDIA_BUS_FMT_VYUY12_1X24, ADV7604_OP_CH_SEL_RBG, false, true, |
814 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 814 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
815 | { V4L2_MBUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false, | 815 | { MEDIA_BUS_FMT_YUYV12_1X24, ADV7604_OP_CH_SEL_RGB, false, false, |
816 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 816 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
817 | { V4L2_MBUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true, | 817 | { MEDIA_BUS_FMT_YVYU12_1X24, ADV7604_OP_CH_SEL_RGB, false, true, |
818 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, | 818 | ADV7604_OP_MODE_SEL_SDR_422_2X | ADV7604_OP_FORMAT_SEL_12BIT }, |
819 | }; | 819 | }; |
820 | 820 | ||
821 | static const struct adv7604_format_info * | 821 | static const struct adv7604_format_info * |
822 | adv7604_format_info(struct adv7604_state *state, enum v4l2_mbus_pixelcode code) | 822 | adv7604_format_info(struct adv7604_state *state, u32 code) |
823 | { | 823 | { |
824 | unsigned int i; | 824 | unsigned int i; |
825 | 825 | ||
@@ -1917,7 +1917,7 @@ static int adv7604_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
1917 | 1917 | ||
1918 | info = adv7604_format_info(state, format->format.code); | 1918 | info = adv7604_format_info(state, format->format.code); |
1919 | if (info == NULL) | 1919 | if (info == NULL) |
1920 | info = adv7604_format_info(state, V4L2_MBUS_FMT_YUYV8_2X8); | 1920 | info = adv7604_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8); |
1921 | 1921 | ||
1922 | adv7604_fill_format(state, &format->format); | 1922 | adv7604_fill_format(state, &format->format); |
1923 | format->format.code = info->code; | 1923 | format->format.code = info->code; |
@@ -1997,19 +1997,7 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
1997 | struct adv7604_state *state = to_state(sd); | 1997 | struct adv7604_state *state = to_state(sd); |
1998 | u8 *data = NULL; | 1998 | u8 *data = NULL; |
1999 | 1999 | ||
2000 | if (edid->pad > ADV7604_PAD_HDMI_PORT_D) | 2000 | memset(edid->reserved, 0, sizeof(edid->reserved)); |
2001 | return -EINVAL; | ||
2002 | if (edid->blocks == 0) | ||
2003 | return -EINVAL; | ||
2004 | if (edid->blocks > 2) | ||
2005 | return -EINVAL; | ||
2006 | if (edid->start_block > 1) | ||
2007 | return -EINVAL; | ||
2008 | if (edid->start_block == 1) | ||
2009 | edid->blocks = 1; | ||
2010 | |||
2011 | if (edid->blocks > state->edid.blocks) | ||
2012 | edid->blocks = state->edid.blocks; | ||
2013 | 2001 | ||
2014 | switch (edid->pad) { | 2002 | switch (edid->pad) { |
2015 | case ADV7604_PAD_HDMI_PORT_A: | 2003 | case ADV7604_PAD_HDMI_PORT_A: |
@@ -2021,14 +2009,24 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
2021 | break; | 2009 | break; |
2022 | default: | 2010 | default: |
2023 | return -EINVAL; | 2011 | return -EINVAL; |
2024 | break; | ||
2025 | } | 2012 | } |
2026 | if (!data) | 2013 | |
2014 | if (edid->start_block == 0 && edid->blocks == 0) { | ||
2015 | edid->blocks = data ? state->edid.blocks : 0; | ||
2016 | return 0; | ||
2017 | } | ||
2018 | |||
2019 | if (data == NULL) | ||
2027 | return -ENODATA; | 2020 | return -ENODATA; |
2028 | 2021 | ||
2029 | memcpy(edid->edid, | 2022 | if (edid->start_block >= state->edid.blocks) |
2030 | data + edid->start_block * 128, | 2023 | return -EINVAL; |
2031 | edid->blocks * 128); | 2024 | |
2025 | if (edid->start_block + edid->blocks > state->edid.blocks) | ||
2026 | edid->blocks = state->edid.blocks - edid->start_block; | ||
2027 | |||
2028 | memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128); | ||
2029 | |||
2032 | return 0; | 2030 | return 0; |
2033 | } | 2031 | } |
2034 | 2032 | ||
@@ -2068,6 +2066,8 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
2068 | int err; | 2066 | int err; |
2069 | int i; | 2067 | int i; |
2070 | 2068 | ||
2069 | memset(edid->reserved, 0, sizeof(edid->reserved)); | ||
2070 | |||
2071 | if (edid->pad > ADV7604_PAD_HDMI_PORT_D) | 2071 | if (edid->pad > ADV7604_PAD_HDMI_PORT_D) |
2072 | return -EINVAL; | 2072 | return -EINVAL; |
2073 | if (edid->start_block != 0) | 2073 | if (edid->start_block != 0) |
@@ -2164,7 +2164,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
2164 | return -EIO; | 2164 | return -EIO; |
2165 | } | 2165 | } |
2166 | 2166 | ||
2167 | |||
2168 | /* enable hotplug after 100 ms */ | 2167 | /* enable hotplug after 100 ms */ |
2169 | queue_delayed_work(state->work_queues, | 2168 | queue_delayed_work(state->work_queues, |
2170 | &state->delayed_work_enable_hotplug, HZ / 10); | 2169 | &state->delayed_work_enable_hotplug, HZ / 10); |
@@ -2807,7 +2806,7 @@ static int adv7604_probe(struct i2c_client *client, | |||
2807 | } | 2806 | } |
2808 | 2807 | ||
2809 | state->timings = cea640x480; | 2808 | state->timings = cea640x480; |
2810 | state->format = adv7604_format_info(state, V4L2_MBUS_FMT_YUYV8_2X8); | 2809 | state->format = adv7604_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8); |
2811 | 2810 | ||
2812 | sd = &state->sd; | 2811 | sd = &state->sd; |
2813 | v4l2_i2c_subdev_init(sd, client, &adv7604_ops); | 2812 | v4l2_i2c_subdev_init(sd, client, &adv7604_ops); |
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 48b628bc6714..75d26dfd0939 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c | |||
@@ -1877,12 +1877,12 @@ static int adv7842_s_routing(struct v4l2_subdev *sd, | |||
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | static int adv7842_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, | 1879 | static int adv7842_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, |
1880 | enum v4l2_mbus_pixelcode *code) | 1880 | u32 *code) |
1881 | { | 1881 | { |
1882 | if (index) | 1882 | if (index) |
1883 | return -EINVAL; | 1883 | return -EINVAL; |
1884 | /* Good enough for now */ | 1884 | /* Good enough for now */ |
1885 | *code = V4L2_MBUS_FMT_FIXED; | 1885 | *code = MEDIA_BUS_FMT_FIXED; |
1886 | return 0; | 1886 | return 0; |
1887 | } | 1887 | } |
1888 | 1888 | ||
@@ -1893,7 +1893,7 @@ static int adv7842_g_mbus_fmt(struct v4l2_subdev *sd, | |||
1893 | 1893 | ||
1894 | fmt->width = state->timings.bt.width; | 1894 | fmt->width = state->timings.bt.width; |
1895 | fmt->height = state->timings.bt.height; | 1895 | fmt->height = state->timings.bt.height; |
1896 | fmt->code = V4L2_MBUS_FMT_FIXED; | 1896 | fmt->code = MEDIA_BUS_FMT_FIXED; |
1897 | fmt->field = V4L2_FIELD_NONE; | 1897 | fmt->field = V4L2_FIELD_NONE; |
1898 | 1898 | ||
1899 | if (state->mode == ADV7842_MODE_SDP) { | 1899 | if (state->mode == ADV7842_MODE_SDP) { |
@@ -2028,16 +2028,7 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
2028 | struct adv7842_state *state = to_state(sd); | 2028 | struct adv7842_state *state = to_state(sd); |
2029 | u8 *data = NULL; | 2029 | u8 *data = NULL; |
2030 | 2030 | ||
2031 | if (edid->pad > ADV7842_EDID_PORT_VGA) | 2031 | memset(edid->reserved, 0, sizeof(edid->reserved)); |
2032 | return -EINVAL; | ||
2033 | if (edid->blocks == 0) | ||
2034 | return -EINVAL; | ||
2035 | if (edid->blocks > 2) | ||
2036 | return -EINVAL; | ||
2037 | if (edid->start_block > 1) | ||
2038 | return -EINVAL; | ||
2039 | if (edid->start_block == 1) | ||
2040 | edid->blocks = 1; | ||
2041 | 2032 | ||
2042 | switch (edid->pad) { | 2033 | switch (edid->pad) { |
2043 | case ADV7842_EDID_PORT_A: | 2034 | case ADV7842_EDID_PORT_A: |
@@ -2052,12 +2043,23 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) | |||
2052 | default: | 2043 | default: |
2053 | return -EINVAL; | 2044 | return -EINVAL; |
2054 | } | 2045 | } |
2046 | |||
2047 | if (edid->start_block == 0 && edid->blocks == 0) { | ||
2048 | edid->blocks = data ? 2 : 0; | ||
2049 | return 0; | ||
2050 | } | ||
2051 | |||
2055 | if (!data) | 2052 | if (!data) |
2056 | return -ENODATA; | 2053 | return -ENODATA; |
2057 | 2054 | ||
2058 | memcpy(edid->edid, | 2055 | if (edid->start_block >= 2) |
2059 | data + edid->start_block * 128, | 2056 | return -EINVAL; |
2060 | edid->blocks * 128); | 2057 | |
2058 | if (edid->start_block + edid->blocks > 2) | ||
2059 | edid->blocks = 2 - edid->start_block; | ||
2060 | |||
2061 | memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128); | ||
2062 | |||
2061 | return 0; | 2063 | return 0; |
2062 | } | 2064 | } |
2063 | 2065 | ||
@@ -2066,12 +2068,16 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e) | |||
2066 | struct adv7842_state *state = to_state(sd); | 2068 | struct adv7842_state *state = to_state(sd); |
2067 | int err = 0; | 2069 | int err = 0; |
2068 | 2070 | ||
2071 | memset(e->reserved, 0, sizeof(e->reserved)); | ||
2072 | |||
2069 | if (e->pad > ADV7842_EDID_PORT_VGA) | 2073 | if (e->pad > ADV7842_EDID_PORT_VGA) |
2070 | return -EINVAL; | 2074 | return -EINVAL; |
2071 | if (e->start_block != 0) | 2075 | if (e->start_block != 0) |
2072 | return -EINVAL; | 2076 | return -EINVAL; |
2073 | if (e->blocks > 2) | 2077 | if (e->blocks > 2) { |
2078 | e->blocks = 2; | ||
2074 | return -E2BIG; | 2079 | return -E2BIG; |
2080 | } | ||
2075 | 2081 | ||
2076 | /* todo, per edid */ | 2082 | /* todo, per edid */ |
2077 | state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15], | 2083 | state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15], |
diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c index c14e66756b98..69aeaf397624 100644 --- a/drivers/media/i2c/ak881x.c +++ b/drivers/media/i2c/ak881x.c | |||
@@ -102,7 +102,7 @@ static int ak881x_try_g_mbus_fmt(struct v4l2_subdev *sd, | |||
102 | v4l_bound_align_image(&mf->width, 0, 720, 2, | 102 | v4l_bound_align_image(&mf->width, 0, 720, 2, |
103 | &mf->height, 0, ak881x->lines, 1, 0); | 103 | &mf->height, 0, ak881x->lines, 1, 0); |
104 | mf->field = V4L2_FIELD_INTERLACED; | 104 | mf->field = V4L2_FIELD_INTERLACED; |
105 | mf->code = V4L2_MBUS_FMT_YUYV8_2X8; | 105 | mf->code = MEDIA_BUS_FMT_YUYV8_2X8; |
106 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; | 106 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; |
107 | 107 | ||
108 | return 0; | 108 | return 0; |
@@ -112,19 +112,19 @@ static int ak881x_s_mbus_fmt(struct v4l2_subdev *sd, | |||
112 | struct v4l2_mbus_framefmt *mf) | 112 | struct v4l2_mbus_framefmt *mf) |
113 | { | 113 | { |
114 | if (mf->field != V4L2_FIELD_INTERLACED || | 114 | if (mf->field != V4L2_FIELD_INTERLACED || |
115 | mf->code != V4L2_MBUS_FMT_YUYV8_2X8) | 115 | mf->code != MEDIA_BUS_FMT_YUYV8_2X8) |
116 | return -EINVAL; | 116 | return -EINVAL; |
117 | 117 | ||
118 | return ak881x_try_g_mbus_fmt(sd, mf); | 118 | return ak881x_try_g_mbus_fmt(sd, mf); |
119 | } | 119 | } |
120 | 120 | ||
121 | static int ak881x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, | 121 | static int ak881x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, |
122 | enum v4l2_mbus_pixelcode *code) | 122 | u32 *code) |
123 | { | 123 | { |
124 | if (index) | 124 | if (index) |
125 | return -EINVAL; | 125 | return -EINVAL; |
126 | 126 | ||
127 | *code = V4L2_MBUS_FMT_YUYV8_2X8; | 127 | *code = MEDIA_BUS_FMT_YUYV8_2X8; |
128 | return 0; | 128 | return 0; |
129 | } | 129 | } |
130 | 130 | ||
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index e453a3ffe7d1..573e08826b9b 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c | |||
@@ -879,7 +879,7 @@ void cx25840_std_setup(struct i2c_client *client) | |||
879 | /* Sets horizontal blanking delay and active lines */ | 879 | /* Sets horizontal blanking delay and active lines */ |
880 | cx25840_write(client, 0x470, hblank); | 880 | cx25840_write(client, 0x470, hblank); |
881 | cx25840_write(client, 0x471, | 881 | cx25840_write(client, 0x471, |
882 | 0xff & (((hblank >> 8) & 0x3) | (hactive << 4))); | 882 | (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff); |
883 | cx25840_write(client, 0x472, hactive >> 4); | 883 | cx25840_write(client, 0x472, hactive >> 4); |
884 | 884 | ||
885 | /* Sets burst gate delay */ | 885 | /* Sets burst gate delay */ |
@@ -888,13 +888,13 @@ void cx25840_std_setup(struct i2c_client *client) | |||
888 | /* Sets vertical blanking delay and active duration */ | 888 | /* Sets vertical blanking delay and active duration */ |
889 | cx25840_write(client, 0x474, vblank); | 889 | cx25840_write(client, 0x474, vblank); |
890 | cx25840_write(client, 0x475, | 890 | cx25840_write(client, 0x475, |
891 | 0xff & (((vblank >> 8) & 0x3) | (vactive << 4))); | 891 | (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff); |
892 | cx25840_write(client, 0x476, vactive >> 4); | 892 | cx25840_write(client, 0x476, vactive >> 4); |
893 | cx25840_write(client, 0x477, vblank656); | 893 | cx25840_write(client, 0x477, vblank656); |
894 | 894 | ||
895 | /* Sets src decimation rate */ | 895 | /* Sets src decimation rate */ |
896 | cx25840_write(client, 0x478, 0xff & src_decimation); | 896 | cx25840_write(client, 0x478, src_decimation & 0xff); |
897 | cx25840_write(client, 0x479, 0xff & (src_decimation >> 8)); | 897 | cx25840_write(client, 0x479, (src_decimation >> 8) & 0xff); |
898 | 898 | ||
899 | /* Sets Luma and UV Low pass filters */ | 899 | /* Sets Luma and UV Low pass filters */ |
900 | cx25840_write(client, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); | 900 | cx25840_write(client, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); |
@@ -904,8 +904,8 @@ void cx25840_std_setup(struct i2c_client *client) | |||
904 | 904 | ||
905 | /* Sets SC Step*/ | 905 | /* Sets SC Step*/ |
906 | cx25840_write(client, 0x47c, sc); | 906 | cx25840_write(client, 0x47c, sc); |
907 | cx25840_write(client, 0x47d, 0xff & sc >> 8); | 907 | cx25840_write(client, 0x47d, (sc >> 8) & 0xff); |
908 | cx25840_write(client, 0x47e, 0xff & sc >> 16); | 908 | cx25840_write(client, 0x47e, (sc >> 16) & 0xff); |
909 | 909 | ||
910 | /* Sets VBI parameters */ | 910 | /* Sets VBI parameters */ |
911 | if (std & V4L2_STD_625_50) { | 911 | if (std & V4L2_STD_625_50) { |
@@ -1373,7 +1373,7 @@ static int cx25840_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt | |||
1373 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; | 1373 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; |
1374 | int is_50Hz = !(state->std & V4L2_STD_525_60); | 1374 | int is_50Hz = !(state->std & V4L2_STD_525_60); |
1375 | 1375 | ||
1376 | if (fmt->code != V4L2_MBUS_FMT_FIXED) | 1376 | if (fmt->code != MEDIA_BUS_FMT_FIXED) |
1377 | return -EINVAL; | 1377 | return -EINVAL; |
1378 | 1378 | ||
1379 | fmt->field = V4L2_FIELD_INTERLACED; | 1379 | fmt->field = V4L2_FIELD_INTERLACED; |
diff --git a/drivers/media/i2c/cx25840/cx25840-firmware.c b/drivers/media/i2c/cx25840/cx25840-firmware.c index b3169f94ece8..9bbb31adc29d 100644 --- a/drivers/media/i2c/cx25840/cx25840-firmware.c +++ b/drivers/media/i2c/cx25840/cx25840-firmware.c | |||
@@ -113,7 +113,7 @@ int cx25840_loadfw(struct i2c_client *client) | |||
113 | const u8 *ptr; | 113 | const u8 *ptr; |
114 | const char *fwname = get_fw_name(client); | 114 | const char *fwname = get_fw_name(client); |
115 | int size, retval; | 115 | int size, retval; |
116 | int MAX_BUF_SIZE = FWSEND; | 116 | int max_buf_size = FWSEND; |
117 | u32 gpio_oe = 0, gpio_da = 0; | 117 | u32 gpio_oe = 0, gpio_da = 0; |
118 | 118 | ||
119 | if (is_cx2388x(state)) { | 119 | if (is_cx2388x(state)) { |
@@ -122,10 +122,9 @@ int cx25840_loadfw(struct i2c_client *client) | |||
122 | gpio_da = cx25840_read(client, 0x164); | 122 | gpio_da = cx25840_read(client, 0x164); |
123 | } | 123 | } |
124 | 124 | ||
125 | if (is_cx231xx(state) && MAX_BUF_SIZE > 16) { | 125 | /* cx231xx cannot accept more than 16 bytes at a time */ |
126 | v4l_err(client, " Firmware download size changed to 16 bytes max length\n"); | 126 | if (is_cx231xx(state) && max_buf_size > 16) |
127 | MAX_BUF_SIZE = 16; /* cx231xx cannot accept more than 16 bytes at a time */ | 127 | max_buf_size = 16; |
128 | } | ||
129 | 128 | ||
130 | if (request_firmware(&fw, fwname, FWDEV(client)) != 0) { | 129 | if (request_firmware(&fw, fwname, FWDEV(client)) != 0) { |
131 | v4l_err(client, "unable to open firmware %s\n", fwname); | 130 | v4l_err(client, "unable to open firmware %s\n", fwname); |
@@ -140,7 +139,7 @@ int cx25840_loadfw(struct i2c_client *client) | |||
140 | size = fw->size; | 139 | size = fw->size; |
141 | ptr = fw->data; | 140 | ptr = fw->data; |
142 | while (size > 0) { | 141 | while (size > 0) { |
143 | int len = min(MAX_BUF_SIZE - 2, size); | 142 | int len = min(max_buf_size - 2, size); |
144 | 143 | ||
145 | memcpy(buffer + 2, ptr, len); | 144 | memcpy(buffer + 2, ptr, len); |
146 | 145 | ||
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 8311f1a9a38e..175a76114953 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c | |||
@@ -464,8 +464,7 @@ static int ir_remove(struct i2c_client *client) | |||
464 | cancel_delayed_work_sync(&ir->work); | 464 | cancel_delayed_work_sync(&ir->work); |
465 | 465 | ||
466 | /* unregister device */ | 466 | /* unregister device */ |
467 | if (ir->rc) | 467 | rc_unregister_device(ir->rc); |
468 | rc_unregister_device(ir->rc); | ||
469 | 468 | ||
470 | /* free memory */ | 469 | /* free memory */ |
471 | return 0; | 470 | return 0; |
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 8d870b7b43ff..2820f7c38cba 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c | |||
@@ -57,14 +57,14 @@ static struct v4l2_mbus_framefmt m5mols_default_ffmt[M5MOLS_RESTYPE_MAX] = { | |||
57 | [M5MOLS_RESTYPE_MONITOR] = { | 57 | [M5MOLS_RESTYPE_MONITOR] = { |
58 | .width = 1920, | 58 | .width = 1920, |
59 | .height = 1080, | 59 | .height = 1080, |
60 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 60 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
61 | .field = V4L2_FIELD_NONE, | 61 | .field = V4L2_FIELD_NONE, |
62 | .colorspace = V4L2_COLORSPACE_JPEG, | 62 | .colorspace = V4L2_COLORSPACE_JPEG, |
63 | }, | 63 | }, |
64 | [M5MOLS_RESTYPE_CAPTURE] = { | 64 | [M5MOLS_RESTYPE_CAPTURE] = { |
65 | .width = 1920, | 65 | .width = 1920, |
66 | .height = 1080, | 66 | .height = 1080, |
67 | .code = V4L2_MBUS_FMT_JPEG_1X8, | 67 | .code = MEDIA_BUS_FMT_JPEG_1X8, |
68 | .field = V4L2_FIELD_NONE, | 68 | .field = V4L2_FIELD_NONE, |
69 | .colorspace = V4L2_COLORSPACE_JPEG, | 69 | .colorspace = V4L2_COLORSPACE_JPEG, |
70 | }, | 70 | }, |
@@ -479,7 +479,7 @@ static int m5mols_get_version(struct v4l2_subdev *sd) | |||
479 | * __find_restype - Lookup M-5MOLS resolution type according to pixel code | 479 | * __find_restype - Lookup M-5MOLS resolution type according to pixel code |
480 | * @code: pixel code | 480 | * @code: pixel code |
481 | */ | 481 | */ |
482 | static enum m5mols_restype __find_restype(enum v4l2_mbus_pixelcode code) | 482 | static enum m5mols_restype __find_restype(u32 code) |
483 | { | 483 | { |
484 | enum m5mols_restype type = M5MOLS_RESTYPE_MONITOR; | 484 | enum m5mols_restype type = M5MOLS_RESTYPE_MONITOR; |
485 | 485 | ||
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c index 2cace7313a22..d7307862c2c5 100644 --- a/drivers/media/i2c/ml86v7667.c +++ b/drivers/media/i2c/ml86v7667.c | |||
@@ -192,12 +192,12 @@ static int ml86v7667_g_input_status(struct v4l2_subdev *sd, u32 *status) | |||
192 | } | 192 | } |
193 | 193 | ||
194 | static int ml86v7667_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, | 194 | static int ml86v7667_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, |
195 | enum v4l2_mbus_pixelcode *code) | 195 | u32 *code) |
196 | { | 196 | { |
197 | if (index > 0) | 197 | if (index > 0) |
198 | return -EINVAL; | 198 | return -EINVAL; |
199 | 199 | ||
200 | *code = V4L2_MBUS_FMT_YUYV8_2X8; | 200 | *code = MEDIA_BUS_FMT_YUYV8_2X8; |
201 | 201 | ||
202 | return 0; | 202 | return 0; |
203 | } | 203 | } |
@@ -207,7 +207,7 @@ static int ml86v7667_mbus_fmt(struct v4l2_subdev *sd, | |||
207 | { | 207 | { |
208 | struct ml86v7667_priv *priv = to_ml86v7667(sd); | 208 | struct ml86v7667_priv *priv = to_ml86v7667(sd); |
209 | 209 | ||
210 | fmt->code = V4L2_MBUS_FMT_YUYV8_2X8; | 210 | fmt->code = MEDIA_BUS_FMT_YUYV8_2X8; |
211 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; | 211 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; |
212 | /* The top field is always transferred first by the chip */ | 212 | /* The top field is always transferred first by the chip */ |
213 | fmt->field = V4L2_FIELD_INTERLACED_TB; | 213 | fmt->field = V4L2_FIELD_INTERLACED_TB; |
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c index 85ec3bacdf1c..45b3fca188ca 100644 --- a/drivers/media/i2c/mt9m032.c +++ b/drivers/media/i2c/mt9m032.c | |||
@@ -323,7 +323,7 @@ static int mt9m032_enum_mbus_code(struct v4l2_subdev *subdev, | |||
323 | if (code->index != 0) | 323 | if (code->index != 0) |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | 325 | ||
326 | code->code = V4L2_MBUS_FMT_Y8_1X8; | 326 | code->code = MEDIA_BUS_FMT_Y8_1X8; |
327 | return 0; | 327 | return 0; |
328 | } | 328 | } |
329 | 329 | ||
@@ -331,7 +331,7 @@ static int mt9m032_enum_frame_size(struct v4l2_subdev *subdev, | |||
331 | struct v4l2_subdev_fh *fh, | 331 | struct v4l2_subdev_fh *fh, |
332 | struct v4l2_subdev_frame_size_enum *fse) | 332 | struct v4l2_subdev_frame_size_enum *fse) |
333 | { | 333 | { |
334 | if (fse->index != 0 || fse->code != V4L2_MBUS_FMT_Y8_1X8) | 334 | if (fse->index != 0 || fse->code != MEDIA_BUS_FMT_Y8_1X8) |
335 | return -EINVAL; | 335 | return -EINVAL; |
336 | 336 | ||
337 | fse->min_width = MT9M032_COLUMN_SIZE_DEF; | 337 | fse->min_width = MT9M032_COLUMN_SIZE_DEF; |
@@ -759,7 +759,7 @@ static int mt9m032_probe(struct i2c_client *client, | |||
759 | 759 | ||
760 | sensor->format.width = sensor->crop.width; | 760 | sensor->format.width = sensor->crop.width; |
761 | sensor->format.height = sensor->crop.height; | 761 | sensor->format.height = sensor->crop.height; |
762 | sensor->format.code = V4L2_MBUS_FMT_Y8_1X8; | 762 | sensor->format.code = MEDIA_BUS_FMT_Y8_1X8; |
763 | sensor->format.field = V4L2_FIELD_NONE; | 763 | sensor->format.field = V4L2_FIELD_NONE; |
764 | sensor->format.colorspace = V4L2_COLORSPACE_SRGB; | 764 | sensor->format.colorspace = V4L2_COLORSPACE_SRGB; |
765 | 765 | ||
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index e18797ff7faf..edb76bd33d16 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c | |||
@@ -950,9 +950,9 @@ static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) | |||
950 | format = v4l2_subdev_get_try_format(fh, 0); | 950 | format = v4l2_subdev_get_try_format(fh, 0); |
951 | 951 | ||
952 | if (mt9p031->model == MT9P031_MODEL_MONOCHROME) | 952 | if (mt9p031->model == MT9P031_MODEL_MONOCHROME) |
953 | format->code = V4L2_MBUS_FMT_Y12_1X12; | 953 | format->code = MEDIA_BUS_FMT_Y12_1X12; |
954 | else | 954 | else |
955 | format->code = V4L2_MBUS_FMT_SGRBG12_1X12; | 955 | format->code = MEDIA_BUS_FMT_SGRBG12_1X12; |
956 | 956 | ||
957 | format->width = MT9P031_WINDOW_WIDTH_DEF; | 957 | format->width = MT9P031_WINDOW_WIDTH_DEF; |
958 | format->height = MT9P031_WINDOW_HEIGHT_DEF; | 958 | format->height = MT9P031_WINDOW_HEIGHT_DEF; |
@@ -1120,9 +1120,9 @@ static int mt9p031_probe(struct i2c_client *client, | |||
1120 | mt9p031->crop.top = MT9P031_ROW_START_DEF; | 1120 | mt9p031->crop.top = MT9P031_ROW_START_DEF; |
1121 | 1121 | ||
1122 | if (mt9p031->model == MT9P031_MODEL_MONOCHROME) | 1122 | if (mt9p031->model == MT9P031_MODEL_MONOCHROME) |
1123 | mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12; | 1123 | mt9p031->format.code = MEDIA_BUS_FMT_Y12_1X12; |
1124 | else | 1124 | else |
1125 | mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12; | 1125 | mt9p031->format.code = MEDIA_BUS_FMT_SGRBG12_1X12; |
1126 | 1126 | ||
1127 | mt9p031->format.width = MT9P031_WINDOW_WIDTH_DEF; | 1127 | mt9p031->format.width = MT9P031_WINDOW_WIDTH_DEF; |
1128 | mt9p031->format.height = MT9P031_WINDOW_HEIGHT_DEF; | 1128 | mt9p031->format.height = MT9P031_WINDOW_HEIGHT_DEF; |
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c index 422e068f5f1b..d9e9889b579f 100644 --- a/drivers/media/i2c/mt9t001.c +++ b/drivers/media/i2c/mt9t001.c | |||
@@ -333,7 +333,7 @@ static int mt9t001_enum_mbus_code(struct v4l2_subdev *subdev, | |||
333 | if (code->index > 0) | 333 | if (code->index > 0) |
334 | return -EINVAL; | 334 | return -EINVAL; |
335 | 335 | ||
336 | code->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 336 | code->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
337 | return 0; | 337 | return 0; |
338 | } | 338 | } |
339 | 339 | ||
@@ -341,7 +341,7 @@ static int mt9t001_enum_frame_size(struct v4l2_subdev *subdev, | |||
341 | struct v4l2_subdev_fh *fh, | 341 | struct v4l2_subdev_fh *fh, |
342 | struct v4l2_subdev_frame_size_enum *fse) | 342 | struct v4l2_subdev_frame_size_enum *fse) |
343 | { | 343 | { |
344 | if (fse->index >= 8 || fse->code != V4L2_MBUS_FMT_SGRBG10_1X10) | 344 | if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) |
345 | return -EINVAL; | 345 | return -EINVAL; |
346 | 346 | ||
347 | fse->min_width = (MT9T001_WINDOW_WIDTH_DEF + 1) / fse->index; | 347 | fse->min_width = (MT9T001_WINDOW_WIDTH_DEF + 1) / fse->index; |
@@ -792,7 +792,7 @@ static int mt9t001_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) | |||
792 | crop->height = MT9T001_WINDOW_HEIGHT_DEF + 1; | 792 | crop->height = MT9T001_WINDOW_HEIGHT_DEF + 1; |
793 | 793 | ||
794 | format = v4l2_subdev_get_try_format(fh, 0); | 794 | format = v4l2_subdev_get_try_format(fh, 0); |
795 | format->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 795 | format->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
796 | format->width = MT9T001_WINDOW_WIDTH_DEF + 1; | 796 | format->width = MT9T001_WINDOW_WIDTH_DEF + 1; |
797 | format->height = MT9T001_WINDOW_HEIGHT_DEF + 1; | 797 | format->height = MT9T001_WINDOW_HEIGHT_DEF + 1; |
798 | format->field = V4L2_FIELD_NONE; | 798 | format->field = V4L2_FIELD_NONE; |
@@ -917,7 +917,7 @@ static int mt9t001_probe(struct i2c_client *client, | |||
917 | mt9t001->crop.width = MT9T001_WINDOW_WIDTH_DEF + 1; | 917 | mt9t001->crop.width = MT9T001_WINDOW_WIDTH_DEF + 1; |
918 | mt9t001->crop.height = MT9T001_WINDOW_HEIGHT_DEF + 1; | 918 | mt9t001->crop.height = MT9T001_WINDOW_HEIGHT_DEF + 1; |
919 | 919 | ||
920 | mt9t001->format.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 920 | mt9t001->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
921 | mt9t001->format.width = MT9T001_WINDOW_WIDTH_DEF + 1; | 921 | mt9t001->format.width = MT9T001_WINDOW_WIDTH_DEF + 1; |
922 | mt9t001->format.height = MT9T001_WINDOW_HEIGHT_DEF + 1; | 922 | mt9t001->format.height = MT9T001_WINDOW_HEIGHT_DEF + 1; |
923 | mt9t001->format.field = V4L2_FIELD_NONE; | 923 | mt9t001->format.field = V4L2_FIELD_NONE; |
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c index 47e475319a24..a10f7f8f0558 100644 --- a/drivers/media/i2c/mt9v011.c +++ b/drivers/media/i2c/mt9v011.c | |||
@@ -325,18 +325,18 @@ static int mt9v011_reset(struct v4l2_subdev *sd, u32 val) | |||
325 | } | 325 | } |
326 | 326 | ||
327 | static int mt9v011_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 327 | static int mt9v011_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
328 | enum v4l2_mbus_pixelcode *code) | 328 | u32 *code) |
329 | { | 329 | { |
330 | if (index > 0) | 330 | if (index > 0) |
331 | return -EINVAL; | 331 | return -EINVAL; |
332 | 332 | ||
333 | *code = V4L2_MBUS_FMT_SGRBG8_1X8; | 333 | *code = MEDIA_BUS_FMT_SGRBG8_1X8; |
334 | return 0; | 334 | return 0; |
335 | } | 335 | } |
336 | 336 | ||
337 | static int mt9v011_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt) | 337 | static int mt9v011_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt) |
338 | { | 338 | { |
339 | if (fmt->code != V4L2_MBUS_FMT_SGRBG8_1X8) | 339 | if (fmt->code != MEDIA_BUS_FMT_SGRBG8_1X8) |
340 | return -EINVAL; | 340 | return -EINVAL; |
341 | 341 | ||
342 | v4l_bound_align_image(&fmt->width, 48, 639, 1, | 342 | v4l_bound_align_image(&fmt->width, 48, 639, 1, |
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index d044bce312e0..93687c1e4097 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c | |||
@@ -454,7 +454,7 @@ static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev, | |||
454 | if (code->index > 0) | 454 | if (code->index > 0) |
455 | return -EINVAL; | 455 | return -EINVAL; |
456 | 456 | ||
457 | code->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 457 | code->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
460 | 460 | ||
@@ -462,7 +462,7 @@ static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev, | |||
462 | struct v4l2_subdev_fh *fh, | 462 | struct v4l2_subdev_fh *fh, |
463 | struct v4l2_subdev_frame_size_enum *fse) | 463 | struct v4l2_subdev_frame_size_enum *fse) |
464 | { | 464 | { |
465 | if (fse->index >= 3 || fse->code != V4L2_MBUS_FMT_SGRBG10_1X10) | 465 | if (fse->index >= 3 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) |
466 | return -EINVAL; | 466 | return -EINVAL; |
467 | 467 | ||
468 | fse->min_width = MT9V032_WINDOW_WIDTH_DEF / (1 << fse->index); | 468 | fse->min_width = MT9V032_WINDOW_WIDTH_DEF / (1 << fse->index); |
@@ -814,9 +814,9 @@ static int mt9v032_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) | |||
814 | format = v4l2_subdev_get_try_format(fh, 0); | 814 | format = v4l2_subdev_get_try_format(fh, 0); |
815 | 815 | ||
816 | if (mt9v032->model->color) | 816 | if (mt9v032->model->color) |
817 | format->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 817 | format->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
818 | else | 818 | else |
819 | format->code = V4L2_MBUS_FMT_Y10_1X10; | 819 | format->code = MEDIA_BUS_FMT_Y10_1X10; |
820 | 820 | ||
821 | format->width = MT9V032_WINDOW_WIDTH_DEF; | 821 | format->width = MT9V032_WINDOW_WIDTH_DEF; |
822 | format->height = MT9V032_WINDOW_HEIGHT_DEF; | 822 | format->height = MT9V032_WINDOW_HEIGHT_DEF; |
@@ -966,9 +966,9 @@ static int mt9v032_probe(struct i2c_client *client, | |||
966 | mt9v032->crop.height = MT9V032_WINDOW_HEIGHT_DEF; | 966 | mt9v032->crop.height = MT9V032_WINDOW_HEIGHT_DEF; |
967 | 967 | ||
968 | if (mt9v032->model->color) | 968 | if (mt9v032->model->color) |
969 | mt9v032->format.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 969 | mt9v032->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
970 | else | 970 | else |
971 | mt9v032->format.code = V4L2_MBUS_FMT_Y10_1X10; | 971 | mt9v032->format.code = MEDIA_BUS_FMT_Y10_1X10; |
972 | 972 | ||
973 | mt9v032->format.width = MT9V032_WINDOW_WIDTH_DEF; | 973 | mt9v032->format.width = MT9V032_WINDOW_WIDTH_DEF; |
974 | mt9v032->format.height = MT9V032_WINDOW_HEIGHT_DEF; | 974 | mt9v032->format.height = MT9V032_WINDOW_HEIGHT_DEF; |
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 7eae48766e2b..00c7b26f4823 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c | |||
@@ -112,7 +112,7 @@ MODULE_PARM_DESC(debug, "Enable module debug trace. Set to 1 to enable."); | |||
112 | #define REG_TERM 0xFFFF | 112 | #define REG_TERM 0xFFFF |
113 | 113 | ||
114 | struct noon010_format { | 114 | struct noon010_format { |
115 | enum v4l2_mbus_pixelcode code; | 115 | u32 code; |
116 | enum v4l2_colorspace colorspace; | 116 | enum v4l2_colorspace colorspace; |
117 | u16 ispctl1_reg; | 117 | u16 ispctl1_reg; |
118 | }; | 118 | }; |
@@ -175,23 +175,23 @@ static const struct noon010_frmsize noon010_sizes[] = { | |||
175 | /* Supported pixel formats. */ | 175 | /* Supported pixel formats. */ |
176 | static const struct noon010_format noon010_formats[] = { | 176 | static const struct noon010_format noon010_formats[] = { |
177 | { | 177 | { |
178 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 178 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
179 | .colorspace = V4L2_COLORSPACE_JPEG, | 179 | .colorspace = V4L2_COLORSPACE_JPEG, |
180 | .ispctl1_reg = 0x03, | 180 | .ispctl1_reg = 0x03, |
181 | }, { | 181 | }, { |
182 | .code = V4L2_MBUS_FMT_YVYU8_2X8, | 182 | .code = MEDIA_BUS_FMT_YVYU8_2X8, |
183 | .colorspace = V4L2_COLORSPACE_JPEG, | 183 | .colorspace = V4L2_COLORSPACE_JPEG, |
184 | .ispctl1_reg = 0x02, | 184 | .ispctl1_reg = 0x02, |
185 | }, { | 185 | }, { |
186 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 186 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
187 | .colorspace = V4L2_COLORSPACE_JPEG, | 187 | .colorspace = V4L2_COLORSPACE_JPEG, |
188 | .ispctl1_reg = 0, | 188 | .ispctl1_reg = 0, |
189 | }, { | 189 | }, { |
190 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 190 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
191 | .colorspace = V4L2_COLORSPACE_JPEG, | 191 | .colorspace = V4L2_COLORSPACE_JPEG, |
192 | .ispctl1_reg = 0x01, | 192 | .ispctl1_reg = 0x01, |
193 | }, { | 193 | }, { |
194 | .code = V4L2_MBUS_FMT_RGB565_2X8_BE, | 194 | .code = MEDIA_BUS_FMT_RGB565_2X8_BE, |
195 | .colorspace = V4L2_COLORSPACE_JPEG, | 195 | .colorspace = V4L2_COLORSPACE_JPEG, |
196 | .ispctl1_reg = 0x40, | 196 | .ispctl1_reg = 0x40, |
197 | }, | 197 | }, |
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index dd3db2458a4f..957927f7a353 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c | |||
@@ -632,31 +632,31 @@ static int ov7670_detect(struct v4l2_subdev *sd) | |||
632 | * The magic matrix numbers come from OmniVision. | 632 | * The magic matrix numbers come from OmniVision. |
633 | */ | 633 | */ |
634 | static struct ov7670_format_struct { | 634 | static struct ov7670_format_struct { |
635 | enum v4l2_mbus_pixelcode mbus_code; | 635 | u32 mbus_code; |
636 | enum v4l2_colorspace colorspace; | 636 | enum v4l2_colorspace colorspace; |
637 | struct regval_list *regs; | 637 | struct regval_list *regs; |
638 | int cmatrix[CMATRIX_LEN]; | 638 | int cmatrix[CMATRIX_LEN]; |
639 | } ov7670_formats[] = { | 639 | } ov7670_formats[] = { |
640 | { | 640 | { |
641 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 641 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
642 | .colorspace = V4L2_COLORSPACE_JPEG, | 642 | .colorspace = V4L2_COLORSPACE_JPEG, |
643 | .regs = ov7670_fmt_yuv422, | 643 | .regs = ov7670_fmt_yuv422, |
644 | .cmatrix = { 128, -128, 0, -34, -94, 128 }, | 644 | .cmatrix = { 128, -128, 0, -34, -94, 128 }, |
645 | }, | 645 | }, |
646 | { | 646 | { |
647 | .mbus_code = V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, | 647 | .mbus_code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, |
648 | .colorspace = V4L2_COLORSPACE_SRGB, | 648 | .colorspace = V4L2_COLORSPACE_SRGB, |
649 | .regs = ov7670_fmt_rgb444, | 649 | .regs = ov7670_fmt_rgb444, |
650 | .cmatrix = { 179, -179, 0, -61, -176, 228 }, | 650 | .cmatrix = { 179, -179, 0, -61, -176, 228 }, |
651 | }, | 651 | }, |
652 | { | 652 | { |
653 | .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 653 | .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
654 | .colorspace = V4L2_COLORSPACE_SRGB, | 654 | .colorspace = V4L2_COLORSPACE_SRGB, |
655 | .regs = ov7670_fmt_rgb565, | 655 | .regs = ov7670_fmt_rgb565, |
656 | .cmatrix = { 179, -179, 0, -61, -176, 228 }, | 656 | .cmatrix = { 179, -179, 0, -61, -176, 228 }, |
657 | }, | 657 | }, |
658 | { | 658 | { |
659 | .mbus_code = V4L2_MBUS_FMT_SBGGR8_1X8, | 659 | .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, |
660 | .colorspace = V4L2_COLORSPACE_SRGB, | 660 | .colorspace = V4L2_COLORSPACE_SRGB, |
661 | .regs = ov7670_fmt_raw, | 661 | .regs = ov7670_fmt_raw, |
662 | .cmatrix = { 0, 0, 0, 0, 0, 0 }, | 662 | .cmatrix = { 0, 0, 0, 0, 0, 0 }, |
@@ -772,7 +772,7 @@ static void ov7675_get_framerate(struct v4l2_subdev *sd, | |||
772 | pll_factor = PLL_FACTOR; | 772 | pll_factor = PLL_FACTOR; |
773 | 773 | ||
774 | clkrc++; | 774 | clkrc++; |
775 | if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) | 775 | if (info->fmt->mbus_code == MEDIA_BUS_FMT_SBGGR8_1X8) |
776 | clkrc = (clkrc >> 1); | 776 | clkrc = (clkrc >> 1); |
777 | 777 | ||
778 | tpf->numerator = 1; | 778 | tpf->numerator = 1; |
@@ -810,7 +810,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, | |||
810 | } else { | 810 | } else { |
811 | clkrc = (5 * pll_factor * info->clock_speed * tpf->numerator) / | 811 | clkrc = (5 * pll_factor * info->clock_speed * tpf->numerator) / |
812 | (4 * tpf->denominator); | 812 | (4 * tpf->denominator); |
813 | if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) | 813 | if (info->fmt->mbus_code == MEDIA_BUS_FMT_SBGGR8_1X8) |
814 | clkrc = (clkrc << 1); | 814 | clkrc = (clkrc << 1); |
815 | clkrc--; | 815 | clkrc--; |
816 | } | 816 | } |
@@ -900,7 +900,7 @@ static int ov7670_set_hw(struct v4l2_subdev *sd, int hstart, int hstop, | |||
900 | 900 | ||
901 | 901 | ||
902 | static int ov7670_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 902 | static int ov7670_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
903 | enum v4l2_mbus_pixelcode *code) | 903 | u32 *code) |
904 | { | 904 | { |
905 | if (index >= N_OV7670_FMTS) | 905 | if (index >= N_OV7670_FMTS) |
906 | return -EINVAL; | 906 | return -EINVAL; |
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index 4da90c621f7e..2246bd5436ad 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c | |||
@@ -384,17 +384,17 @@ static const struct ov965x_framesize ov965x_framesizes[] = { | |||
384 | }; | 384 | }; |
385 | 385 | ||
386 | struct ov965x_pixfmt { | 386 | struct ov965x_pixfmt { |
387 | enum v4l2_mbus_pixelcode code; | 387 | u32 code; |
388 | u32 colorspace; | 388 | u32 colorspace; |
389 | /* REG_TSLB value, only bits [3:2] may be set. */ | 389 | /* REG_TSLB value, only bits [3:2] may be set. */ |
390 | u8 tslb_reg; | 390 | u8 tslb_reg; |
391 | }; | 391 | }; |
392 | 392 | ||
393 | static const struct ov965x_pixfmt ov965x_formats[] = { | 393 | static const struct ov965x_pixfmt ov965x_formats[] = { |
394 | { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 0x00}, | 394 | { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 0x00}, |
395 | { V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG, 0x04}, | 395 | { MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG, 0x04}, |
396 | { V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG, 0x0c}, | 396 | { MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG, 0x0c}, |
397 | { V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 0x08}, | 397 | { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 0x08}, |
398 | }; | 398 | }; |
399 | 399 | ||
400 | /* | 400 | /* |
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h index 9656b6723dc6..13aed59f0f5d 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3.h +++ b/drivers/media/i2c/s5c73m3/s5c73m3.h | |||
@@ -27,8 +27,8 @@ | |||
27 | 27 | ||
28 | #define DRIVER_NAME "S5C73M3" | 28 | #define DRIVER_NAME "S5C73M3" |
29 | 29 | ||
30 | #define S5C73M3_ISP_FMT V4L2_MBUS_FMT_VYUY8_2X8 | 30 | #define S5C73M3_ISP_FMT MEDIA_BUS_FMT_VYUY8_2X8 |
31 | #define S5C73M3_JPEG_FMT V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8 | 31 | #define S5C73M3_JPEG_FMT MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8 |
32 | 32 | ||
33 | /* Subdevs pad index definitions */ | 33 | /* Subdevs pad index definitions */ |
34 | enum s5c73m3_pads { | 34 | enum s5c73m3_pads { |
@@ -402,7 +402,7 @@ struct s5c73m3 { | |||
402 | 402 | ||
403 | const struct s5c73m3_frame_size *sensor_pix_size[2]; | 403 | const struct s5c73m3_frame_size *sensor_pix_size[2]; |
404 | const struct s5c73m3_frame_size *oif_pix_size[2]; | 404 | const struct s5c73m3_frame_size *oif_pix_size[2]; |
405 | enum v4l2_mbus_pixelcode mbus_code; | 405 | u32 mbus_code; |
406 | 406 | ||
407 | const struct s5c73m3_interval *fiv; | 407 | const struct s5c73m3_interval *fiv; |
408 | 408 | ||
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index 1fcc76fd1bbf..d1c50c9d43ae 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c | |||
@@ -151,7 +151,7 @@ static const struct s5k4ecgx_frmsize s5k4ecgx_prev_sizes[] = { | |||
151 | #define S5K4ECGX_NUM_PREV ARRAY_SIZE(s5k4ecgx_prev_sizes) | 151 | #define S5K4ECGX_NUM_PREV ARRAY_SIZE(s5k4ecgx_prev_sizes) |
152 | 152 | ||
153 | struct s5k4ecgx_pixfmt { | 153 | struct s5k4ecgx_pixfmt { |
154 | enum v4l2_mbus_pixelcode code; | 154 | u32 code; |
155 | u32 colorspace; | 155 | u32 colorspace; |
156 | /* REG_TC_PCFG_Format register value */ | 156 | /* REG_TC_PCFG_Format register value */ |
157 | u16 reg_p_format; | 157 | u16 reg_p_format; |
@@ -159,7 +159,7 @@ struct s5k4ecgx_pixfmt { | |||
159 | 159 | ||
160 | /* By default value, output from sensor will be YUV422 0-255 */ | 160 | /* By default value, output from sensor will be YUV422 0-255 */ |
161 | static const struct s5k4ecgx_pixfmt s5k4ecgx_formats[] = { | 161 | static const struct s5k4ecgx_pixfmt s5k4ecgx_formats[] = { |
162 | { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 }, | 162 | { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 }, |
163 | }; | 163 | }; |
164 | 164 | ||
165 | static const char * const s5k4ecgx_supply_names[] = { | 165 | static const char * const s5k4ecgx_supply_names[] = { |
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 0e461a6fd065..60a74d8d38d5 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c | |||
@@ -248,7 +248,7 @@ enum s5k5baf_gpio_id { | |||
248 | #define NUM_ISP_PADS 2 | 248 | #define NUM_ISP_PADS 2 |
249 | 249 | ||
250 | struct s5k5baf_pixfmt { | 250 | struct s5k5baf_pixfmt { |
251 | enum v4l2_mbus_pixelcode code; | 251 | u32 code; |
252 | u32 colorspace; | 252 | u32 colorspace; |
253 | /* REG_P_FMT(x) register value */ | 253 | /* REG_P_FMT(x) register value */ |
254 | u16 reg_p_fmt; | 254 | u16 reg_p_fmt; |
@@ -331,10 +331,10 @@ struct s5k5baf { | |||
331 | }; | 331 | }; |
332 | 332 | ||
333 | static const struct s5k5baf_pixfmt s5k5baf_formats[] = { | 333 | static const struct s5k5baf_pixfmt s5k5baf_formats[] = { |
334 | { V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 5 }, | 334 | { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG, 5 }, |
335 | /* range 16-240 */ | 335 | /* range 16-240 */ |
336 | { V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_REC709, 6 }, | 336 | { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_REC709, 6 }, |
337 | { V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 }, | 337 | { MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 }, |
338 | }; | 338 | }; |
339 | 339 | ||
340 | static struct v4l2_rect s5k5baf_cis_rect = { | 340 | static struct v4l2_rect s5k5baf_cis_rect = { |
@@ -1206,7 +1206,7 @@ static int s5k5baf_enum_mbus_code(struct v4l2_subdev *sd, | |||
1206 | if (code->pad == PAD_CIS) { | 1206 | if (code->pad == PAD_CIS) { |
1207 | if (code->index > 0) | 1207 | if (code->index > 0) |
1208 | return -EINVAL; | 1208 | return -EINVAL; |
1209 | code->code = V4L2_MBUS_FMT_FIXED; | 1209 | code->code = MEDIA_BUS_FMT_FIXED; |
1210 | return 0; | 1210 | return 0; |
1211 | } | 1211 | } |
1212 | 1212 | ||
@@ -1227,7 +1227,7 @@ static int s5k5baf_enum_frame_size(struct v4l2_subdev *sd, | |||
1227 | return -EINVAL; | 1227 | return -EINVAL; |
1228 | 1228 | ||
1229 | if (fse->pad == PAD_CIS) { | 1229 | if (fse->pad == PAD_CIS) { |
1230 | fse->code = V4L2_MBUS_FMT_FIXED; | 1230 | fse->code = MEDIA_BUS_FMT_FIXED; |
1231 | fse->min_width = S5K5BAF_CIS_WIDTH; | 1231 | fse->min_width = S5K5BAF_CIS_WIDTH; |
1232 | fse->max_width = S5K5BAF_CIS_WIDTH; | 1232 | fse->max_width = S5K5BAF_CIS_WIDTH; |
1233 | fse->min_height = S5K5BAF_CIS_HEIGHT; | 1233 | fse->min_height = S5K5BAF_CIS_HEIGHT; |
@@ -1252,7 +1252,7 @@ static void s5k5baf_try_cis_format(struct v4l2_mbus_framefmt *mf) | |||
1252 | { | 1252 | { |
1253 | mf->width = S5K5BAF_CIS_WIDTH; | 1253 | mf->width = S5K5BAF_CIS_WIDTH; |
1254 | mf->height = S5K5BAF_CIS_HEIGHT; | 1254 | mf->height = S5K5BAF_CIS_HEIGHT; |
1255 | mf->code = V4L2_MBUS_FMT_FIXED; | 1255 | mf->code = MEDIA_BUS_FMT_FIXED; |
1256 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 1256 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
1257 | mf->field = V4L2_FIELD_NONE; | 1257 | mf->field = V4L2_FIELD_NONE; |
1258 | } | 1258 | } |
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index c11a40850ed1..91b841a1b850 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c | |||
@@ -80,7 +80,7 @@ static inline struct s5k6a3 *sd_to_s5k6a3(struct v4l2_subdev *sd) | |||
80 | 80 | ||
81 | static const struct v4l2_mbus_framefmt s5k6a3_formats[] = { | 81 | static const struct v4l2_mbus_framefmt s5k6a3_formats[] = { |
82 | { | 82 | { |
83 | .code = V4L2_MBUS_FMT_SGRBG10_1X10, | 83 | .code = MEDIA_BUS_FMT_SGRBG10_1X10, |
84 | .colorspace = V4L2_COLORSPACE_SRGB, | 84 | .colorspace = V4L2_COLORSPACE_SRGB, |
85 | .field = V4L2_FIELD_NONE, | 85 | .field = V4L2_FIELD_NONE, |
86 | } | 86 | } |
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index 629a5cdadd3a..2851581e0061 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c | |||
@@ -191,7 +191,7 @@ struct s5k6aa_regval { | |||
191 | }; | 191 | }; |
192 | 192 | ||
193 | struct s5k6aa_pixfmt { | 193 | struct s5k6aa_pixfmt { |
194 | enum v4l2_mbus_pixelcode code; | 194 | u32 code; |
195 | u32 colorspace; | 195 | u32 colorspace; |
196 | /* REG_P_FMT(x) register value */ | 196 | /* REG_P_FMT(x) register value */ |
197 | u16 reg_p_fmt; | 197 | u16 reg_p_fmt; |
@@ -285,10 +285,10 @@ static struct s5k6aa_regval s5k6aa_analog_config[] = { | |||
285 | 285 | ||
286 | /* TODO: Add RGB888 and Bayer format */ | 286 | /* TODO: Add RGB888 and Bayer format */ |
287 | static const struct s5k6aa_pixfmt s5k6aa_formats[] = { | 287 | static const struct s5k6aa_pixfmt s5k6aa_formats[] = { |
288 | { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 }, | 288 | { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG, 5 }, |
289 | /* range 16-240 */ | 289 | /* range 16-240 */ |
290 | { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_REC709, 6 }, | 290 | { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_REC709, 6 }, |
291 | { V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 }, | 291 | { MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_JPEG, 0 }, |
292 | }; | 292 | }; |
293 | 293 | ||
294 | static const struct s5k6aa_interval s5k6aa_intervals[] = { | 294 | static const struct s5k6aa_interval s5k6aa_intervals[] = { |
diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c index 4024ea6f1371..f14c0e6435a3 100644 --- a/drivers/media/i2c/saa6752hs.c +++ b/drivers/media/i2c/saa6752hs.c | |||
@@ -562,7 +562,7 @@ static int saa6752hs_g_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm | |||
562 | h->video_format = SAA6752HS_VF_D1; | 562 | h->video_format = SAA6752HS_VF_D1; |
563 | f->width = v4l2_format_table[h->video_format].fmt.pix.width; | 563 | f->width = v4l2_format_table[h->video_format].fmt.pix.width; |
564 | f->height = v4l2_format_table[h->video_format].fmt.pix.height; | 564 | f->height = v4l2_format_table[h->video_format].fmt.pix.height; |
565 | f->code = V4L2_MBUS_FMT_FIXED; | 565 | f->code = MEDIA_BUS_FMT_FIXED; |
566 | f->field = V4L2_FIELD_INTERLACED; | 566 | f->field = V4L2_FIELD_INTERLACED; |
567 | f->colorspace = V4L2_COLORSPACE_SMPTE170M; | 567 | f->colorspace = V4L2_COLORSPACE_SMPTE170M; |
568 | return 0; | 568 | return 0; |
@@ -572,7 +572,7 @@ static int saa6752hs_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_frame | |||
572 | { | 572 | { |
573 | int dist_352, dist_480, dist_720; | 573 | int dist_352, dist_480, dist_720; |
574 | 574 | ||
575 | f->code = V4L2_MBUS_FMT_FIXED; | 575 | f->code = MEDIA_BUS_FMT_FIXED; |
576 | 576 | ||
577 | dist_352 = abs(f->width - 352); | 577 | dist_352 = abs(f->width - 352); |
578 | dist_480 = abs(f->width - 480); | 578 | dist_480 = abs(f->width - 480); |
@@ -599,7 +599,7 @@ static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm | |||
599 | { | 599 | { |
600 | struct saa6752hs_state *h = to_state(sd); | 600 | struct saa6752hs_state *h = to_state(sd); |
601 | 601 | ||
602 | if (f->code != V4L2_MBUS_FMT_FIXED) | 602 | if (f->code != MEDIA_BUS_FMT_FIXED) |
603 | return -EINVAL; | 603 | return -EINVAL; |
604 | 604 | ||
605 | /* | 605 | /* |
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 35a44648150e..7147c8b68fac 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c | |||
@@ -1172,7 +1172,7 @@ static int saa711x_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f | |||
1172 | 1172 | ||
1173 | static int saa711x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt) | 1173 | static int saa711x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt) |
1174 | { | 1174 | { |
1175 | if (fmt->code != V4L2_MBUS_FMT_FIXED) | 1175 | if (fmt->code != MEDIA_BUS_FMT_FIXED) |
1176 | return -EINVAL; | 1176 | return -EINVAL; |
1177 | fmt->field = V4L2_FIELD_INTERLACED; | 1177 | fmt->field = V4L2_FIELD_INTERLACED; |
1178 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; | 1178 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; |
diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c index 6922a9f9a5cd..0d0f9a917cd3 100644 --- a/drivers/media/i2c/saa717x.c +++ b/drivers/media/i2c/saa717x.c | |||
@@ -998,7 +998,7 @@ static int saa717x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt | |||
998 | 998 | ||
999 | v4l2_dbg(1, debug, sd, "decoder set size\n"); | 999 | v4l2_dbg(1, debug, sd, "decoder set size\n"); |
1000 | 1000 | ||
1001 | if (fmt->code != V4L2_MBUS_FMT_FIXED) | 1001 | if (fmt->code != MEDIA_BUS_FMT_FIXED) |
1002 | return -EINVAL; | 1002 | return -EINVAL; |
1003 | 1003 | ||
1004 | /* FIXME need better bounds checking here */ | 1004 | /* FIXME need better bounds checking here */ |
diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c index 2335529b195c..e40d9027df3d 100644 --- a/drivers/media/i2c/smiapp-pll.c +++ b/drivers/media/i2c/smiapp-pll.c | |||
@@ -65,26 +65,89 @@ static int bounds_check(struct device *dev, uint32_t val, | |||
65 | 65 | ||
66 | static void print_pll(struct device *dev, struct smiapp_pll *pll) | 66 | static void print_pll(struct device *dev, struct smiapp_pll *pll) |
67 | { | 67 | { |
68 | dev_dbg(dev, "pre_pll_clk_div\t%d\n", pll->pre_pll_clk_div); | 68 | dev_dbg(dev, "pre_pll_clk_div\t%u\n", pll->pre_pll_clk_div); |
69 | dev_dbg(dev, "pll_multiplier \t%d\n", pll->pll_multiplier); | 69 | dev_dbg(dev, "pll_multiplier \t%u\n", pll->pll_multiplier); |
70 | if (pll->flags != SMIAPP_PLL_FLAG_NO_OP_CLOCKS) { | 70 | if (!(pll->flags & SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) { |
71 | dev_dbg(dev, "op_sys_clk_div \t%d\n", pll->op_sys_clk_div); | 71 | dev_dbg(dev, "op_sys_clk_div \t%u\n", pll->op.sys_clk_div); |
72 | dev_dbg(dev, "op_pix_clk_div \t%d\n", pll->op_pix_clk_div); | 72 | dev_dbg(dev, "op_pix_clk_div \t%u\n", pll->op.pix_clk_div); |
73 | } | 73 | } |
74 | dev_dbg(dev, "vt_sys_clk_div \t%d\n", pll->vt_sys_clk_div); | 74 | dev_dbg(dev, "vt_sys_clk_div \t%u\n", pll->vt.sys_clk_div); |
75 | dev_dbg(dev, "vt_pix_clk_div \t%d\n", pll->vt_pix_clk_div); | 75 | dev_dbg(dev, "vt_pix_clk_div \t%u\n", pll->vt.pix_clk_div); |
76 | 76 | ||
77 | dev_dbg(dev, "ext_clk_freq_hz \t%d\n", pll->ext_clk_freq_hz); | 77 | dev_dbg(dev, "ext_clk_freq_hz \t%u\n", pll->ext_clk_freq_hz); |
78 | dev_dbg(dev, "pll_ip_clk_freq_hz \t%d\n", pll->pll_ip_clk_freq_hz); | 78 | dev_dbg(dev, "pll_ip_clk_freq_hz \t%u\n", pll->pll_ip_clk_freq_hz); |
79 | dev_dbg(dev, "pll_op_clk_freq_hz \t%d\n", pll->pll_op_clk_freq_hz); | 79 | dev_dbg(dev, "pll_op_clk_freq_hz \t%u\n", pll->pll_op_clk_freq_hz); |
80 | if (pll->flags & SMIAPP_PLL_FLAG_NO_OP_CLOCKS) { | 80 | if (!(pll->flags & SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) { |
81 | dev_dbg(dev, "op_sys_clk_freq_hz \t%d\n", | 81 | dev_dbg(dev, "op_sys_clk_freq_hz \t%u\n", |
82 | pll->op_sys_clk_freq_hz); | 82 | pll->op.sys_clk_freq_hz); |
83 | dev_dbg(dev, "op_pix_clk_freq_hz \t%d\n", | 83 | dev_dbg(dev, "op_pix_clk_freq_hz \t%u\n", |
84 | pll->op_pix_clk_freq_hz); | 84 | pll->op.pix_clk_freq_hz); |
85 | } | 85 | } |
86 | dev_dbg(dev, "vt_sys_clk_freq_hz \t%d\n", pll->vt_sys_clk_freq_hz); | 86 | dev_dbg(dev, "vt_sys_clk_freq_hz \t%u\n", pll->vt.sys_clk_freq_hz); |
87 | dev_dbg(dev, "vt_pix_clk_freq_hz \t%d\n", pll->vt_pix_clk_freq_hz); | 87 | dev_dbg(dev, "vt_pix_clk_freq_hz \t%u\n", pll->vt.pix_clk_freq_hz); |
88 | } | ||
89 | |||
90 | static int check_all_bounds(struct device *dev, | ||
91 | const struct smiapp_pll_limits *limits, | ||
92 | const struct smiapp_pll_branch_limits *op_limits, | ||
93 | struct smiapp_pll *pll, | ||
94 | struct smiapp_pll_branch *op_pll) | ||
95 | { | ||
96 | int rval; | ||
97 | |||
98 | rval = bounds_check(dev, pll->pll_ip_clk_freq_hz, | ||
99 | limits->min_pll_ip_freq_hz, | ||
100 | limits->max_pll_ip_freq_hz, | ||
101 | "pll_ip_clk_freq_hz"); | ||
102 | if (!rval) | ||
103 | rval = bounds_check( | ||
104 | dev, pll->pll_multiplier, | ||
105 | limits->min_pll_multiplier, limits->max_pll_multiplier, | ||
106 | "pll_multiplier"); | ||
107 | if (!rval) | ||
108 | rval = bounds_check( | ||
109 | dev, pll->pll_op_clk_freq_hz, | ||
110 | limits->min_pll_op_freq_hz, limits->max_pll_op_freq_hz, | ||
111 | "pll_op_clk_freq_hz"); | ||
112 | if (!rval) | ||
113 | rval = bounds_check( | ||
114 | dev, op_pll->sys_clk_div, | ||
115 | op_limits->min_sys_clk_div, op_limits->max_sys_clk_div, | ||
116 | "op_sys_clk_div"); | ||
117 | if (!rval) | ||
118 | rval = bounds_check( | ||
119 | dev, op_pll->sys_clk_freq_hz, | ||
120 | op_limits->min_sys_clk_freq_hz, | ||
121 | op_limits->max_sys_clk_freq_hz, | ||
122 | "op_sys_clk_freq_hz"); | ||
123 | if (!rval) | ||
124 | rval = bounds_check( | ||
125 | dev, op_pll->pix_clk_freq_hz, | ||
126 | op_limits->min_pix_clk_freq_hz, | ||
127 | op_limits->max_pix_clk_freq_hz, | ||
128 | "op_pix_clk_freq_hz"); | ||
129 | |||
130 | /* | ||
131 | * If there are no OP clocks, the VT clocks are contained in | ||
132 | * the OP clock struct. | ||
133 | */ | ||
134 | if (pll->flags & SMIAPP_PLL_FLAG_NO_OP_CLOCKS) | ||
135 | return rval; | ||
136 | |||
137 | if (!rval) | ||
138 | rval = bounds_check( | ||
139 | dev, pll->vt.sys_clk_freq_hz, | ||
140 | limits->vt.min_sys_clk_freq_hz, | ||
141 | limits->vt.max_sys_clk_freq_hz, | ||
142 | "vt_sys_clk_freq_hz"); | ||
143 | if (!rval) | ||
144 | rval = bounds_check( | ||
145 | dev, pll->vt.pix_clk_freq_hz, | ||
146 | limits->vt.min_pix_clk_freq_hz, | ||
147 | limits->vt.max_pix_clk_freq_hz, | ||
148 | "vt_pix_clk_freq_hz"); | ||
149 | |||
150 | return rval; | ||
88 | } | 151 | } |
89 | 152 | ||
90 | /* | 153 | /* |
@@ -98,10 +161,11 @@ static void print_pll(struct device *dev, struct smiapp_pll *pll) | |||
98 | * | 161 | * |
99 | * @return Zero on success, error code on error. | 162 | * @return Zero on success, error code on error. |
100 | */ | 163 | */ |
101 | static int __smiapp_pll_calculate(struct device *dev, | 164 | static int __smiapp_pll_calculate( |
102 | const struct smiapp_pll_limits *limits, | 165 | struct device *dev, const struct smiapp_pll_limits *limits, |
103 | struct smiapp_pll *pll, uint32_t mul, | 166 | const struct smiapp_pll_branch_limits *op_limits, |
104 | uint32_t div, uint32_t lane_op_clock_ratio) | 167 | struct smiapp_pll *pll, struct smiapp_pll_branch *op_pll, uint32_t mul, |
168 | uint32_t div, uint32_t lane_op_clock_ratio) | ||
105 | { | 169 | { |
106 | uint32_t sys_div; | 170 | uint32_t sys_div; |
107 | uint32_t best_pix_div = INT_MAX >> 1; | 171 | uint32_t best_pix_div = INT_MAX >> 1; |
@@ -117,17 +181,16 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
117 | uint32_t min_vt_div, max_vt_div, vt_div; | 181 | uint32_t min_vt_div, max_vt_div, vt_div; |
118 | uint32_t min_sys_div, max_sys_div; | 182 | uint32_t min_sys_div, max_sys_div; |
119 | unsigned int i; | 183 | unsigned int i; |
120 | int rval; | ||
121 | 184 | ||
122 | /* | 185 | /* |
123 | * Get pre_pll_clk_div so that our pll_op_clk_freq_hz won't be | 186 | * Get pre_pll_clk_div so that our pll_op_clk_freq_hz won't be |
124 | * too high. | 187 | * too high. |
125 | */ | 188 | */ |
126 | dev_dbg(dev, "pre_pll_clk_div %d\n", pll->pre_pll_clk_div); | 189 | dev_dbg(dev, "pre_pll_clk_div %u\n", pll->pre_pll_clk_div); |
127 | 190 | ||
128 | /* Don't go above max pll multiplier. */ | 191 | /* Don't go above max pll multiplier. */ |
129 | more_mul_max = limits->max_pll_multiplier / mul; | 192 | more_mul_max = limits->max_pll_multiplier / mul; |
130 | dev_dbg(dev, "more_mul_max: max_pll_multiplier check: %d\n", | 193 | dev_dbg(dev, "more_mul_max: max_pll_multiplier check: %u\n", |
131 | more_mul_max); | 194 | more_mul_max); |
132 | /* Don't go above max pll op frequency. */ | 195 | /* Don't go above max pll op frequency. */ |
133 | more_mul_max = | 196 | more_mul_max = |
@@ -135,30 +198,30 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
135 | more_mul_max, | 198 | more_mul_max, |
136 | limits->max_pll_op_freq_hz | 199 | limits->max_pll_op_freq_hz |
137 | / (pll->ext_clk_freq_hz / pll->pre_pll_clk_div * mul)); | 200 | / (pll->ext_clk_freq_hz / pll->pre_pll_clk_div * mul)); |
138 | dev_dbg(dev, "more_mul_max: max_pll_op_freq_hz check: %d\n", | 201 | dev_dbg(dev, "more_mul_max: max_pll_op_freq_hz check: %u\n", |
139 | more_mul_max); | 202 | more_mul_max); |
140 | /* Don't go above the division capability of op sys clock divider. */ | 203 | /* Don't go above the division capability of op sys clock divider. */ |
141 | more_mul_max = min(more_mul_max, | 204 | more_mul_max = min(more_mul_max, |
142 | limits->op.max_sys_clk_div * pll->pre_pll_clk_div | 205 | op_limits->max_sys_clk_div * pll->pre_pll_clk_div |
143 | / div); | 206 | / div); |
144 | dev_dbg(dev, "more_mul_max: max_op_sys_clk_div check: %d\n", | 207 | dev_dbg(dev, "more_mul_max: max_op_sys_clk_div check: %u\n", |
145 | more_mul_max); | 208 | more_mul_max); |
146 | /* Ensure we won't go above min_pll_multiplier. */ | 209 | /* Ensure we won't go above min_pll_multiplier. */ |
147 | more_mul_max = min(more_mul_max, | 210 | more_mul_max = min(more_mul_max, |
148 | DIV_ROUND_UP(limits->max_pll_multiplier, mul)); | 211 | DIV_ROUND_UP(limits->max_pll_multiplier, mul)); |
149 | dev_dbg(dev, "more_mul_max: min_pll_multiplier check: %d\n", | 212 | dev_dbg(dev, "more_mul_max: min_pll_multiplier check: %u\n", |
150 | more_mul_max); | 213 | more_mul_max); |
151 | 214 | ||
152 | /* Ensure we won't go below min_pll_op_freq_hz. */ | 215 | /* Ensure we won't go below min_pll_op_freq_hz. */ |
153 | more_mul_min = DIV_ROUND_UP(limits->min_pll_op_freq_hz, | 216 | more_mul_min = DIV_ROUND_UP(limits->min_pll_op_freq_hz, |
154 | pll->ext_clk_freq_hz / pll->pre_pll_clk_div | 217 | pll->ext_clk_freq_hz / pll->pre_pll_clk_div |
155 | * mul); | 218 | * mul); |
156 | dev_dbg(dev, "more_mul_min: min_pll_op_freq_hz check: %d\n", | 219 | dev_dbg(dev, "more_mul_min: min_pll_op_freq_hz check: %u\n", |
157 | more_mul_min); | 220 | more_mul_min); |
158 | /* Ensure we won't go below min_pll_multiplier. */ | 221 | /* Ensure we won't go below min_pll_multiplier. */ |
159 | more_mul_min = max(more_mul_min, | 222 | more_mul_min = max(more_mul_min, |
160 | DIV_ROUND_UP(limits->min_pll_multiplier, mul)); | 223 | DIV_ROUND_UP(limits->min_pll_multiplier, mul)); |
161 | dev_dbg(dev, "more_mul_min: min_pll_multiplier check: %d\n", | 224 | dev_dbg(dev, "more_mul_min: min_pll_multiplier check: %u\n", |
162 | more_mul_min); | 225 | more_mul_min); |
163 | 226 | ||
164 | if (more_mul_min > more_mul_max) { | 227 | if (more_mul_min > more_mul_max) { |
@@ -168,23 +231,23 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
168 | } | 231 | } |
169 | 232 | ||
170 | more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div; | 233 | more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div; |
171 | dev_dbg(dev, "more_mul_factor: %d\n", more_mul_factor); | 234 | dev_dbg(dev, "more_mul_factor: %u\n", more_mul_factor); |
172 | more_mul_factor = lcm(more_mul_factor, limits->op.min_sys_clk_div); | 235 | more_mul_factor = lcm(more_mul_factor, op_limits->min_sys_clk_div); |
173 | dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n", | 236 | dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n", |
174 | more_mul_factor); | 237 | more_mul_factor); |
175 | i = roundup(more_mul_min, more_mul_factor); | 238 | i = roundup(more_mul_min, more_mul_factor); |
176 | if (!is_one_or_even(i)) | 239 | if (!is_one_or_even(i)) |
177 | i <<= 1; | 240 | i <<= 1; |
178 | 241 | ||
179 | dev_dbg(dev, "final more_mul: %d\n", i); | 242 | dev_dbg(dev, "final more_mul: %u\n", i); |
180 | if (i > more_mul_max) { | 243 | if (i > more_mul_max) { |
181 | dev_dbg(dev, "final more_mul is bad, max %d\n", more_mul_max); | 244 | dev_dbg(dev, "final more_mul is bad, max %u\n", more_mul_max); |
182 | return -EINVAL; | 245 | return -EINVAL; |
183 | } | 246 | } |
184 | 247 | ||
185 | pll->pll_multiplier = mul * i; | 248 | pll->pll_multiplier = mul * i; |
186 | pll->op_sys_clk_div = div * i / pll->pre_pll_clk_div; | 249 | op_pll->sys_clk_div = div * i / pll->pre_pll_clk_div; |
187 | dev_dbg(dev, "op_sys_clk_div: %d\n", pll->op_sys_clk_div); | 250 | dev_dbg(dev, "op_sys_clk_div: %u\n", op_pll->sys_clk_div); |
188 | 251 | ||
189 | pll->pll_ip_clk_freq_hz = pll->ext_clk_freq_hz | 252 | pll->pll_ip_clk_freq_hz = pll->ext_clk_freq_hz |
190 | / pll->pre_pll_clk_div; | 253 | / pll->pre_pll_clk_div; |
@@ -193,14 +256,19 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
193 | * pll->pll_multiplier; | 256 | * pll->pll_multiplier; |
194 | 257 | ||
195 | /* Derive pll_op_clk_freq_hz. */ | 258 | /* Derive pll_op_clk_freq_hz. */ |
196 | pll->op_sys_clk_freq_hz = | 259 | op_pll->sys_clk_freq_hz = |
197 | pll->pll_op_clk_freq_hz / pll->op_sys_clk_div; | 260 | pll->pll_op_clk_freq_hz / op_pll->sys_clk_div; |
261 | |||
262 | op_pll->pix_clk_div = pll->bits_per_pixel; | ||
263 | dev_dbg(dev, "op_pix_clk_div: %u\n", op_pll->pix_clk_div); | ||
198 | 264 | ||
199 | pll->op_pix_clk_div = pll->bits_per_pixel; | 265 | op_pll->pix_clk_freq_hz = |
200 | dev_dbg(dev, "op_pix_clk_div: %d\n", pll->op_pix_clk_div); | 266 | op_pll->sys_clk_freq_hz / op_pll->pix_clk_div; |
201 | 267 | ||
202 | pll->op_pix_clk_freq_hz = | 268 | if (pll->flags & SMIAPP_PLL_FLAG_NO_OP_CLOCKS) { |
203 | pll->op_sys_clk_freq_hz / pll->op_pix_clk_div; | 269 | /* No OP clocks --- VT clocks are used instead. */ |
270 | goto out_skip_vt_calc; | ||
271 | } | ||
204 | 272 | ||
205 | /* | 273 | /* |
206 | * Some sensors perform analogue binning and some do this | 274 | * Some sensors perform analogue binning and some do this |
@@ -214,7 +282,7 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
214 | vt_op_binning_div = pll->binning_horizontal; | 282 | vt_op_binning_div = pll->binning_horizontal; |
215 | else | 283 | else |
216 | vt_op_binning_div = 1; | 284 | vt_op_binning_div = 1; |
217 | dev_dbg(dev, "vt_op_binning_div: %d\n", vt_op_binning_div); | 285 | dev_dbg(dev, "vt_op_binning_div: %u\n", vt_op_binning_div); |
218 | 286 | ||
219 | /* | 287 | /* |
220 | * Profile 2 supports vt_pix_clk_div E [4, 10] | 288 | * Profile 2 supports vt_pix_clk_div E [4, 10] |
@@ -227,30 +295,30 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
227 | * | 295 | * |
228 | * Find absolute limits for the factor of vt divider. | 296 | * Find absolute limits for the factor of vt divider. |
229 | */ | 297 | */ |
230 | dev_dbg(dev, "scale_m: %d\n", pll->scale_m); | 298 | dev_dbg(dev, "scale_m: %u\n", pll->scale_m); |
231 | min_vt_div = DIV_ROUND_UP(pll->op_pix_clk_div * pll->op_sys_clk_div | 299 | min_vt_div = DIV_ROUND_UP(op_pll->pix_clk_div * op_pll->sys_clk_div |
232 | * pll->scale_n, | 300 | * pll->scale_n, |
233 | lane_op_clock_ratio * vt_op_binning_div | 301 | lane_op_clock_ratio * vt_op_binning_div |
234 | * pll->scale_m); | 302 | * pll->scale_m); |
235 | 303 | ||
236 | /* Find smallest and biggest allowed vt divisor. */ | 304 | /* Find smallest and biggest allowed vt divisor. */ |
237 | dev_dbg(dev, "min_vt_div: %d\n", min_vt_div); | 305 | dev_dbg(dev, "min_vt_div: %u\n", min_vt_div); |
238 | min_vt_div = max(min_vt_div, | 306 | min_vt_div = max(min_vt_div, |
239 | DIV_ROUND_UP(pll->pll_op_clk_freq_hz, | 307 | DIV_ROUND_UP(pll->pll_op_clk_freq_hz, |
240 | limits->vt.max_pix_clk_freq_hz)); | 308 | limits->vt.max_pix_clk_freq_hz)); |
241 | dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %d\n", | 309 | dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %u\n", |
242 | min_vt_div); | 310 | min_vt_div); |
243 | min_vt_div = max_t(uint32_t, min_vt_div, | 311 | min_vt_div = max_t(uint32_t, min_vt_div, |
244 | limits->vt.min_pix_clk_div | 312 | limits->vt.min_pix_clk_div |
245 | * limits->vt.min_sys_clk_div); | 313 | * limits->vt.min_sys_clk_div); |
246 | dev_dbg(dev, "min_vt_div: min_vt_clk_div: %d\n", min_vt_div); | 314 | dev_dbg(dev, "min_vt_div: min_vt_clk_div: %u\n", min_vt_div); |
247 | 315 | ||
248 | max_vt_div = limits->vt.max_sys_clk_div * limits->vt.max_pix_clk_div; | 316 | max_vt_div = limits->vt.max_sys_clk_div * limits->vt.max_pix_clk_div; |
249 | dev_dbg(dev, "max_vt_div: %d\n", max_vt_div); | 317 | dev_dbg(dev, "max_vt_div: %u\n", max_vt_div); |
250 | max_vt_div = min(max_vt_div, | 318 | max_vt_div = min(max_vt_div, |
251 | DIV_ROUND_UP(pll->pll_op_clk_freq_hz, | 319 | DIV_ROUND_UP(pll->pll_op_clk_freq_hz, |
252 | limits->vt.min_pix_clk_freq_hz)); | 320 | limits->vt.min_pix_clk_freq_hz)); |
253 | dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %d\n", | 321 | dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %u\n", |
254 | max_vt_div); | 322 | max_vt_div); |
255 | 323 | ||
256 | /* | 324 | /* |
@@ -258,28 +326,28 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
258 | * with all values of pix_clk_div. | 326 | * with all values of pix_clk_div. |
259 | */ | 327 | */ |
260 | min_sys_div = limits->vt.min_sys_clk_div; | 328 | min_sys_div = limits->vt.min_sys_clk_div; |
261 | dev_dbg(dev, "min_sys_div: %d\n", min_sys_div); | 329 | dev_dbg(dev, "min_sys_div: %u\n", min_sys_div); |
262 | min_sys_div = max(min_sys_div, | 330 | min_sys_div = max(min_sys_div, |
263 | DIV_ROUND_UP(min_vt_div, | 331 | DIV_ROUND_UP(min_vt_div, |
264 | limits->vt.max_pix_clk_div)); | 332 | limits->vt.max_pix_clk_div)); |
265 | dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %d\n", min_sys_div); | 333 | dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %u\n", min_sys_div); |
266 | min_sys_div = max(min_sys_div, | 334 | min_sys_div = max(min_sys_div, |
267 | pll->pll_op_clk_freq_hz | 335 | pll->pll_op_clk_freq_hz |
268 | / limits->vt.max_sys_clk_freq_hz); | 336 | / limits->vt.max_sys_clk_freq_hz); |
269 | dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %d\n", min_sys_div); | 337 | dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %u\n", min_sys_div); |
270 | min_sys_div = clk_div_even_up(min_sys_div); | 338 | min_sys_div = clk_div_even_up(min_sys_div); |
271 | dev_dbg(dev, "min_sys_div: one or even: %d\n", min_sys_div); | 339 | dev_dbg(dev, "min_sys_div: one or even: %u\n", min_sys_div); |
272 | 340 | ||
273 | max_sys_div = limits->vt.max_sys_clk_div; | 341 | max_sys_div = limits->vt.max_sys_clk_div; |
274 | dev_dbg(dev, "max_sys_div: %d\n", max_sys_div); | 342 | dev_dbg(dev, "max_sys_div: %u\n", max_sys_div); |
275 | max_sys_div = min(max_sys_div, | 343 | max_sys_div = min(max_sys_div, |
276 | DIV_ROUND_UP(max_vt_div, | 344 | DIV_ROUND_UP(max_vt_div, |
277 | limits->vt.min_pix_clk_div)); | 345 | limits->vt.min_pix_clk_div)); |
278 | dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %d\n", max_sys_div); | 346 | dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %u\n", max_sys_div); |
279 | max_sys_div = min(max_sys_div, | 347 | max_sys_div = min(max_sys_div, |
280 | DIV_ROUND_UP(pll->pll_op_clk_freq_hz, | 348 | DIV_ROUND_UP(pll->pll_op_clk_freq_hz, |
281 | limits->vt.min_pix_clk_freq_hz)); | 349 | limits->vt.min_pix_clk_freq_hz)); |
282 | dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %d\n", max_sys_div); | 350 | dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %u\n", max_sys_div); |
283 | 351 | ||
284 | /* | 352 | /* |
285 | * Find pix_div such that a legal pix_div * sys_div results | 353 | * Find pix_div such that a legal pix_div * sys_div results |
@@ -296,7 +364,7 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
296 | if (pix_div < limits->vt.min_pix_clk_div | 364 | if (pix_div < limits->vt.min_pix_clk_div |
297 | || pix_div > limits->vt.max_pix_clk_div) { | 365 | || pix_div > limits->vt.max_pix_clk_div) { |
298 | dev_dbg(dev, | 366 | dev_dbg(dev, |
299 | "pix_div %d too small or too big (%d--%d)\n", | 367 | "pix_div %u too small or too big (%u--%u)\n", |
300 | pix_div, | 368 | pix_div, |
301 | limits->vt.min_pix_clk_div, | 369 | limits->vt.min_pix_clk_div, |
302 | limits->vt.max_pix_clk_div); | 370 | limits->vt.max_pix_clk_div); |
@@ -312,73 +380,28 @@ static int __smiapp_pll_calculate(struct device *dev, | |||
312 | break; | 380 | break; |
313 | } | 381 | } |
314 | 382 | ||
315 | pll->vt_sys_clk_div = DIV_ROUND_UP(min_vt_div, best_pix_div); | 383 | pll->vt.sys_clk_div = DIV_ROUND_UP(min_vt_div, best_pix_div); |
316 | pll->vt_pix_clk_div = best_pix_div; | 384 | pll->vt.pix_clk_div = best_pix_div; |
317 | 385 | ||
318 | pll->vt_sys_clk_freq_hz = | 386 | pll->vt.sys_clk_freq_hz = |
319 | pll->pll_op_clk_freq_hz / pll->vt_sys_clk_div; | 387 | pll->pll_op_clk_freq_hz / pll->vt.sys_clk_div; |
320 | pll->vt_pix_clk_freq_hz = | 388 | pll->vt.pix_clk_freq_hz = |
321 | pll->vt_sys_clk_freq_hz / pll->vt_pix_clk_div; | 389 | pll->vt.sys_clk_freq_hz / pll->vt.pix_clk_div; |
322 | 390 | ||
391 | out_skip_vt_calc: | ||
323 | pll->pixel_rate_csi = | 392 | pll->pixel_rate_csi = |
324 | pll->op_pix_clk_freq_hz * lane_op_clock_ratio; | 393 | op_pll->pix_clk_freq_hz * lane_op_clock_ratio; |
394 | pll->pixel_rate_pixel_array = pll->vt.pix_clk_freq_hz; | ||
325 | 395 | ||
326 | rval = bounds_check(dev, pll->pll_ip_clk_freq_hz, | 396 | return check_all_bounds(dev, limits, op_limits, pll, op_pll); |
327 | limits->min_pll_ip_freq_hz, | ||
328 | limits->max_pll_ip_freq_hz, | ||
329 | "pll_ip_clk_freq_hz"); | ||
330 | if (!rval) | ||
331 | rval = bounds_check( | ||
332 | dev, pll->pll_multiplier, | ||
333 | limits->min_pll_multiplier, limits->max_pll_multiplier, | ||
334 | "pll_multiplier"); | ||
335 | if (!rval) | ||
336 | rval = bounds_check( | ||
337 | dev, pll->pll_op_clk_freq_hz, | ||
338 | limits->min_pll_op_freq_hz, limits->max_pll_op_freq_hz, | ||
339 | "pll_op_clk_freq_hz"); | ||
340 | if (!rval) | ||
341 | rval = bounds_check( | ||
342 | dev, pll->op_sys_clk_div, | ||
343 | limits->op.min_sys_clk_div, limits->op.max_sys_clk_div, | ||
344 | "op_sys_clk_div"); | ||
345 | if (!rval) | ||
346 | rval = bounds_check( | ||
347 | dev, pll->op_pix_clk_div, | ||
348 | limits->op.min_pix_clk_div, limits->op.max_pix_clk_div, | ||
349 | "op_pix_clk_div"); | ||
350 | if (!rval) | ||
351 | rval = bounds_check( | ||
352 | dev, pll->op_sys_clk_freq_hz, | ||
353 | limits->op.min_sys_clk_freq_hz, | ||
354 | limits->op.max_sys_clk_freq_hz, | ||
355 | "op_sys_clk_freq_hz"); | ||
356 | if (!rval) | ||
357 | rval = bounds_check( | ||
358 | dev, pll->op_pix_clk_freq_hz, | ||
359 | limits->op.min_pix_clk_freq_hz, | ||
360 | limits->op.max_pix_clk_freq_hz, | ||
361 | "op_pix_clk_freq_hz"); | ||
362 | if (!rval) | ||
363 | rval = bounds_check( | ||
364 | dev, pll->vt_sys_clk_freq_hz, | ||
365 | limits->vt.min_sys_clk_freq_hz, | ||
366 | limits->vt.max_sys_clk_freq_hz, | ||
367 | "vt_sys_clk_freq_hz"); | ||
368 | if (!rval) | ||
369 | rval = bounds_check( | ||
370 | dev, pll->vt_pix_clk_freq_hz, | ||
371 | limits->vt.min_pix_clk_freq_hz, | ||
372 | limits->vt.max_pix_clk_freq_hz, | ||
373 | "vt_pix_clk_freq_hz"); | ||
374 | |||
375 | return rval; | ||
376 | } | 397 | } |
377 | 398 | ||
378 | int smiapp_pll_calculate(struct device *dev, | 399 | int smiapp_pll_calculate(struct device *dev, |
379 | const struct smiapp_pll_limits *limits, | 400 | const struct smiapp_pll_limits *limits, |
380 | struct smiapp_pll *pll) | 401 | struct smiapp_pll *pll) |
381 | { | 402 | { |
403 | const struct smiapp_pll_branch_limits *op_limits = &limits->op; | ||
404 | struct smiapp_pll_branch *op_pll = &pll->op; | ||
382 | uint16_t min_pre_pll_clk_div; | 405 | uint16_t min_pre_pll_clk_div; |
383 | uint16_t max_pre_pll_clk_div; | 406 | uint16_t max_pre_pll_clk_div; |
384 | uint32_t lane_op_clock_ratio; | 407 | uint32_t lane_op_clock_ratio; |
@@ -386,13 +409,23 @@ int smiapp_pll_calculate(struct device *dev, | |||
386 | unsigned int i; | 409 | unsigned int i; |
387 | int rval = -EINVAL; | 410 | int rval = -EINVAL; |
388 | 411 | ||
412 | if (pll->flags & SMIAPP_PLL_FLAG_NO_OP_CLOCKS) { | ||
413 | /* | ||
414 | * If there's no OP PLL at all, use the VT values | ||
415 | * instead. The OP values are ignored for the rest of | ||
416 | * the PLL calculation. | ||
417 | */ | ||
418 | op_limits = &limits->vt; | ||
419 | op_pll = &pll->vt; | ||
420 | } | ||
421 | |||
389 | if (pll->flags & SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE) | 422 | if (pll->flags & SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE) |
390 | lane_op_clock_ratio = pll->csi2.lanes; | 423 | lane_op_clock_ratio = pll->csi2.lanes; |
391 | else | 424 | else |
392 | lane_op_clock_ratio = 1; | 425 | lane_op_clock_ratio = 1; |
393 | dev_dbg(dev, "lane_op_clock_ratio: %d\n", lane_op_clock_ratio); | 426 | dev_dbg(dev, "lane_op_clock_ratio: %u\n", lane_op_clock_ratio); |
394 | 427 | ||
395 | dev_dbg(dev, "binning: %dx%d\n", pll->binning_horizontal, | 428 | dev_dbg(dev, "binning: %ux%u\n", pll->binning_horizontal, |
396 | pll->binning_vertical); | 429 | pll->binning_vertical); |
397 | 430 | ||
398 | switch (pll->bus_type) { | 431 | switch (pll->bus_type) { |
@@ -411,7 +444,7 @@ int smiapp_pll_calculate(struct device *dev, | |||
411 | } | 444 | } |
412 | 445 | ||
413 | /* Figure out limits for pre-pll divider based on extclk */ | 446 | /* Figure out limits for pre-pll divider based on extclk */ |
414 | dev_dbg(dev, "min / max pre_pll_clk_div: %d / %d\n", | 447 | dev_dbg(dev, "min / max pre_pll_clk_div: %u / %u\n", |
415 | limits->min_pre_pll_clk_div, limits->max_pre_pll_clk_div); | 448 | limits->min_pre_pll_clk_div, limits->max_pre_pll_clk_div); |
416 | max_pre_pll_clk_div = | 449 | max_pre_pll_clk_div = |
417 | min_t(uint16_t, limits->max_pre_pll_clk_div, | 450 | min_t(uint16_t, limits->max_pre_pll_clk_div, |
@@ -422,26 +455,27 @@ int smiapp_pll_calculate(struct device *dev, | |||
422 | clk_div_even_up( | 455 | clk_div_even_up( |
423 | DIV_ROUND_UP(pll->ext_clk_freq_hz, | 456 | DIV_ROUND_UP(pll->ext_clk_freq_hz, |
424 | limits->max_pll_ip_freq_hz))); | 457 | limits->max_pll_ip_freq_hz))); |
425 | dev_dbg(dev, "pre-pll check: min / max pre_pll_clk_div: %d / %d\n", | 458 | dev_dbg(dev, "pre-pll check: min / max pre_pll_clk_div: %u / %u\n", |
426 | min_pre_pll_clk_div, max_pre_pll_clk_div); | 459 | min_pre_pll_clk_div, max_pre_pll_clk_div); |
427 | 460 | ||
428 | i = gcd(pll->pll_op_clk_freq_hz, pll->ext_clk_freq_hz); | 461 | i = gcd(pll->pll_op_clk_freq_hz, pll->ext_clk_freq_hz); |
429 | mul = div_u64(pll->pll_op_clk_freq_hz, i); | 462 | mul = div_u64(pll->pll_op_clk_freq_hz, i); |
430 | div = pll->ext_clk_freq_hz / i; | 463 | div = pll->ext_clk_freq_hz / i; |
431 | dev_dbg(dev, "mul %d / div %d\n", mul, div); | 464 | dev_dbg(dev, "mul %u / div %u\n", mul, div); |
432 | 465 | ||
433 | min_pre_pll_clk_div = | 466 | min_pre_pll_clk_div = |
434 | max_t(uint16_t, min_pre_pll_clk_div, | 467 | max_t(uint16_t, min_pre_pll_clk_div, |
435 | clk_div_even_up( | 468 | clk_div_even_up( |
436 | DIV_ROUND_UP(mul * pll->ext_clk_freq_hz, | 469 | DIV_ROUND_UP(mul * pll->ext_clk_freq_hz, |
437 | limits->max_pll_op_freq_hz))); | 470 | limits->max_pll_op_freq_hz))); |
438 | dev_dbg(dev, "pll_op check: min / max pre_pll_clk_div: %d / %d\n", | 471 | dev_dbg(dev, "pll_op check: min / max pre_pll_clk_div: %u / %u\n", |
439 | min_pre_pll_clk_div, max_pre_pll_clk_div); | 472 | min_pre_pll_clk_div, max_pre_pll_clk_div); |
440 | 473 | ||
441 | for (pll->pre_pll_clk_div = min_pre_pll_clk_div; | 474 | for (pll->pre_pll_clk_div = min_pre_pll_clk_div; |
442 | pll->pre_pll_clk_div <= max_pre_pll_clk_div; | 475 | pll->pre_pll_clk_div <= max_pre_pll_clk_div; |
443 | pll->pre_pll_clk_div += 2 - (pll->pre_pll_clk_div & 1)) { | 476 | pll->pre_pll_clk_div += 2 - (pll->pre_pll_clk_div & 1)) { |
444 | rval = __smiapp_pll_calculate(dev, limits, pll, mul, div, | 477 | rval = __smiapp_pll_calculate(dev, limits, op_limits, pll, |
478 | op_pll, mul, div, | ||
445 | lane_op_clock_ratio); | 479 | lane_op_clock_ratio); |
446 | if (rval) | 480 | if (rval) |
447 | continue; | 481 | continue; |
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h index 5ce2b61da3c5..e8f035a50c76 100644 --- a/drivers/media/i2c/smiapp-pll.h +++ b/drivers/media/i2c/smiapp-pll.h | |||
@@ -35,6 +35,13 @@ | |||
35 | #define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0) | 35 | #define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0) |
36 | #define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1) | 36 | #define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1) |
37 | 37 | ||
38 | struct smiapp_pll_branch { | ||
39 | uint16_t sys_clk_div; | ||
40 | uint16_t pix_clk_div; | ||
41 | uint32_t sys_clk_freq_hz; | ||
42 | uint32_t pix_clk_freq_hz; | ||
43 | }; | ||
44 | |||
38 | struct smiapp_pll { | 45 | struct smiapp_pll { |
39 | /* input values */ | 46 | /* input values */ |
40 | uint8_t bus_type; | 47 | uint8_t bus_type; |
@@ -53,24 +60,18 @@ struct smiapp_pll { | |||
53 | uint8_t scale_n; | 60 | uint8_t scale_n; |
54 | uint8_t bits_per_pixel; | 61 | uint8_t bits_per_pixel; |
55 | uint32_t link_freq; | 62 | uint32_t link_freq; |
63 | uint32_t ext_clk_freq_hz; | ||
56 | 64 | ||
57 | /* output values */ | 65 | /* output values */ |
58 | uint16_t pre_pll_clk_div; | 66 | uint16_t pre_pll_clk_div; |
59 | uint16_t pll_multiplier; | 67 | uint16_t pll_multiplier; |
60 | uint16_t op_sys_clk_div; | ||
61 | uint16_t op_pix_clk_div; | ||
62 | uint16_t vt_sys_clk_div; | ||
63 | uint16_t vt_pix_clk_div; | ||
64 | |||
65 | uint32_t ext_clk_freq_hz; | ||
66 | uint32_t pll_ip_clk_freq_hz; | 68 | uint32_t pll_ip_clk_freq_hz; |
67 | uint32_t pll_op_clk_freq_hz; | 69 | uint32_t pll_op_clk_freq_hz; |
68 | uint32_t op_sys_clk_freq_hz; | 70 | struct smiapp_pll_branch vt; |
69 | uint32_t op_pix_clk_freq_hz; | 71 | struct smiapp_pll_branch op; |
70 | uint32_t vt_sys_clk_freq_hz; | ||
71 | uint32_t vt_pix_clk_freq_hz; | ||
72 | 72 | ||
73 | uint32_t pixel_rate_csi; | 73 | uint32_t pixel_rate_csi; |
74 | uint32_t pixel_rate_pixel_array; | ||
74 | }; | 75 | }; |
75 | 76 | ||
76 | struct smiapp_pll_branch_limits { | 77 | struct smiapp_pll_branch_limits { |
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index b10aaeda2bb4..0df5070e73c7 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c | |||
@@ -205,12 +205,12 @@ static int smiapp_pll_configure(struct smiapp_sensor *sensor) | |||
205 | int rval; | 205 | int rval; |
206 | 206 | ||
207 | rval = smiapp_write( | 207 | rval = smiapp_write( |
208 | sensor, SMIAPP_REG_U16_VT_PIX_CLK_DIV, pll->vt_pix_clk_div); | 208 | sensor, SMIAPP_REG_U16_VT_PIX_CLK_DIV, pll->vt.pix_clk_div); |
209 | if (rval < 0) | 209 | if (rval < 0) |
210 | return rval; | 210 | return rval; |
211 | 211 | ||
212 | rval = smiapp_write( | 212 | rval = smiapp_write( |
213 | sensor, SMIAPP_REG_U16_VT_SYS_CLK_DIV, pll->vt_sys_clk_div); | 213 | sensor, SMIAPP_REG_U16_VT_SYS_CLK_DIV, pll->vt.sys_clk_div); |
214 | if (rval < 0) | 214 | if (rval < 0) |
215 | return rval; | 215 | return rval; |
216 | 216 | ||
@@ -227,20 +227,21 @@ static int smiapp_pll_configure(struct smiapp_sensor *sensor) | |||
227 | /* Lane op clock ratio does not apply here. */ | 227 | /* Lane op clock ratio does not apply here. */ |
228 | rval = smiapp_write( | 228 | rval = smiapp_write( |
229 | sensor, SMIAPP_REG_U32_REQUESTED_LINK_BIT_RATE_MBPS, | 229 | sensor, SMIAPP_REG_U32_REQUESTED_LINK_BIT_RATE_MBPS, |
230 | DIV_ROUND_UP(pll->op_sys_clk_freq_hz, 1000000 / 256 / 256)); | 230 | DIV_ROUND_UP(pll->op.sys_clk_freq_hz, 1000000 / 256 / 256)); |
231 | if (rval < 0 || sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) | 231 | if (rval < 0 || sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) |
232 | return rval; | 232 | return rval; |
233 | 233 | ||
234 | rval = smiapp_write( | 234 | rval = smiapp_write( |
235 | sensor, SMIAPP_REG_U16_OP_PIX_CLK_DIV, pll->op_pix_clk_div); | 235 | sensor, SMIAPP_REG_U16_OP_PIX_CLK_DIV, pll->op.pix_clk_div); |
236 | if (rval < 0) | 236 | if (rval < 0) |
237 | return rval; | 237 | return rval; |
238 | 238 | ||
239 | return smiapp_write( | 239 | return smiapp_write( |
240 | sensor, SMIAPP_REG_U16_OP_SYS_CLK_DIV, pll->op_sys_clk_div); | 240 | sensor, SMIAPP_REG_U16_OP_SYS_CLK_DIV, pll->op.sys_clk_div); |
241 | } | 241 | } |
242 | 242 | ||
243 | static int smiapp_pll_update(struct smiapp_sensor *sensor) | 243 | static int smiapp_pll_try(struct smiapp_sensor *sensor, |
244 | struct smiapp_pll *pll) | ||
244 | { | 245 | { |
245 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); | 246 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); |
246 | struct smiapp_pll_limits lim = { | 247 | struct smiapp_pll_limits lim = { |
@@ -274,19 +275,15 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor) | |||
274 | .min_line_length_pck_bin = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN], | 275 | .min_line_length_pck_bin = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN], |
275 | .min_line_length_pck = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK], | 276 | .min_line_length_pck = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK], |
276 | }; | 277 | }; |
278 | |||
279 | return smiapp_pll_calculate(&client->dev, &lim, pll); | ||
280 | } | ||
281 | |||
282 | static int smiapp_pll_update(struct smiapp_sensor *sensor) | ||
283 | { | ||
277 | struct smiapp_pll *pll = &sensor->pll; | 284 | struct smiapp_pll *pll = &sensor->pll; |
278 | int rval; | 285 | int rval; |
279 | 286 | ||
280 | if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) { | ||
281 | /* | ||
282 | * Fill in operational clock divisors limits from the | ||
283 | * video timing ones. On profile 0 sensors the | ||
284 | * requirements regarding them are essentially the | ||
285 | * same as on VT ones. | ||
286 | */ | ||
287 | lim.op = lim.vt; | ||
288 | } | ||
289 | |||
290 | pll->binning_horizontal = sensor->binning_horizontal; | 287 | pll->binning_horizontal = sensor->binning_horizontal; |
291 | pll->binning_vertical = sensor->binning_vertical; | 288 | pll->binning_vertical = sensor->binning_vertical; |
292 | pll->link_freq = | 289 | pll->link_freq = |
@@ -294,12 +291,12 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor) | |||
294 | pll->scale_m = sensor->scale_m; | 291 | pll->scale_m = sensor->scale_m; |
295 | pll->bits_per_pixel = sensor->csi_format->compressed; | 292 | pll->bits_per_pixel = sensor->csi_format->compressed; |
296 | 293 | ||
297 | rval = smiapp_pll_calculate(&client->dev, &lim, pll); | 294 | rval = smiapp_pll_try(sensor, pll); |
298 | if (rval < 0) | 295 | if (rval < 0) |
299 | return rval; | 296 | return rval; |
300 | 297 | ||
301 | __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_parray, | 298 | __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_parray, |
302 | pll->vt_pix_clk_freq_hz); | 299 | pll->pixel_rate_pixel_array); |
303 | __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_csi, pll->pixel_rate_csi); | 300 | __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_csi, pll->pixel_rate_csi); |
304 | 301 | ||
305 | return 0; | 302 | return 0; |
@@ -333,22 +330,22 @@ static void __smiapp_update_exposure_limits(struct smiapp_sensor *sensor) | |||
333 | * orders must be defined. | 330 | * orders must be defined. |
334 | */ | 331 | */ |
335 | static const struct smiapp_csi_data_format smiapp_csi_data_formats[] = { | 332 | static const struct smiapp_csi_data_format smiapp_csi_data_formats[] = { |
336 | { V4L2_MBUS_FMT_SGRBG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GRBG, }, | 333 | { MEDIA_BUS_FMT_SGRBG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GRBG, }, |
337 | { V4L2_MBUS_FMT_SRGGB12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_RGGB, }, | 334 | { MEDIA_BUS_FMT_SRGGB12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_RGGB, }, |
338 | { V4L2_MBUS_FMT_SBGGR12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_BGGR, }, | 335 | { MEDIA_BUS_FMT_SBGGR12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_BGGR, }, |
339 | { V4L2_MBUS_FMT_SGBRG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GBRG, }, | 336 | { MEDIA_BUS_FMT_SGBRG12_1X12, 12, 12, SMIAPP_PIXEL_ORDER_GBRG, }, |
340 | { V4L2_MBUS_FMT_SGRBG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GRBG, }, | 337 | { MEDIA_BUS_FMT_SGRBG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GRBG, }, |
341 | { V4L2_MBUS_FMT_SRGGB10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_RGGB, }, | 338 | { MEDIA_BUS_FMT_SRGGB10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_RGGB, }, |
342 | { V4L2_MBUS_FMT_SBGGR10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_BGGR, }, | 339 | { MEDIA_BUS_FMT_SBGGR10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_BGGR, }, |
343 | { V4L2_MBUS_FMT_SGBRG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GBRG, }, | 340 | { MEDIA_BUS_FMT_SGBRG10_1X10, 10, 10, SMIAPP_PIXEL_ORDER_GBRG, }, |
344 | { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GRBG, }, | 341 | { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GRBG, }, |
345 | { V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_RGGB, }, | 342 | { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_RGGB, }, |
346 | { V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_BGGR, }, | 343 | { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_BGGR, }, |
347 | { V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GBRG, }, | 344 | { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, 10, 8, SMIAPP_PIXEL_ORDER_GBRG, }, |
348 | { V4L2_MBUS_FMT_SGRBG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GRBG, }, | 345 | { MEDIA_BUS_FMT_SGRBG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GRBG, }, |
349 | { V4L2_MBUS_FMT_SRGGB8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_RGGB, }, | 346 | { MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_RGGB, }, |
350 | { V4L2_MBUS_FMT_SBGGR8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_BGGR, }, | 347 | { MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_BGGR, }, |
351 | { V4L2_MBUS_FMT_SGBRG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GBRG, }, | 348 | { MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, SMIAPP_PIXEL_ORDER_GBRG, }, |
352 | }; | 349 | }; |
353 | 350 | ||
354 | const char *pixel_order_str[] = { "GRBG", "RGGB", "BGGR", "GBRG" }; | 351 | const char *pixel_order_str[] = { "GRBG", "RGGB", "BGGR", "GBRG" }; |
@@ -526,6 +523,8 @@ static const struct v4l2_ctrl_ops smiapp_ctrl_ops = { | |||
526 | static int smiapp_init_controls(struct smiapp_sensor *sensor) | 523 | static int smiapp_init_controls(struct smiapp_sensor *sensor) |
527 | { | 524 | { |
528 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); | 525 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); |
526 | unsigned long *valid_link_freqs = &sensor->valid_link_freqs[ | ||
527 | sensor->csi_format->compressed - SMIAPP_COMPRESSED_BASE]; | ||
529 | unsigned int max, i; | 528 | unsigned int max, i; |
530 | int rval; | 529 | int rval; |
531 | 530 | ||
@@ -608,8 +607,8 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) | |||
608 | 607 | ||
609 | sensor->link_freq = v4l2_ctrl_new_int_menu( | 608 | sensor->link_freq = v4l2_ctrl_new_int_menu( |
610 | &sensor->src->ctrl_handler, &smiapp_ctrl_ops, | 609 | &sensor->src->ctrl_handler, &smiapp_ctrl_ops, |
611 | V4L2_CID_LINK_FREQ, max, 0, | 610 | V4L2_CID_LINK_FREQ, __fls(*valid_link_freqs), |
612 | sensor->platform_data->op_sys_clock); | 611 | __ffs(*valid_link_freqs), sensor->platform_data->op_sys_clock); |
613 | 612 | ||
614 | sensor->pixel_rate_csi = v4l2_ctrl_new_std( | 613 | sensor->pixel_rate_csi = v4l2_ctrl_new_std( |
615 | &sensor->src->ctrl_handler, &smiapp_ctrl_ops, | 614 | &sensor->src->ctrl_handler, &smiapp_ctrl_ops, |
@@ -745,6 +744,7 @@ static int smiapp_get_limits_binning(struct smiapp_sensor *sensor) | |||
745 | static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor) | 744 | static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor) |
746 | { | 745 | { |
747 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); | 746 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); |
747 | struct smiapp_pll *pll = &sensor->pll; | ||
748 | unsigned int type, n; | 748 | unsigned int type, n; |
749 | unsigned int i, pixel_order; | 749 | unsigned int i, pixel_order; |
750 | int rval; | 750 | int rval; |
@@ -808,14 +808,57 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor) | |||
808 | dev_dbg(&client->dev, "jolly good! %d\n", j); | 808 | dev_dbg(&client->dev, "jolly good! %d\n", j); |
809 | 809 | ||
810 | sensor->default_mbus_frame_fmts |= 1 << j; | 810 | sensor->default_mbus_frame_fmts |= 1 << j; |
811 | if (!sensor->csi_format | 811 | } |
812 | || f->width > sensor->csi_format->width | 812 | } |
813 | || (f->width == sensor->csi_format->width | 813 | |
814 | && f->compressed | 814 | /* Figure out which BPP values can be used with which formats. */ |
815 | > sensor->csi_format->compressed)) { | 815 | pll->binning_horizontal = 1; |
816 | sensor->csi_format = f; | 816 | pll->binning_vertical = 1; |
817 | sensor->internal_csi_format = f; | 817 | pll->scale_m = sensor->scale_m; |
818 | } | 818 | |
819 | for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) { | ||
820 | const struct smiapp_csi_data_format *f = | ||
821 | &smiapp_csi_data_formats[i]; | ||
822 | unsigned long *valid_link_freqs = | ||
823 | &sensor->valid_link_freqs[ | ||
824 | f->compressed - SMIAPP_COMPRESSED_BASE]; | ||
825 | unsigned int j; | ||
826 | |||
827 | BUG_ON(f->compressed < SMIAPP_COMPRESSED_BASE); | ||
828 | BUG_ON(f->compressed > SMIAPP_COMPRESSED_MAX); | ||
829 | |||
830 | if (!(sensor->default_mbus_frame_fmts & 1 << i)) | ||
831 | continue; | ||
832 | |||
833 | pll->bits_per_pixel = f->compressed; | ||
834 | |||
835 | for (j = 0; sensor->platform_data->op_sys_clock[j]; j++) { | ||
836 | pll->link_freq = sensor->platform_data->op_sys_clock[j]; | ||
837 | |||
838 | rval = smiapp_pll_try(sensor, pll); | ||
839 | dev_dbg(&client->dev, "link freq %u Hz, bpp %u %s\n", | ||
840 | pll->link_freq, pll->bits_per_pixel, | ||
841 | rval ? "not ok" : "ok"); | ||
842 | if (rval) | ||
843 | continue; | ||
844 | |||
845 | set_bit(j, valid_link_freqs); | ||
846 | } | ||
847 | |||
848 | if (!*valid_link_freqs) { | ||
849 | dev_info(&client->dev, | ||
850 | "no valid link frequencies for %u bpp\n", | ||
851 | f->compressed); | ||
852 | sensor->default_mbus_frame_fmts &= ~BIT(i); | ||
853 | continue; | ||
854 | } | ||
855 | |||
856 | if (!sensor->csi_format | ||
857 | || f->width > sensor->csi_format->width | ||
858 | || (f->width == sensor->csi_format->width | ||
859 | && f->compressed > sensor->csi_format->compressed)) { | ||
860 | sensor->csi_format = f; | ||
861 | sensor->internal_csi_format = f; | ||
819 | } | 862 | } |
820 | } | 863 | } |
821 | 864 | ||
@@ -904,7 +947,7 @@ static int smiapp_update_mode(struct smiapp_sensor *sensor) | |||
904 | dev_dbg(&client->dev, "hblank\t\t%d\n", sensor->hblank->val); | 947 | dev_dbg(&client->dev, "hblank\t\t%d\n", sensor->hblank->val); |
905 | 948 | ||
906 | dev_dbg(&client->dev, "real timeperframe\t100/%d\n", | 949 | dev_dbg(&client->dev, "real timeperframe\t100/%d\n", |
907 | sensor->pll.vt_pix_clk_freq_hz / | 950 | sensor->pll.pixel_rate_pixel_array / |
908 | ((sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].width | 951 | ((sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].width |
909 | + sensor->hblank->val) * | 952 | + sensor->hblank->val) * |
910 | (sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].height | 953 | (sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].height |
@@ -1687,51 +1730,77 @@ static const struct smiapp_csi_data_format | |||
1687 | return csi_format; | 1730 | return csi_format; |
1688 | } | 1731 | } |
1689 | 1732 | ||
1690 | static int smiapp_set_format(struct v4l2_subdev *subdev, | 1733 | static int smiapp_set_format_source(struct v4l2_subdev *subdev, |
1691 | struct v4l2_subdev_fh *fh, | 1734 | struct v4l2_subdev_fh *fh, |
1692 | struct v4l2_subdev_format *fmt) | 1735 | struct v4l2_subdev_format *fmt) |
1693 | { | 1736 | { |
1694 | struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); | 1737 | struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); |
1695 | struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); | 1738 | const struct smiapp_csi_data_format *csi_format, |
1696 | struct v4l2_rect *crops[SMIAPP_PADS]; | 1739 | *old_csi_format = sensor->csi_format; |
1740 | unsigned long *valid_link_freqs; | ||
1741 | u32 code = fmt->format.code; | ||
1742 | unsigned int i; | ||
1743 | int rval; | ||
1697 | 1744 | ||
1698 | mutex_lock(&sensor->mutex); | 1745 | rval = __smiapp_get_format(subdev, fh, fmt); |
1746 | if (rval) | ||
1747 | return rval; | ||
1699 | 1748 | ||
1700 | /* | 1749 | /* |
1701 | * Media bus code is changeable on src subdev's source pad. On | 1750 | * Media bus code is changeable on src subdev's source pad. On |
1702 | * other source pads we just get format here. | 1751 | * other source pads we just get format here. |
1703 | */ | 1752 | */ |
1704 | if (fmt->pad == ssd->source_pad) { | 1753 | if (subdev != &sensor->src->sd) |
1705 | u32 code = fmt->format.code; | 1754 | return 0; |
1706 | int rval = __smiapp_get_format(subdev, fh, fmt); | ||
1707 | bool range_changed = false; | ||
1708 | unsigned int i; | ||
1709 | 1755 | ||
1710 | if (!rval && subdev == &sensor->src->sd) { | 1756 | csi_format = smiapp_validate_csi_data_format(sensor, code); |
1711 | const struct smiapp_csi_data_format *csi_format = | ||
1712 | smiapp_validate_csi_data_format(sensor, code); | ||
1713 | 1757 | ||
1714 | if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { | 1758 | fmt->format.code = csi_format->code; |
1715 | if (csi_format->width != | ||
1716 | sensor->csi_format->width) | ||
1717 | range_changed = true; | ||
1718 | 1759 | ||
1719 | sensor->csi_format = csi_format; | 1760 | if (fmt->which != V4L2_SUBDEV_FORMAT_ACTIVE) |
1720 | } | 1761 | return 0; |
1721 | |||
1722 | fmt->format.code = csi_format->code; | ||
1723 | } | ||
1724 | 1762 | ||
1725 | mutex_unlock(&sensor->mutex); | 1763 | sensor->csi_format = csi_format; |
1726 | if (rval || !range_changed) | ||
1727 | return rval; | ||
1728 | 1764 | ||
1765 | if (csi_format->width != old_csi_format->width) | ||
1729 | for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) | 1766 | for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) |
1730 | v4l2_ctrl_modify_range( | 1767 | __v4l2_ctrl_modify_range( |
1731 | sensor->test_data[i], | 1768 | sensor->test_data[i], 0, |
1732 | 0, (1 << sensor->csi_format->width) - 1, 1, 0); | 1769 | (1 << csi_format->width) - 1, 1, 0); |
1733 | 1770 | ||
1771 | if (csi_format->compressed == old_csi_format->compressed) | ||
1734 | return 0; | 1772 | return 0; |
1773 | |||
1774 | valid_link_freqs = | ||
1775 | &sensor->valid_link_freqs[sensor->csi_format->compressed | ||
1776 | - SMIAPP_COMPRESSED_BASE]; | ||
1777 | |||
1778 | __v4l2_ctrl_modify_range( | ||
1779 | sensor->link_freq, 0, | ||
1780 | __fls(*valid_link_freqs), ~*valid_link_freqs, | ||
1781 | __ffs(*valid_link_freqs)); | ||
1782 | |||
1783 | return smiapp_pll_update(sensor); | ||
1784 | } | ||
1785 | |||
1786 | static int smiapp_set_format(struct v4l2_subdev *subdev, | ||
1787 | struct v4l2_subdev_fh *fh, | ||
1788 | struct v4l2_subdev_format *fmt) | ||
1789 | { | ||
1790 | struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); | ||
1791 | struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); | ||
1792 | struct v4l2_rect *crops[SMIAPP_PADS]; | ||
1793 | |||
1794 | mutex_lock(&sensor->mutex); | ||
1795 | |||
1796 | if (fmt->pad == ssd->source_pad) { | ||
1797 | int rval; | ||
1798 | |||
1799 | rval = smiapp_set_format_source(subdev, fh, fmt); | ||
1800 | |||
1801 | mutex_unlock(&sensor->mutex); | ||
1802 | |||
1803 | return rval; | ||
1735 | } | 1804 | } |
1736 | 1805 | ||
1737 | /* Sink pad. Width and height are changeable here. */ | 1806 | /* Sink pad. Width and height are changeable here. */ |
@@ -2023,6 +2092,11 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev, | |||
2023 | == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) | 2092 | == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) |
2024 | return 0; | 2093 | return 0; |
2025 | return -EINVAL; | 2094 | return -EINVAL; |
2095 | case V4L2_SEL_TGT_NATIVE_SIZE: | ||
2096 | if (ssd == sensor->pixel_array | ||
2097 | && sel->pad == SMIAPP_PA_PAD_SRC) | ||
2098 | return 0; | ||
2099 | return -EINVAL; | ||
2026 | case V4L2_SEL_TGT_COMPOSE: | 2100 | case V4L2_SEL_TGT_COMPOSE: |
2027 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: | 2101 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: |
2028 | if (sel->pad == ssd->source_pad) | 2102 | if (sel->pad == ssd->source_pad) |
@@ -2121,7 +2195,9 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev, | |||
2121 | 2195 | ||
2122 | switch (sel->target) { | 2196 | switch (sel->target) { |
2123 | case V4L2_SEL_TGT_CROP_BOUNDS: | 2197 | case V4L2_SEL_TGT_CROP_BOUNDS: |
2198 | case V4L2_SEL_TGT_NATIVE_SIZE: | ||
2124 | if (ssd == sensor->pixel_array) { | 2199 | if (ssd == sensor->pixel_array) { |
2200 | sel->r.left = sel->r.top = 0; | ||
2125 | sel->r.width = | 2201 | sel->r.width = |
2126 | sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; | 2202 | sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; |
2127 | sel->r.height = | 2203 | sel->r.height = |
@@ -2482,12 +2558,6 @@ static int smiapp_registered(struct v4l2_subdev *subdev) | |||
2482 | goto out_power_off; | 2558 | goto out_power_off; |
2483 | } | 2559 | } |
2484 | 2560 | ||
2485 | rval = smiapp_get_mbus_formats(sensor); | ||
2486 | if (rval) { | ||
2487 | rval = -ENODEV; | ||
2488 | goto out_power_off; | ||
2489 | } | ||
2490 | |||
2491 | if (sensor->limits[SMIAPP_LIMIT_BINNING_CAPABILITY]) { | 2561 | if (sensor->limits[SMIAPP_LIMIT_BINNING_CAPABILITY]) { |
2492 | u32 val; | 2562 | u32 val; |
2493 | 2563 | ||
@@ -2569,6 +2639,22 @@ static int smiapp_registered(struct v4l2_subdev *subdev) | |||
2569 | 2639 | ||
2570 | sensor->scale_m = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; | 2640 | sensor->scale_m = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; |
2571 | 2641 | ||
2642 | /* prepare PLL configuration input values */ | ||
2643 | pll->bus_type = SMIAPP_PLL_BUS_TYPE_CSI2; | ||
2644 | pll->csi2.lanes = sensor->platform_data->lanes; | ||
2645 | pll->ext_clk_freq_hz = sensor->platform_data->ext_clk; | ||
2646 | pll->flags = smiapp_call_quirk(sensor, pll_flags); | ||
2647 | pll->scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; | ||
2648 | /* Profile 0 sensors have no separate OP clock branch. */ | ||
2649 | if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) | ||
2650 | pll->flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS; | ||
2651 | |||
2652 | rval = smiapp_get_mbus_formats(sensor); | ||
2653 | if (rval) { | ||
2654 | rval = -ENODEV; | ||
2655 | goto out_nvm_release; | ||
2656 | } | ||
2657 | |||
2572 | for (i = 0; i < SMIAPP_SUBDEVS; i++) { | 2658 | for (i = 0; i < SMIAPP_SUBDEVS; i++) { |
2573 | struct { | 2659 | struct { |
2574 | struct smiapp_subdev *ssd; | 2660 | struct smiapp_subdev *ssd; |
@@ -2666,18 +2752,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev) | |||
2666 | if (rval < 0) | 2752 | if (rval < 0) |
2667 | goto out_nvm_release; | 2753 | goto out_nvm_release; |
2668 | 2754 | ||
2669 | /* prepare PLL configuration input values */ | 2755 | mutex_lock(&sensor->mutex); |
2670 | pll->bus_type = SMIAPP_PLL_BUS_TYPE_CSI2; | ||
2671 | pll->csi2.lanes = sensor->platform_data->lanes; | ||
2672 | pll->ext_clk_freq_hz = sensor->platform_data->ext_clk; | ||
2673 | pll->flags = smiapp_call_quirk(sensor, pll_flags); | ||
2674 | |||
2675 | /* Profile 0 sensors have no separate OP clock branch. */ | ||
2676 | if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) | ||
2677 | pll->flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS; | ||
2678 | pll->scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; | ||
2679 | |||
2680 | rval = smiapp_update_mode(sensor); | 2756 | rval = smiapp_update_mode(sensor); |
2757 | mutex_unlock(&sensor->mutex); | ||
2681 | if (rval) { | 2758 | if (rval) { |
2682 | dev_err(&client->dev, "update mode failed\n"); | 2759 | dev_err(&client->dev, "update mode failed\n"); |
2683 | goto out_nvm_release; | 2760 | goto out_nvm_release; |
diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h index 874b49ffd88f..f88f8ec344d3 100644 --- a/drivers/media/i2c/smiapp/smiapp.h +++ b/drivers/media/i2c/smiapp/smiapp.h | |||
@@ -156,6 +156,11 @@ struct smiapp_csi_data_format { | |||
156 | #define SMIAPP_PAD_SRC 1 | 156 | #define SMIAPP_PAD_SRC 1 |
157 | #define SMIAPP_PADS 2 | 157 | #define SMIAPP_PADS 2 |
158 | 158 | ||
159 | #define SMIAPP_COMPRESSED_BASE 8 | ||
160 | #define SMIAPP_COMPRESSED_MAX 12 | ||
161 | #define SMIAPP_NR_OF_COMPRESSED (SMIAPP_COMPRESSED_MAX - \ | ||
162 | SMIAPP_COMPRESSED_BASE + 1) | ||
163 | |||
159 | struct smiapp_binning_subtype { | 164 | struct smiapp_binning_subtype { |
160 | u8 horizontal:4; | 165 | u8 horizontal:4; |
161 | u8 vertical:4; | 166 | u8 vertical:4; |
@@ -232,6 +237,9 @@ struct smiapp_sensor { | |||
232 | 237 | ||
233 | struct smiapp_pll pll; | 238 | struct smiapp_pll pll; |
234 | 239 | ||
240 | /* Is a default format supported for a given BPP? */ | ||
241 | unsigned long valid_link_freqs[SMIAPP_NR_OF_COMPRESSED]; | ||
242 | |||
235 | /* Pixel array controls */ | 243 | /* Pixel array controls */ |
236 | struct v4l2_ctrl *analog_gain; | 244 | struct v4l2_ctrl *analog_gain; |
237 | struct v4l2_ctrl *exposure; | 245 | struct v4l2_ctrl *exposure; |
diff --git a/drivers/media/i2c/soc_camera/imx074.c b/drivers/media/i2c/soc_camera/imx074.c index 5b915936c3f3..ec89cfa927a2 100644 --- a/drivers/media/i2c/soc_camera/imx074.c +++ b/drivers/media/i2c/soc_camera/imx074.c | |||
@@ -71,7 +71,7 @@ | |||
71 | 71 | ||
72 | /* IMX074 has only one fixed colorspace per pixelcode */ | 72 | /* IMX074 has only one fixed colorspace per pixelcode */ |
73 | struct imx074_datafmt { | 73 | struct imx074_datafmt { |
74 | enum v4l2_mbus_pixelcode code; | 74 | u32 code; |
75 | enum v4l2_colorspace colorspace; | 75 | enum v4l2_colorspace colorspace; |
76 | }; | 76 | }; |
77 | 77 | ||
@@ -82,7 +82,7 @@ struct imx074 { | |||
82 | }; | 82 | }; |
83 | 83 | ||
84 | static const struct imx074_datafmt imx074_colour_fmts[] = { | 84 | static const struct imx074_datafmt imx074_colour_fmts[] = { |
85 | {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, | 85 | {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static struct imx074 *to_imx074(const struct i2c_client *client) | 88 | static struct imx074 *to_imx074(const struct i2c_client *client) |
@@ -91,7 +91,7 @@ static struct imx074 *to_imx074(const struct i2c_client *client) | |||
91 | } | 91 | } |
92 | 92 | ||
93 | /* Find a data format by a pixel code in an array */ | 93 | /* Find a data format by a pixel code in an array */ |
94 | static const struct imx074_datafmt *imx074_find_datafmt(enum v4l2_mbus_pixelcode code) | 94 | static const struct imx074_datafmt *imx074_find_datafmt(u32 code) |
95 | { | 95 | { |
96 | int i; | 96 | int i; |
97 | 97 | ||
@@ -236,7 +236,7 @@ static int imx074_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) | |||
236 | } | 236 | } |
237 | 237 | ||
238 | static int imx074_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 238 | static int imx074_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
239 | enum v4l2_mbus_pixelcode *code) | 239 | u32 *code) |
240 | { | 240 | { |
241 | if ((unsigned int)index >= ARRAY_SIZE(imx074_colour_fmts)) | 241 | if ((unsigned int)index >= ARRAY_SIZE(imx074_colour_fmts)) |
242 | return -EINVAL; | 242 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c index dbd8c142d6ef..2e9a53502551 100644 --- a/drivers/media/i2c/soc_camera/mt9m001.c +++ b/drivers/media/i2c/soc_camera/mt9m001.c | |||
@@ -53,13 +53,13 @@ | |||
53 | 53 | ||
54 | /* MT9M001 has only one fixed colorspace per pixelcode */ | 54 | /* MT9M001 has only one fixed colorspace per pixelcode */ |
55 | struct mt9m001_datafmt { | 55 | struct mt9m001_datafmt { |
56 | enum v4l2_mbus_pixelcode code; | 56 | u32 code; |
57 | enum v4l2_colorspace colorspace; | 57 | enum v4l2_colorspace colorspace; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* Find a data format by a pixel code in an array */ | 60 | /* Find a data format by a pixel code in an array */ |
61 | static const struct mt9m001_datafmt *mt9m001_find_datafmt( | 61 | static const struct mt9m001_datafmt *mt9m001_find_datafmt( |
62 | enum v4l2_mbus_pixelcode code, const struct mt9m001_datafmt *fmt, | 62 | u32 code, const struct mt9m001_datafmt *fmt, |
63 | int n) | 63 | int n) |
64 | { | 64 | { |
65 | int i; | 65 | int i; |
@@ -75,14 +75,14 @@ static const struct mt9m001_datafmt mt9m001_colour_fmts[] = { | |||
75 | * Order important: first natively supported, | 75 | * Order important: first natively supported, |
76 | * second supported with a GPIO extender | 76 | * second supported with a GPIO extender |
77 | */ | 77 | */ |
78 | {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, | 78 | {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, |
79 | {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, | 79 | {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static const struct mt9m001_datafmt mt9m001_monochrome_fmts[] = { | 82 | static const struct mt9m001_datafmt mt9m001_monochrome_fmts[] = { |
83 | /* Order important - see above */ | 83 | /* Order important - see above */ |
84 | {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG}, | 84 | {MEDIA_BUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG}, |
85 | {V4L2_MBUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG}, | 85 | {MEDIA_BUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG}, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | struct mt9m001 { | 88 | struct mt9m001 { |
@@ -563,7 +563,7 @@ static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = { | |||
563 | }; | 563 | }; |
564 | 564 | ||
565 | static int mt9m001_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 565 | static int mt9m001_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
566 | enum v4l2_mbus_pixelcode *code) | 566 | u32 *code) |
567 | { | 567 | { |
568 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 568 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
569 | struct mt9m001 *mt9m001 = to_mt9m001(client); | 569 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index b51e8562e775..5992ea93257a 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c | |||
@@ -182,23 +182,23 @@ static struct mt9m111_context context_b = { | |||
182 | 182 | ||
183 | /* MT9M111 has only one fixed colorspace per pixelcode */ | 183 | /* MT9M111 has only one fixed colorspace per pixelcode */ |
184 | struct mt9m111_datafmt { | 184 | struct mt9m111_datafmt { |
185 | enum v4l2_mbus_pixelcode code; | 185 | u32 code; |
186 | enum v4l2_colorspace colorspace; | 186 | enum v4l2_colorspace colorspace; |
187 | }; | 187 | }; |
188 | 188 | ||
189 | static const struct mt9m111_datafmt mt9m111_colour_fmts[] = { | 189 | static const struct mt9m111_datafmt mt9m111_colour_fmts[] = { |
190 | {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}, | 190 | {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}, |
191 | {V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG}, | 191 | {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG}, |
192 | {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}, | 192 | {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}, |
193 | {V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG}, | 193 | {MEDIA_BUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG}, |
194 | {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, | 194 | {MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, |
195 | {V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, | 195 | {MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, |
196 | {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, | 196 | {MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, |
197 | {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, | 197 | {MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, |
198 | {V4L2_MBUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB}, | 198 | {MEDIA_BUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB}, |
199 | {V4L2_MBUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB}, | 199 | {MEDIA_BUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB}, |
200 | {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, | 200 | {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, |
201 | {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, | 201 | {MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, |
202 | }; | 202 | }; |
203 | 203 | ||
204 | struct mt9m111 { | 204 | struct mt9m111 { |
@@ -218,7 +218,7 @@ struct mt9m111 { | |||
218 | 218 | ||
219 | /* Find a data format by a pixel code */ | 219 | /* Find a data format by a pixel code */ |
220 | static const struct mt9m111_datafmt *mt9m111_find_datafmt(struct mt9m111 *mt9m111, | 220 | static const struct mt9m111_datafmt *mt9m111_find_datafmt(struct mt9m111 *mt9m111, |
221 | enum v4l2_mbus_pixelcode code) | 221 | u32 code) |
222 | { | 222 | { |
223 | int i; | 223 | int i; |
224 | for (i = 0; i < ARRAY_SIZE(mt9m111_colour_fmts); i++) | 224 | for (i = 0; i < ARRAY_SIZE(mt9m111_colour_fmts); i++) |
@@ -331,7 +331,7 @@ static int mt9m111_setup_rect_ctx(struct mt9m111 *mt9m111, | |||
331 | } | 331 | } |
332 | 332 | ||
333 | static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rect, | 333 | static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rect, |
334 | int width, int height, enum v4l2_mbus_pixelcode code) | 334 | int width, int height, u32 code) |
335 | { | 335 | { |
336 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); | 336 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); |
337 | int ret; | 337 | int ret; |
@@ -345,7 +345,7 @@ static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rec | |||
345 | if (!ret) | 345 | if (!ret) |
346 | ret = reg_write(WINDOW_HEIGHT, rect->height); | 346 | ret = reg_write(WINDOW_HEIGHT, rect->height); |
347 | 347 | ||
348 | if (code != V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) { | 348 | if (code != MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) { |
349 | /* IFP in use, down-scaling possible */ | 349 | /* IFP in use, down-scaling possible */ |
350 | if (!ret) | 350 | if (!ret) |
351 | ret = mt9m111_setup_rect_ctx(mt9m111, &context_b, | 351 | ret = mt9m111_setup_rect_ctx(mt9m111, &context_b, |
@@ -393,8 +393,8 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a) | |||
393 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 393 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
394 | return -EINVAL; | 394 | return -EINVAL; |
395 | 395 | ||
396 | if (mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 || | 396 | if (mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 || |
397 | mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) { | 397 | mt9m111->fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) { |
398 | /* Bayer format - even size lengths */ | 398 | /* Bayer format - even size lengths */ |
399 | rect.width = ALIGN(rect.width, 2); | 399 | rect.width = ALIGN(rect.width, 2); |
400 | rect.height = ALIGN(rect.height, 2); | 400 | rect.height = ALIGN(rect.height, 2); |
@@ -462,7 +462,7 @@ static int mt9m111_g_fmt(struct v4l2_subdev *sd, | |||
462 | } | 462 | } |
463 | 463 | ||
464 | static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111, | 464 | static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111, |
465 | enum v4l2_mbus_pixelcode code) | 465 | u32 code) |
466 | { | 466 | { |
467 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); | 467 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); |
468 | u16 data_outfmt2, mask_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER | | 468 | u16 data_outfmt2, mask_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER | |
@@ -474,46 +474,46 @@ static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111, | |||
474 | int ret; | 474 | int ret; |
475 | 475 | ||
476 | switch (code) { | 476 | switch (code) { |
477 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 477 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
478 | data_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER | | 478 | data_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER | |
479 | MT9M111_OUTFMT_RGB; | 479 | MT9M111_OUTFMT_RGB; |
480 | break; | 480 | break; |
481 | case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE: | 481 | case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE: |
482 | data_outfmt2 = MT9M111_OUTFMT_BYPASS_IFP | MT9M111_OUTFMT_RGB; | 482 | data_outfmt2 = MT9M111_OUTFMT_BYPASS_IFP | MT9M111_OUTFMT_RGB; |
483 | break; | 483 | break; |
484 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: | 484 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE: |
485 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555 | | 485 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555 | |
486 | MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN; | 486 | MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN; |
487 | break; | 487 | break; |
488 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE: | 488 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE: |
489 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555; | 489 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555; |
490 | break; | 490 | break; |
491 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 491 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
492 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 | | 492 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 | |
493 | MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN; | 493 | MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN; |
494 | break; | 494 | break; |
495 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 495 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
496 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565; | 496 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565; |
497 | break; | 497 | break; |
498 | case V4L2_MBUS_FMT_BGR565_2X8_BE: | 498 | case MEDIA_BUS_FMT_BGR565_2X8_BE: |
499 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 | | 499 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 | |
500 | MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; | 500 | MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; |
501 | break; | 501 | break; |
502 | case V4L2_MBUS_FMT_BGR565_2X8_LE: | 502 | case MEDIA_BUS_FMT_BGR565_2X8_LE: |
503 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 | | 503 | data_outfmt2 = MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565 | |
504 | MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN | | 504 | MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN | |
505 | MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; | 505 | MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; |
506 | break; | 506 | break; |
507 | case V4L2_MBUS_FMT_UYVY8_2X8: | 507 | case MEDIA_BUS_FMT_UYVY8_2X8: |
508 | data_outfmt2 = 0; | 508 | data_outfmt2 = 0; |
509 | break; | 509 | break; |
510 | case V4L2_MBUS_FMT_VYUY8_2X8: | 510 | case MEDIA_BUS_FMT_VYUY8_2X8: |
511 | data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; | 511 | data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; |
512 | break; | 512 | break; |
513 | case V4L2_MBUS_FMT_YUYV8_2X8: | 513 | case MEDIA_BUS_FMT_YUYV8_2X8: |
514 | data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN; | 514 | data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN; |
515 | break; | 515 | break; |
516 | case V4L2_MBUS_FMT_YVYU8_2X8: | 516 | case MEDIA_BUS_FMT_YVYU8_2X8: |
517 | data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN | | 517 | data_outfmt2 = MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN | |
518 | MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; | 518 | MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B; |
519 | break; | 519 | break; |
@@ -542,8 +542,8 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd, | |||
542 | 542 | ||
543 | fmt = mt9m111_find_datafmt(mt9m111, mf->code); | 543 | fmt = mt9m111_find_datafmt(mt9m111, mf->code); |
544 | 544 | ||
545 | bayer = fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 || | 545 | bayer = fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8 || |
546 | fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE; | 546 | fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE; |
547 | 547 | ||
548 | /* | 548 | /* |
549 | * With Bayer format enforce even side lengths, but let the user play | 549 | * With Bayer format enforce even side lengths, but let the user play |
@@ -554,7 +554,7 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd, | |||
554 | rect->height = ALIGN(rect->height, 2); | 554 | rect->height = ALIGN(rect->height, 2); |
555 | } | 555 | } |
556 | 556 | ||
557 | if (fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) { | 557 | if (fmt->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) { |
558 | /* IFP bypass mode, no scaling */ | 558 | /* IFP bypass mode, no scaling */ |
559 | mf->width = rect->width; | 559 | mf->width = rect->width; |
560 | mf->height = rect->height; | 560 | mf->height = rect->height; |
@@ -840,7 +840,7 @@ static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = { | |||
840 | }; | 840 | }; |
841 | 841 | ||
842 | static int mt9m111_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 842 | static int mt9m111_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
843 | enum v4l2_mbus_pixelcode *code) | 843 | u32 *code) |
844 | { | 844 | { |
845 | if (index >= ARRAY_SIZE(mt9m111_colour_fmts)) | 845 | if (index >= ARRAY_SIZE(mt9m111_colour_fmts)) |
846 | return -EINVAL; | 846 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index f8358c4071a9..35d9c8d25589 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c | |||
@@ -345,7 +345,7 @@ static int mt9t031_g_fmt(struct v4l2_subdev *sd, | |||
345 | 345 | ||
346 | mf->width = mt9t031->rect.width / mt9t031->xskip; | 346 | mf->width = mt9t031->rect.width / mt9t031->xskip; |
347 | mf->height = mt9t031->rect.height / mt9t031->yskip; | 347 | mf->height = mt9t031->rect.height / mt9t031->yskip; |
348 | mf->code = V4L2_MBUS_FMT_SBGGR10_1X10; | 348 | mf->code = MEDIA_BUS_FMT_SBGGR10_1X10; |
349 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 349 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
350 | mf->field = V4L2_FIELD_NONE; | 350 | mf->field = V4L2_FIELD_NONE; |
351 | 351 | ||
@@ -367,7 +367,7 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd, | |||
367 | xskip = mt9t031_skip(&rect.width, mf->width, MT9T031_MAX_WIDTH); | 367 | xskip = mt9t031_skip(&rect.width, mf->width, MT9T031_MAX_WIDTH); |
368 | yskip = mt9t031_skip(&rect.height, mf->height, MT9T031_MAX_HEIGHT); | 368 | yskip = mt9t031_skip(&rect.height, mf->height, MT9T031_MAX_HEIGHT); |
369 | 369 | ||
370 | mf->code = V4L2_MBUS_FMT_SBGGR10_1X10; | 370 | mf->code = MEDIA_BUS_FMT_SBGGR10_1X10; |
371 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 371 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
372 | 372 | ||
373 | /* mt9t031_set_params() doesn't change width and height */ | 373 | /* mt9t031_set_params() doesn't change width and height */ |
@@ -385,7 +385,7 @@ static int mt9t031_try_fmt(struct v4l2_subdev *sd, | |||
385 | &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, | 385 | &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, |
386 | &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); | 386 | &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); |
387 | 387 | ||
388 | mf->code = V4L2_MBUS_FMT_SBGGR10_1X10; | 388 | mf->code = MEDIA_BUS_FMT_SBGGR10_1X10; |
389 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 389 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
390 | 390 | ||
391 | return 0; | 391 | return 0; |
@@ -673,12 +673,12 @@ static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = { | |||
673 | }; | 673 | }; |
674 | 674 | ||
675 | static int mt9t031_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 675 | static int mt9t031_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
676 | enum v4l2_mbus_pixelcode *code) | 676 | u32 *code) |
677 | { | 677 | { |
678 | if (index) | 678 | if (index) |
679 | return -EINVAL; | 679 | return -EINVAL; |
680 | 680 | ||
681 | *code = V4L2_MBUS_FMT_SBGGR10_1X10; | 681 | *code = MEDIA_BUS_FMT_SBGGR10_1X10; |
682 | return 0; | 682 | return 0; |
683 | } | 683 | } |
684 | 684 | ||
diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c index 996d7b4007a5..64f08365e6b2 100644 --- a/drivers/media/i2c/soc_camera/mt9t112.c +++ b/drivers/media/i2c/soc_camera/mt9t112.c | |||
@@ -77,7 +77,7 @@ | |||
77 | struct | 77 | struct |
78 | ************************************************************************/ | 78 | ************************************************************************/ |
79 | struct mt9t112_format { | 79 | struct mt9t112_format { |
80 | enum v4l2_mbus_pixelcode code; | 80 | u32 code; |
81 | enum v4l2_colorspace colorspace; | 81 | enum v4l2_colorspace colorspace; |
82 | u16 fmt; | 82 | u16 fmt; |
83 | u16 order; | 83 | u16 order; |
@@ -103,32 +103,32 @@ struct mt9t112_priv { | |||
103 | 103 | ||
104 | static const struct mt9t112_format mt9t112_cfmts[] = { | 104 | static const struct mt9t112_format mt9t112_cfmts[] = { |
105 | { | 105 | { |
106 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 106 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
107 | .colorspace = V4L2_COLORSPACE_JPEG, | 107 | .colorspace = V4L2_COLORSPACE_JPEG, |
108 | .fmt = 1, | 108 | .fmt = 1, |
109 | .order = 0, | 109 | .order = 0, |
110 | }, { | 110 | }, { |
111 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 111 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
112 | .colorspace = V4L2_COLORSPACE_JPEG, | 112 | .colorspace = V4L2_COLORSPACE_JPEG, |
113 | .fmt = 1, | 113 | .fmt = 1, |
114 | .order = 1, | 114 | .order = 1, |
115 | }, { | 115 | }, { |
116 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 116 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
117 | .colorspace = V4L2_COLORSPACE_JPEG, | 117 | .colorspace = V4L2_COLORSPACE_JPEG, |
118 | .fmt = 1, | 118 | .fmt = 1, |
119 | .order = 2, | 119 | .order = 2, |
120 | }, { | 120 | }, { |
121 | .code = V4L2_MBUS_FMT_YVYU8_2X8, | 121 | .code = MEDIA_BUS_FMT_YVYU8_2X8, |
122 | .colorspace = V4L2_COLORSPACE_JPEG, | 122 | .colorspace = V4L2_COLORSPACE_JPEG, |
123 | .fmt = 1, | 123 | .fmt = 1, |
124 | .order = 3, | 124 | .order = 3, |
125 | }, { | 125 | }, { |
126 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, | 126 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, |
127 | .colorspace = V4L2_COLORSPACE_SRGB, | 127 | .colorspace = V4L2_COLORSPACE_SRGB, |
128 | .fmt = 8, | 128 | .fmt = 8, |
129 | .order = 2, | 129 | .order = 2, |
130 | }, { | 130 | }, { |
131 | .code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 131 | .code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
132 | .colorspace = V4L2_COLORSPACE_SRGB, | 132 | .colorspace = V4L2_COLORSPACE_SRGB, |
133 | .fmt = 4, | 133 | .fmt = 4, |
134 | .order = 2, | 134 | .order = 2, |
@@ -840,7 +840,7 @@ static int mt9t112_s_stream(struct v4l2_subdev *sd, int enable) | |||
840 | 840 | ||
841 | static int mt9t112_set_params(struct mt9t112_priv *priv, | 841 | static int mt9t112_set_params(struct mt9t112_priv *priv, |
842 | const struct v4l2_rect *rect, | 842 | const struct v4l2_rect *rect, |
843 | enum v4l2_mbus_pixelcode code) | 843 | u32 code) |
844 | { | 844 | { |
845 | int i; | 845 | int i; |
846 | 846 | ||
@@ -953,7 +953,7 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd, | |||
953 | break; | 953 | break; |
954 | 954 | ||
955 | if (i == priv->num_formats) { | 955 | if (i == priv->num_formats) { |
956 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 956 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
957 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 957 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
958 | } else { | 958 | } else { |
959 | mf->colorspace = mt9t112_cfmts[i].colorspace; | 959 | mf->colorspace = mt9t112_cfmts[i].colorspace; |
@@ -967,7 +967,7 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd, | |||
967 | } | 967 | } |
968 | 968 | ||
969 | static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 969 | static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
970 | enum v4l2_mbus_pixelcode *code) | 970 | u32 *code) |
971 | { | 971 | { |
972 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 972 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
973 | struct mt9t112_priv *priv = to_mt9t112(client); | 973 | struct mt9t112_priv *priv = to_mt9t112(client); |
@@ -1101,7 +1101,7 @@ static int mt9t112_probe(struct i2c_client *client, | |||
1101 | 1101 | ||
1102 | /* Cannot fail: using the default supported pixel code */ | 1102 | /* Cannot fail: using the default supported pixel code */ |
1103 | if (!ret) | 1103 | if (!ret) |
1104 | mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8); | 1104 | mt9t112_set_params(priv, &rect, MEDIA_BUS_FMT_UYVY8_2X8); |
1105 | else | 1105 | else |
1106 | v4l2_clk_put(priv->clk); | 1106 | v4l2_clk_put(priv->clk); |
1107 | 1107 | ||
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c index 99022c8d76eb..a246d4d64b8b 100644 --- a/drivers/media/i2c/soc_camera/mt9v022.c +++ b/drivers/media/i2c/soc_camera/mt9v022.c | |||
@@ -85,13 +85,13 @@ MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\""); | |||
85 | 85 | ||
86 | /* MT9V022 has only one fixed colorspace per pixelcode */ | 86 | /* MT9V022 has only one fixed colorspace per pixelcode */ |
87 | struct mt9v022_datafmt { | 87 | struct mt9v022_datafmt { |
88 | enum v4l2_mbus_pixelcode code; | 88 | u32 code; |
89 | enum v4l2_colorspace colorspace; | 89 | enum v4l2_colorspace colorspace; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | /* Find a data format by a pixel code in an array */ | 92 | /* Find a data format by a pixel code in an array */ |
93 | static const struct mt9v022_datafmt *mt9v022_find_datafmt( | 93 | static const struct mt9v022_datafmt *mt9v022_find_datafmt( |
94 | enum v4l2_mbus_pixelcode code, const struct mt9v022_datafmt *fmt, | 94 | u32 code, const struct mt9v022_datafmt *fmt, |
95 | int n) | 95 | int n) |
96 | { | 96 | { |
97 | int i; | 97 | int i; |
@@ -107,14 +107,14 @@ static const struct mt9v022_datafmt mt9v022_colour_fmts[] = { | |||
107 | * Order important: first natively supported, | 107 | * Order important: first natively supported, |
108 | * second supported with a GPIO extender | 108 | * second supported with a GPIO extender |
109 | */ | 109 | */ |
110 | {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, | 110 | {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, |
111 | {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, | 111 | {MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static const struct mt9v022_datafmt mt9v022_monochrome_fmts[] = { | 114 | static const struct mt9v022_datafmt mt9v022_monochrome_fmts[] = { |
115 | /* Order important - see above */ | 115 | /* Order important - see above */ |
116 | {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG}, | 116 | {MEDIA_BUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG}, |
117 | {V4L2_MBUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG}, | 117 | {MEDIA_BUS_FMT_Y8_1X8, V4L2_COLORSPACE_JPEG}, |
118 | }; | 118 | }; |
119 | 119 | ||
120 | /* only registers with different addresses on different mt9v02x sensors */ | 120 | /* only registers with different addresses on different mt9v02x sensors */ |
@@ -410,13 +410,13 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, | |||
410 | * .try_mbus_fmt(), datawidth is from our supported format list | 410 | * .try_mbus_fmt(), datawidth is from our supported format list |
411 | */ | 411 | */ |
412 | switch (mf->code) { | 412 | switch (mf->code) { |
413 | case V4L2_MBUS_FMT_Y8_1X8: | 413 | case MEDIA_BUS_FMT_Y8_1X8: |
414 | case V4L2_MBUS_FMT_Y10_1X10: | 414 | case MEDIA_BUS_FMT_Y10_1X10: |
415 | if (mt9v022->model != MT9V022IX7ATM) | 415 | if (mt9v022->model != MT9V022IX7ATM) |
416 | return -EINVAL; | 416 | return -EINVAL; |
417 | break; | 417 | break; |
418 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 418 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
419 | case V4L2_MBUS_FMT_SBGGR10_1X10: | 419 | case MEDIA_BUS_FMT_SBGGR10_1X10: |
420 | if (mt9v022->model != MT9V022IX7ATC) | 420 | if (mt9v022->model != MT9V022IX7ATC) |
421 | return -EINVAL; | 421 | return -EINVAL; |
422 | break; | 422 | break; |
@@ -443,8 +443,8 @@ static int mt9v022_try_fmt(struct v4l2_subdev *sd, | |||
443 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 443 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
444 | struct mt9v022 *mt9v022 = to_mt9v022(client); | 444 | struct mt9v022 *mt9v022 = to_mt9v022(client); |
445 | const struct mt9v022_datafmt *fmt; | 445 | const struct mt9v022_datafmt *fmt; |
446 | int align = mf->code == V4L2_MBUS_FMT_SBGGR8_1X8 || | 446 | int align = mf->code == MEDIA_BUS_FMT_SBGGR8_1X8 || |
447 | mf->code == V4L2_MBUS_FMT_SBGGR10_1X10; | 447 | mf->code == MEDIA_BUS_FMT_SBGGR10_1X10; |
448 | 448 | ||
449 | v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH, | 449 | v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH, |
450 | MT9V022_MAX_WIDTH, align, | 450 | MT9V022_MAX_WIDTH, align, |
@@ -759,7 +759,7 @@ static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = { | |||
759 | }; | 759 | }; |
760 | 760 | ||
761 | static int mt9v022_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 761 | static int mt9v022_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
762 | enum v4l2_mbus_pixelcode *code) | 762 | u32 *code) |
763 | { | 763 | { |
764 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 764 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
765 | struct mt9v022 *mt9v022 = to_mt9v022(client); | 765 | struct mt9v022 *mt9v022 = to_mt9v022(client); |
diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c index 6c6b1c3b45e3..6f2dd9093d94 100644 --- a/drivers/media/i2c/soc_camera/ov2640.c +++ b/drivers/media/i2c/soc_camera/ov2640.c | |||
@@ -302,7 +302,7 @@ struct ov2640_win_size { | |||
302 | struct ov2640_priv { | 302 | struct ov2640_priv { |
303 | struct v4l2_subdev subdev; | 303 | struct v4l2_subdev subdev; |
304 | struct v4l2_ctrl_handler hdl; | 304 | struct v4l2_ctrl_handler hdl; |
305 | enum v4l2_mbus_pixelcode cfmt_code; | 305 | u32 cfmt_code; |
306 | struct v4l2_clk *clk; | 306 | struct v4l2_clk *clk; |
307 | const struct ov2640_win_size *win; | 307 | const struct ov2640_win_size *win; |
308 | }; | 308 | }; |
@@ -623,11 +623,11 @@ static const struct regval_list ov2640_rgb565_le_regs[] = { | |||
623 | ENDMARKER, | 623 | ENDMARKER, |
624 | }; | 624 | }; |
625 | 625 | ||
626 | static enum v4l2_mbus_pixelcode ov2640_codes[] = { | 626 | static u32 ov2640_codes[] = { |
627 | V4L2_MBUS_FMT_YUYV8_2X8, | 627 | MEDIA_BUS_FMT_YUYV8_2X8, |
628 | V4L2_MBUS_FMT_UYVY8_2X8, | 628 | MEDIA_BUS_FMT_UYVY8_2X8, |
629 | V4L2_MBUS_FMT_RGB565_2X8_BE, | 629 | MEDIA_BUS_FMT_RGB565_2X8_BE, |
630 | V4L2_MBUS_FMT_RGB565_2X8_LE, | 630 | MEDIA_BUS_FMT_RGB565_2X8_LE, |
631 | }; | 631 | }; |
632 | 632 | ||
633 | /* | 633 | /* |
@@ -785,7 +785,7 @@ static const struct ov2640_win_size *ov2640_select_win(u32 *width, u32 *height) | |||
785 | } | 785 | } |
786 | 786 | ||
787 | static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height, | 787 | static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height, |
788 | enum v4l2_mbus_pixelcode code) | 788 | u32 code) |
789 | { | 789 | { |
790 | struct ov2640_priv *priv = to_ov2640(client); | 790 | struct ov2640_priv *priv = to_ov2640(client); |
791 | const struct regval_list *selected_cfmt_regs; | 791 | const struct regval_list *selected_cfmt_regs; |
@@ -797,20 +797,20 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height, | |||
797 | /* select format */ | 797 | /* select format */ |
798 | priv->cfmt_code = 0; | 798 | priv->cfmt_code = 0; |
799 | switch (code) { | 799 | switch (code) { |
800 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 800 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
801 | dev_dbg(&client->dev, "%s: Selected cfmt RGB565 BE", __func__); | 801 | dev_dbg(&client->dev, "%s: Selected cfmt RGB565 BE", __func__); |
802 | selected_cfmt_regs = ov2640_rgb565_be_regs; | 802 | selected_cfmt_regs = ov2640_rgb565_be_regs; |
803 | break; | 803 | break; |
804 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 804 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
805 | dev_dbg(&client->dev, "%s: Selected cfmt RGB565 LE", __func__); | 805 | dev_dbg(&client->dev, "%s: Selected cfmt RGB565 LE", __func__); |
806 | selected_cfmt_regs = ov2640_rgb565_le_regs; | 806 | selected_cfmt_regs = ov2640_rgb565_le_regs; |
807 | break; | 807 | break; |
808 | case V4L2_MBUS_FMT_YUYV8_2X8: | 808 | case MEDIA_BUS_FMT_YUYV8_2X8: |
809 | dev_dbg(&client->dev, "%s: Selected cfmt YUYV (YUV422)", __func__); | 809 | dev_dbg(&client->dev, "%s: Selected cfmt YUYV (YUV422)", __func__); |
810 | selected_cfmt_regs = ov2640_yuyv_regs; | 810 | selected_cfmt_regs = ov2640_yuyv_regs; |
811 | break; | 811 | break; |
812 | default: | 812 | default: |
813 | case V4L2_MBUS_FMT_UYVY8_2X8: | 813 | case MEDIA_BUS_FMT_UYVY8_2X8: |
814 | dev_dbg(&client->dev, "%s: Selected cfmt UYVY", __func__); | 814 | dev_dbg(&client->dev, "%s: Selected cfmt UYVY", __func__); |
815 | selected_cfmt_regs = ov2640_uyvy_regs; | 815 | selected_cfmt_regs = ov2640_uyvy_regs; |
816 | } | 816 | } |
@@ -869,7 +869,7 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd, | |||
869 | if (!priv->win) { | 869 | if (!priv->win) { |
870 | u32 width = W_SVGA, height = H_SVGA; | 870 | u32 width = W_SVGA, height = H_SVGA; |
871 | priv->win = ov2640_select_win(&width, &height); | 871 | priv->win = ov2640_select_win(&width, &height); |
872 | priv->cfmt_code = V4L2_MBUS_FMT_UYVY8_2X8; | 872 | priv->cfmt_code = MEDIA_BUS_FMT_UYVY8_2X8; |
873 | } | 873 | } |
874 | 874 | ||
875 | mf->width = priv->win->width; | 875 | mf->width = priv->win->width; |
@@ -877,13 +877,13 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd, | |||
877 | mf->code = priv->cfmt_code; | 877 | mf->code = priv->cfmt_code; |
878 | 878 | ||
879 | switch (mf->code) { | 879 | switch (mf->code) { |
880 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 880 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
881 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 881 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
882 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 882 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
883 | break; | 883 | break; |
884 | default: | 884 | default: |
885 | case V4L2_MBUS_FMT_YUYV8_2X8: | 885 | case MEDIA_BUS_FMT_YUYV8_2X8: |
886 | case V4L2_MBUS_FMT_UYVY8_2X8: | 886 | case MEDIA_BUS_FMT_UYVY8_2X8: |
887 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 887 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
888 | } | 888 | } |
889 | mf->field = V4L2_FIELD_NONE; | 889 | mf->field = V4L2_FIELD_NONE; |
@@ -899,14 +899,14 @@ static int ov2640_s_fmt(struct v4l2_subdev *sd, | |||
899 | 899 | ||
900 | 900 | ||
901 | switch (mf->code) { | 901 | switch (mf->code) { |
902 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 902 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
903 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 903 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
904 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 904 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
905 | break; | 905 | break; |
906 | default: | 906 | default: |
907 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 907 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
908 | case V4L2_MBUS_FMT_YUYV8_2X8: | 908 | case MEDIA_BUS_FMT_YUYV8_2X8: |
909 | case V4L2_MBUS_FMT_UYVY8_2X8: | 909 | case MEDIA_BUS_FMT_UYVY8_2X8: |
910 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 910 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
911 | } | 911 | } |
912 | 912 | ||
@@ -926,14 +926,14 @@ static int ov2640_try_fmt(struct v4l2_subdev *sd, | |||
926 | mf->field = V4L2_FIELD_NONE; | 926 | mf->field = V4L2_FIELD_NONE; |
927 | 927 | ||
928 | switch (mf->code) { | 928 | switch (mf->code) { |
929 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 929 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
930 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 930 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
931 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 931 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
932 | break; | 932 | break; |
933 | default: | 933 | default: |
934 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 934 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
935 | case V4L2_MBUS_FMT_YUYV8_2X8: | 935 | case MEDIA_BUS_FMT_YUYV8_2X8: |
936 | case V4L2_MBUS_FMT_UYVY8_2X8: | 936 | case MEDIA_BUS_FMT_UYVY8_2X8: |
937 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 937 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
938 | } | 938 | } |
939 | 939 | ||
@@ -941,7 +941,7 @@ static int ov2640_try_fmt(struct v4l2_subdev *sd, | |||
941 | } | 941 | } |
942 | 942 | ||
943 | static int ov2640_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 943 | static int ov2640_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
944 | enum v4l2_mbus_pixelcode *code) | 944 | u32 *code) |
945 | { | 945 | { |
946 | if (index >= ARRAY_SIZE(ov2640_codes)) | 946 | if (index >= ARRAY_SIZE(ov2640_codes)) |
947 | return -EINVAL; | 947 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c index d2daa6a8f272..93ae031bdafb 100644 --- a/drivers/media/i2c/soc_camera/ov5642.c +++ b/drivers/media/i2c/soc_camera/ov5642.c | |||
@@ -602,7 +602,7 @@ static struct regval_list ov5642_default_regs_finalise[] = { | |||
602 | }; | 602 | }; |
603 | 603 | ||
604 | struct ov5642_datafmt { | 604 | struct ov5642_datafmt { |
605 | enum v4l2_mbus_pixelcode code; | 605 | u32 code; |
606 | enum v4l2_colorspace colorspace; | 606 | enum v4l2_colorspace colorspace; |
607 | }; | 607 | }; |
608 | 608 | ||
@@ -618,7 +618,7 @@ struct ov5642 { | |||
618 | }; | 618 | }; |
619 | 619 | ||
620 | static const struct ov5642_datafmt ov5642_colour_fmts[] = { | 620 | static const struct ov5642_datafmt ov5642_colour_fmts[] = { |
621 | {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}, | 621 | {MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}, |
622 | }; | 622 | }; |
623 | 623 | ||
624 | static struct ov5642 *to_ov5642(const struct i2c_client *client) | 624 | static struct ov5642 *to_ov5642(const struct i2c_client *client) |
@@ -628,7 +628,7 @@ static struct ov5642 *to_ov5642(const struct i2c_client *client) | |||
628 | 628 | ||
629 | /* Find a data format by a pixel code in an array */ | 629 | /* Find a data format by a pixel code in an array */ |
630 | static const struct ov5642_datafmt | 630 | static const struct ov5642_datafmt |
631 | *ov5642_find_datafmt(enum v4l2_mbus_pixelcode code) | 631 | *ov5642_find_datafmt(u32 code) |
632 | { | 632 | { |
633 | int i; | 633 | int i; |
634 | 634 | ||
@@ -840,7 +840,7 @@ static int ov5642_g_fmt(struct v4l2_subdev *sd, | |||
840 | } | 840 | } |
841 | 841 | ||
842 | static int ov5642_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 842 | static int ov5642_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
843 | enum v4l2_mbus_pixelcode *code) | 843 | u32 *code) |
844 | { | 844 | { |
845 | if (index >= ARRAY_SIZE(ov5642_colour_fmts)) | 845 | if (index >= ARRAY_SIZE(ov5642_colour_fmts)) |
846 | return -EINVAL; | 846 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c index ab01598ec83f..f4eef2fa6f6f 100644 --- a/drivers/media/i2c/soc_camera/ov6650.c +++ b/drivers/media/i2c/soc_camera/ov6650.c | |||
@@ -202,18 +202,18 @@ struct ov6650 { | |||
202 | unsigned long pclk_limit; /* from host */ | 202 | unsigned long pclk_limit; /* from host */ |
203 | unsigned long pclk_max; /* from resolution and format */ | 203 | unsigned long pclk_max; /* from resolution and format */ |
204 | struct v4l2_fract tpf; /* as requested with s_parm */ | 204 | struct v4l2_fract tpf; /* as requested with s_parm */ |
205 | enum v4l2_mbus_pixelcode code; | 205 | u32 code; |
206 | enum v4l2_colorspace colorspace; | 206 | enum v4l2_colorspace colorspace; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | static enum v4l2_mbus_pixelcode ov6650_codes[] = { | 210 | static u32 ov6650_codes[] = { |
211 | V4L2_MBUS_FMT_YUYV8_2X8, | 211 | MEDIA_BUS_FMT_YUYV8_2X8, |
212 | V4L2_MBUS_FMT_UYVY8_2X8, | 212 | MEDIA_BUS_FMT_UYVY8_2X8, |
213 | V4L2_MBUS_FMT_YVYU8_2X8, | 213 | MEDIA_BUS_FMT_YVYU8_2X8, |
214 | V4L2_MBUS_FMT_VYUY8_2X8, | 214 | MEDIA_BUS_FMT_VYUY8_2X8, |
215 | V4L2_MBUS_FMT_SBGGR8_1X8, | 215 | MEDIA_BUS_FMT_SBGGR8_1X8, |
216 | V4L2_MBUS_FMT_Y8_1X8, | 216 | MEDIA_BUS_FMT_Y8_1X8, |
217 | }; | 217 | }; |
218 | 218 | ||
219 | /* read a register */ | 219 | /* read a register */ |
@@ -555,29 +555,29 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) | |||
555 | .height = mf->height << half_scale, | 555 | .height = mf->height << half_scale, |
556 | }, | 556 | }, |
557 | }; | 557 | }; |
558 | enum v4l2_mbus_pixelcode code = mf->code; | 558 | u32 code = mf->code; |
559 | unsigned long mclk, pclk; | 559 | unsigned long mclk, pclk; |
560 | u8 coma_set = 0, coma_mask = 0, coml_set, coml_mask, clkrc; | 560 | u8 coma_set = 0, coma_mask = 0, coml_set, coml_mask, clkrc; |
561 | int ret; | 561 | int ret; |
562 | 562 | ||
563 | /* select color matrix configuration for given color encoding */ | 563 | /* select color matrix configuration for given color encoding */ |
564 | switch (code) { | 564 | switch (code) { |
565 | case V4L2_MBUS_FMT_Y8_1X8: | 565 | case MEDIA_BUS_FMT_Y8_1X8: |
566 | dev_dbg(&client->dev, "pixel format GREY8_1X8\n"); | 566 | dev_dbg(&client->dev, "pixel format GREY8_1X8\n"); |
567 | coma_mask |= COMA_RGB | COMA_WORD_SWAP | COMA_BYTE_SWAP; | 567 | coma_mask |= COMA_RGB | COMA_WORD_SWAP | COMA_BYTE_SWAP; |
568 | coma_set |= COMA_BW; | 568 | coma_set |= COMA_BW; |
569 | break; | 569 | break; |
570 | case V4L2_MBUS_FMT_YUYV8_2X8: | 570 | case MEDIA_BUS_FMT_YUYV8_2X8: |
571 | dev_dbg(&client->dev, "pixel format YUYV8_2X8_LE\n"); | 571 | dev_dbg(&client->dev, "pixel format YUYV8_2X8_LE\n"); |
572 | coma_mask |= COMA_RGB | COMA_BW | COMA_BYTE_SWAP; | 572 | coma_mask |= COMA_RGB | COMA_BW | COMA_BYTE_SWAP; |
573 | coma_set |= COMA_WORD_SWAP; | 573 | coma_set |= COMA_WORD_SWAP; |
574 | break; | 574 | break; |
575 | case V4L2_MBUS_FMT_YVYU8_2X8: | 575 | case MEDIA_BUS_FMT_YVYU8_2X8: |
576 | dev_dbg(&client->dev, "pixel format YVYU8_2X8_LE (untested)\n"); | 576 | dev_dbg(&client->dev, "pixel format YVYU8_2X8_LE (untested)\n"); |
577 | coma_mask |= COMA_RGB | COMA_BW | COMA_WORD_SWAP | | 577 | coma_mask |= COMA_RGB | COMA_BW | COMA_WORD_SWAP | |
578 | COMA_BYTE_SWAP; | 578 | COMA_BYTE_SWAP; |
579 | break; | 579 | break; |
580 | case V4L2_MBUS_FMT_UYVY8_2X8: | 580 | case MEDIA_BUS_FMT_UYVY8_2X8: |
581 | dev_dbg(&client->dev, "pixel format YUYV8_2X8_BE\n"); | 581 | dev_dbg(&client->dev, "pixel format YUYV8_2X8_BE\n"); |
582 | if (half_scale) { | 582 | if (half_scale) { |
583 | coma_mask |= COMA_RGB | COMA_BW | COMA_WORD_SWAP; | 583 | coma_mask |= COMA_RGB | COMA_BW | COMA_WORD_SWAP; |
@@ -587,7 +587,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) | |||
587 | coma_set |= COMA_BYTE_SWAP | COMA_WORD_SWAP; | 587 | coma_set |= COMA_BYTE_SWAP | COMA_WORD_SWAP; |
588 | } | 588 | } |
589 | break; | 589 | break; |
590 | case V4L2_MBUS_FMT_VYUY8_2X8: | 590 | case MEDIA_BUS_FMT_VYUY8_2X8: |
591 | dev_dbg(&client->dev, "pixel format YVYU8_2X8_BE (untested)\n"); | 591 | dev_dbg(&client->dev, "pixel format YVYU8_2X8_BE (untested)\n"); |
592 | if (half_scale) { | 592 | if (half_scale) { |
593 | coma_mask |= COMA_RGB | COMA_BW; | 593 | coma_mask |= COMA_RGB | COMA_BW; |
@@ -597,7 +597,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) | |||
597 | coma_set |= COMA_BYTE_SWAP; | 597 | coma_set |= COMA_BYTE_SWAP; |
598 | } | 598 | } |
599 | break; | 599 | break; |
600 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 600 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
601 | dev_dbg(&client->dev, "pixel format SBGGR8_1X8 (untested)\n"); | 601 | dev_dbg(&client->dev, "pixel format SBGGR8_1X8 (untested)\n"); |
602 | coma_mask |= COMA_BW | COMA_BYTE_SWAP | COMA_WORD_SWAP; | 602 | coma_mask |= COMA_BW | COMA_BYTE_SWAP | COMA_WORD_SWAP; |
603 | coma_set |= COMA_RAW_RGB | COMA_RGB; | 603 | coma_set |= COMA_RAW_RGB | COMA_RGB; |
@@ -608,8 +608,8 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) | |||
608 | } | 608 | } |
609 | priv->code = code; | 609 | priv->code = code; |
610 | 610 | ||
611 | if (code == V4L2_MBUS_FMT_Y8_1X8 || | 611 | if (code == MEDIA_BUS_FMT_Y8_1X8 || |
612 | code == V4L2_MBUS_FMT_SBGGR8_1X8) { | 612 | code == MEDIA_BUS_FMT_SBGGR8_1X8) { |
613 | coml_mask = COML_ONE_CHANNEL; | 613 | coml_mask = COML_ONE_CHANNEL; |
614 | coml_set = 0; | 614 | coml_set = 0; |
615 | priv->pclk_max = 4000000; | 615 | priv->pclk_max = 4000000; |
@@ -619,7 +619,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) | |||
619 | priv->pclk_max = 8000000; | 619 | priv->pclk_max = 8000000; |
620 | } | 620 | } |
621 | 621 | ||
622 | if (code == V4L2_MBUS_FMT_SBGGR8_1X8) | 622 | if (code == MEDIA_BUS_FMT_SBGGR8_1X8) |
623 | priv->colorspace = V4L2_COLORSPACE_SRGB; | 623 | priv->colorspace = V4L2_COLORSPACE_SRGB; |
624 | else if (code != 0) | 624 | else if (code != 0) |
625 | priv->colorspace = V4L2_COLORSPACE_JPEG; | 625 | priv->colorspace = V4L2_COLORSPACE_JPEG; |
@@ -697,18 +697,18 @@ static int ov6650_try_fmt(struct v4l2_subdev *sd, | |||
697 | mf->field = V4L2_FIELD_NONE; | 697 | mf->field = V4L2_FIELD_NONE; |
698 | 698 | ||
699 | switch (mf->code) { | 699 | switch (mf->code) { |
700 | case V4L2_MBUS_FMT_Y10_1X10: | 700 | case MEDIA_BUS_FMT_Y10_1X10: |
701 | mf->code = V4L2_MBUS_FMT_Y8_1X8; | 701 | mf->code = MEDIA_BUS_FMT_Y8_1X8; |
702 | case V4L2_MBUS_FMT_Y8_1X8: | 702 | case MEDIA_BUS_FMT_Y8_1X8: |
703 | case V4L2_MBUS_FMT_YVYU8_2X8: | 703 | case MEDIA_BUS_FMT_YVYU8_2X8: |
704 | case V4L2_MBUS_FMT_YUYV8_2X8: | 704 | case MEDIA_BUS_FMT_YUYV8_2X8: |
705 | case V4L2_MBUS_FMT_VYUY8_2X8: | 705 | case MEDIA_BUS_FMT_VYUY8_2X8: |
706 | case V4L2_MBUS_FMT_UYVY8_2X8: | 706 | case MEDIA_BUS_FMT_UYVY8_2X8: |
707 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 707 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
708 | break; | 708 | break; |
709 | default: | 709 | default: |
710 | mf->code = V4L2_MBUS_FMT_SBGGR8_1X8; | 710 | mf->code = MEDIA_BUS_FMT_SBGGR8_1X8; |
711 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 711 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
712 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 712 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
713 | break; | 713 | break; |
714 | } | 714 | } |
@@ -717,7 +717,7 @@ static int ov6650_try_fmt(struct v4l2_subdev *sd, | |||
717 | } | 717 | } |
718 | 718 | ||
719 | static int ov6650_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 719 | static int ov6650_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
720 | enum v4l2_mbus_pixelcode *code) | 720 | u32 *code) |
721 | { | 721 | { |
722 | if (index >= ARRAY_SIZE(ov6650_codes)) | 722 | if (index >= ARRAY_SIZE(ov6650_codes)) |
723 | return -EINVAL; | 723 | return -EINVAL; |
@@ -1013,7 +1013,7 @@ static int ov6650_probe(struct i2c_client *client, | |||
1013 | priv->rect.width = W_CIF; | 1013 | priv->rect.width = W_CIF; |
1014 | priv->rect.height = H_CIF; | 1014 | priv->rect.height = H_CIF; |
1015 | priv->half_scale = false; | 1015 | priv->half_scale = false; |
1016 | priv->code = V4L2_MBUS_FMT_YUYV8_2X8; | 1016 | priv->code = MEDIA_BUS_FMT_YUYV8_2X8; |
1017 | priv->colorspace = V4L2_COLORSPACE_JPEG; | 1017 | priv->colorspace = V4L2_COLORSPACE_JPEG; |
1018 | 1018 | ||
1019 | priv->clk = v4l2_clk_get(&client->dev, "mclk"); | 1019 | priv->clk = v4l2_clk_get(&client->dev, "mclk"); |
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c index 970a04e1e56e..8daac88b33fe 100644 --- a/drivers/media/i2c/soc_camera/ov772x.c +++ b/drivers/media/i2c/soc_camera/ov772x.c | |||
@@ -376,7 +376,7 @@ | |||
376 | */ | 376 | */ |
377 | 377 | ||
378 | struct ov772x_color_format { | 378 | struct ov772x_color_format { |
379 | enum v4l2_mbus_pixelcode code; | 379 | u32 code; |
380 | enum v4l2_colorspace colorspace; | 380 | enum v4l2_colorspace colorspace; |
381 | u8 dsp3; | 381 | u8 dsp3; |
382 | u8 dsp4; | 382 | u8 dsp4; |
@@ -408,7 +408,7 @@ struct ov772x_priv { | |||
408 | */ | 408 | */ |
409 | static const struct ov772x_color_format ov772x_cfmts[] = { | 409 | static const struct ov772x_color_format ov772x_cfmts[] = { |
410 | { | 410 | { |
411 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 411 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
412 | .colorspace = V4L2_COLORSPACE_JPEG, | 412 | .colorspace = V4L2_COLORSPACE_JPEG, |
413 | .dsp3 = 0x0, | 413 | .dsp3 = 0x0, |
414 | .dsp4 = DSP_OFMT_YUV, | 414 | .dsp4 = DSP_OFMT_YUV, |
@@ -416,7 +416,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
416 | .com7 = OFMT_YUV, | 416 | .com7 = OFMT_YUV, |
417 | }, | 417 | }, |
418 | { | 418 | { |
419 | .code = V4L2_MBUS_FMT_YVYU8_2X8, | 419 | .code = MEDIA_BUS_FMT_YVYU8_2X8, |
420 | .colorspace = V4L2_COLORSPACE_JPEG, | 420 | .colorspace = V4L2_COLORSPACE_JPEG, |
421 | .dsp3 = UV_ON, | 421 | .dsp3 = UV_ON, |
422 | .dsp4 = DSP_OFMT_YUV, | 422 | .dsp4 = DSP_OFMT_YUV, |
@@ -424,7 +424,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
424 | .com7 = OFMT_YUV, | 424 | .com7 = OFMT_YUV, |
425 | }, | 425 | }, |
426 | { | 426 | { |
427 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 427 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
428 | .colorspace = V4L2_COLORSPACE_JPEG, | 428 | .colorspace = V4L2_COLORSPACE_JPEG, |
429 | .dsp3 = 0x0, | 429 | .dsp3 = 0x0, |
430 | .dsp4 = DSP_OFMT_YUV, | 430 | .dsp4 = DSP_OFMT_YUV, |
@@ -432,7 +432,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
432 | .com7 = OFMT_YUV, | 432 | .com7 = OFMT_YUV, |
433 | }, | 433 | }, |
434 | { | 434 | { |
435 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, | 435 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, |
436 | .colorspace = V4L2_COLORSPACE_SRGB, | 436 | .colorspace = V4L2_COLORSPACE_SRGB, |
437 | .dsp3 = 0x0, | 437 | .dsp3 = 0x0, |
438 | .dsp4 = DSP_OFMT_YUV, | 438 | .dsp4 = DSP_OFMT_YUV, |
@@ -440,7 +440,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
440 | .com7 = FMT_RGB555 | OFMT_RGB, | 440 | .com7 = FMT_RGB555 | OFMT_RGB, |
441 | }, | 441 | }, |
442 | { | 442 | { |
443 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, | 443 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, |
444 | .colorspace = V4L2_COLORSPACE_SRGB, | 444 | .colorspace = V4L2_COLORSPACE_SRGB, |
445 | .dsp3 = 0x0, | 445 | .dsp3 = 0x0, |
446 | .dsp4 = DSP_OFMT_YUV, | 446 | .dsp4 = DSP_OFMT_YUV, |
@@ -448,7 +448,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
448 | .com7 = FMT_RGB555 | OFMT_RGB, | 448 | .com7 = FMT_RGB555 | OFMT_RGB, |
449 | }, | 449 | }, |
450 | { | 450 | { |
451 | .code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 451 | .code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
452 | .colorspace = V4L2_COLORSPACE_SRGB, | 452 | .colorspace = V4L2_COLORSPACE_SRGB, |
453 | .dsp3 = 0x0, | 453 | .dsp3 = 0x0, |
454 | .dsp4 = DSP_OFMT_YUV, | 454 | .dsp4 = DSP_OFMT_YUV, |
@@ -456,7 +456,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
456 | .com7 = FMT_RGB565 | OFMT_RGB, | 456 | .com7 = FMT_RGB565 | OFMT_RGB, |
457 | }, | 457 | }, |
458 | { | 458 | { |
459 | .code = V4L2_MBUS_FMT_RGB565_2X8_BE, | 459 | .code = MEDIA_BUS_FMT_RGB565_2X8_BE, |
460 | .colorspace = V4L2_COLORSPACE_SRGB, | 460 | .colorspace = V4L2_COLORSPACE_SRGB, |
461 | .dsp3 = 0x0, | 461 | .dsp3 = 0x0, |
462 | .dsp4 = DSP_OFMT_YUV, | 462 | .dsp4 = DSP_OFMT_YUV, |
@@ -468,7 +468,7 @@ static const struct ov772x_color_format ov772x_cfmts[] = { | |||
468 | * regardless of the COM7 value. We can thus only support 10-bit | 468 | * regardless of the COM7 value. We can thus only support 10-bit |
469 | * Bayer until someone figures it out. | 469 | * Bayer until someone figures it out. |
470 | */ | 470 | */ |
471 | .code = V4L2_MBUS_FMT_SBGGR10_1X10, | 471 | .code = MEDIA_BUS_FMT_SBGGR10_1X10, |
472 | .colorspace = V4L2_COLORSPACE_SRGB, | 472 | .colorspace = V4L2_COLORSPACE_SRGB, |
473 | .dsp3 = 0x0, | 473 | .dsp3 = 0x0, |
474 | .dsp4 = DSP_OFMT_RAW10, | 474 | .dsp4 = DSP_OFMT_RAW10, |
@@ -990,7 +990,7 @@ static struct v4l2_subdev_core_ops ov772x_subdev_core_ops = { | |||
990 | }; | 990 | }; |
991 | 991 | ||
992 | static int ov772x_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 992 | static int ov772x_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
993 | enum v4l2_mbus_pixelcode *code) | 993 | u32 *code) |
994 | { | 994 | { |
995 | if (index >= ARRAY_SIZE(ov772x_cfmts)) | 995 | if (index >= ARRAY_SIZE(ov772x_cfmts)) |
996 | return -EINVAL; | 996 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c index bc74224503e7..aa93d2e88572 100644 --- a/drivers/media/i2c/soc_camera/ov9640.c +++ b/drivers/media/i2c/soc_camera/ov9640.c | |||
@@ -159,10 +159,10 @@ static const struct ov9640_reg ov9640_regs_rgb[] = { | |||
159 | { OV9640_MTXS, 0x65 }, | 159 | { OV9640_MTXS, 0x65 }, |
160 | }; | 160 | }; |
161 | 161 | ||
162 | static enum v4l2_mbus_pixelcode ov9640_codes[] = { | 162 | static u32 ov9640_codes[] = { |
163 | V4L2_MBUS_FMT_UYVY8_2X8, | 163 | MEDIA_BUS_FMT_UYVY8_2X8, |
164 | V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, | 164 | MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, |
165 | V4L2_MBUS_FMT_RGB565_2X8_LE, | 165 | MEDIA_BUS_FMT_RGB565_2X8_LE, |
166 | }; | 166 | }; |
167 | 167 | ||
168 | /* read a register */ | 168 | /* read a register */ |
@@ -351,22 +351,22 @@ static void ov9640_res_roundup(u32 *width, u32 *height) | |||
351 | } | 351 | } |
352 | 352 | ||
353 | /* Prepare necessary register changes depending on color encoding */ | 353 | /* Prepare necessary register changes depending on color encoding */ |
354 | static void ov9640_alter_regs(enum v4l2_mbus_pixelcode code, | 354 | static void ov9640_alter_regs(u32 code, |
355 | struct ov9640_reg_alt *alt) | 355 | struct ov9640_reg_alt *alt) |
356 | { | 356 | { |
357 | switch (code) { | 357 | switch (code) { |
358 | default: | 358 | default: |
359 | case V4L2_MBUS_FMT_UYVY8_2X8: | 359 | case MEDIA_BUS_FMT_UYVY8_2X8: |
360 | alt->com12 = OV9640_COM12_YUV_AVG; | 360 | alt->com12 = OV9640_COM12_YUV_AVG; |
361 | alt->com13 = OV9640_COM13_Y_DELAY_EN | | 361 | alt->com13 = OV9640_COM13_Y_DELAY_EN | |
362 | OV9640_COM13_YUV_DLY(0x01); | 362 | OV9640_COM13_YUV_DLY(0x01); |
363 | break; | 363 | break; |
364 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: | 364 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE: |
365 | alt->com7 = OV9640_COM7_RGB; | 365 | alt->com7 = OV9640_COM7_RGB; |
366 | alt->com13 = OV9640_COM13_RGB_AVG; | 366 | alt->com13 = OV9640_COM13_RGB_AVG; |
367 | alt->com15 = OV9640_COM15_RGB_555; | 367 | alt->com15 = OV9640_COM15_RGB_555; |
368 | break; | 368 | break; |
369 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 369 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
370 | alt->com7 = OV9640_COM7_RGB; | 370 | alt->com7 = OV9640_COM7_RGB; |
371 | alt->com13 = OV9640_COM13_RGB_AVG; | 371 | alt->com13 = OV9640_COM13_RGB_AVG; |
372 | alt->com15 = OV9640_COM15_RGB_565; | 372 | alt->com15 = OV9640_COM15_RGB_565; |
@@ -376,7 +376,7 @@ static void ov9640_alter_regs(enum v4l2_mbus_pixelcode code, | |||
376 | 376 | ||
377 | /* Setup registers according to resolution and color encoding */ | 377 | /* Setup registers according to resolution and color encoding */ |
378 | static int ov9640_write_regs(struct i2c_client *client, u32 width, | 378 | static int ov9640_write_regs(struct i2c_client *client, u32 width, |
379 | enum v4l2_mbus_pixelcode code, struct ov9640_reg_alt *alts) | 379 | u32 code, struct ov9640_reg_alt *alts) |
380 | { | 380 | { |
381 | const struct ov9640_reg *ov9640_regs, *matrix_regs; | 381 | const struct ov9640_reg *ov9640_regs, *matrix_regs; |
382 | int ov9640_regs_len, matrix_regs_len; | 382 | int ov9640_regs_len, matrix_regs_len; |
@@ -419,7 +419,7 @@ static int ov9640_write_regs(struct i2c_client *client, u32 width, | |||
419 | } | 419 | } |
420 | 420 | ||
421 | /* select color matrix configuration for given color encoding */ | 421 | /* select color matrix configuration for given color encoding */ |
422 | if (code == V4L2_MBUS_FMT_UYVY8_2X8) { | 422 | if (code == MEDIA_BUS_FMT_UYVY8_2X8) { |
423 | matrix_regs = ov9640_regs_yuv; | 423 | matrix_regs = ov9640_regs_yuv; |
424 | matrix_regs_len = ARRAY_SIZE(ov9640_regs_yuv); | 424 | matrix_regs_len = ARRAY_SIZE(ov9640_regs_yuv); |
425 | } else { | 425 | } else { |
@@ -487,7 +487,7 @@ static int ov9640_s_fmt(struct v4l2_subdev *sd, | |||
487 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 487 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
488 | struct ov9640_reg_alt alts = {0}; | 488 | struct ov9640_reg_alt alts = {0}; |
489 | enum v4l2_colorspace cspace; | 489 | enum v4l2_colorspace cspace; |
490 | enum v4l2_mbus_pixelcode code = mf->code; | 490 | u32 code = mf->code; |
491 | int ret; | 491 | int ret; |
492 | 492 | ||
493 | ov9640_res_roundup(&mf->width, &mf->height); | 493 | ov9640_res_roundup(&mf->width, &mf->height); |
@@ -500,13 +500,13 @@ static int ov9640_s_fmt(struct v4l2_subdev *sd, | |||
500 | return ret; | 500 | return ret; |
501 | 501 | ||
502 | switch (code) { | 502 | switch (code) { |
503 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: | 503 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE: |
504 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 504 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
505 | cspace = V4L2_COLORSPACE_SRGB; | 505 | cspace = V4L2_COLORSPACE_SRGB; |
506 | break; | 506 | break; |
507 | default: | 507 | default: |
508 | code = V4L2_MBUS_FMT_UYVY8_2X8; | 508 | code = MEDIA_BUS_FMT_UYVY8_2X8; |
509 | case V4L2_MBUS_FMT_UYVY8_2X8: | 509 | case MEDIA_BUS_FMT_UYVY8_2X8: |
510 | cspace = V4L2_COLORSPACE_JPEG; | 510 | cspace = V4L2_COLORSPACE_JPEG; |
511 | } | 511 | } |
512 | 512 | ||
@@ -527,13 +527,13 @@ static int ov9640_try_fmt(struct v4l2_subdev *sd, | |||
527 | mf->field = V4L2_FIELD_NONE; | 527 | mf->field = V4L2_FIELD_NONE; |
528 | 528 | ||
529 | switch (mf->code) { | 529 | switch (mf->code) { |
530 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: | 530 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE: |
531 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 531 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
532 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 532 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
533 | break; | 533 | break; |
534 | default: | 534 | default: |
535 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 535 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
536 | case V4L2_MBUS_FMT_UYVY8_2X8: | 536 | case MEDIA_BUS_FMT_UYVY8_2X8: |
537 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 537 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
538 | } | 538 | } |
539 | 539 | ||
@@ -541,7 +541,7 @@ static int ov9640_try_fmt(struct v4l2_subdev *sd, | |||
541 | } | 541 | } |
542 | 542 | ||
543 | static int ov9640_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 543 | static int ov9640_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
544 | enum v4l2_mbus_pixelcode *code) | 544 | u32 *code) |
545 | { | 545 | { |
546 | if (index >= ARRAY_SIZE(ov9640_codes)) | 546 | if (index >= ARRAY_SIZE(ov9640_codes)) |
547 | return -EINVAL; | 547 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c index ee9eb635d540..841dc55457cf 100644 --- a/drivers/media/i2c/soc_camera/ov9740.c +++ b/drivers/media/i2c/soc_camera/ov9740.c | |||
@@ -392,8 +392,8 @@ static const struct ov9740_reg ov9740_defaults[] = { | |||
392 | { OV9740_ISP_CTRL19, 0x02 }, | 392 | { OV9740_ISP_CTRL19, 0x02 }, |
393 | }; | 393 | }; |
394 | 394 | ||
395 | static enum v4l2_mbus_pixelcode ov9740_codes[] = { | 395 | static u32 ov9740_codes[] = { |
396 | V4L2_MBUS_FMT_YUYV8_2X8, | 396 | MEDIA_BUS_FMT_YUYV8_2X8, |
397 | }; | 397 | }; |
398 | 398 | ||
399 | /* read a register */ | 399 | /* read a register */ |
@@ -674,13 +674,13 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd, | |||
674 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 674 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
675 | struct ov9740_priv *priv = to_ov9740(sd); | 675 | struct ov9740_priv *priv = to_ov9740(sd); |
676 | enum v4l2_colorspace cspace; | 676 | enum v4l2_colorspace cspace; |
677 | enum v4l2_mbus_pixelcode code = mf->code; | 677 | u32 code = mf->code; |
678 | int ret; | 678 | int ret; |
679 | 679 | ||
680 | ov9740_res_roundup(&mf->width, &mf->height); | 680 | ov9740_res_roundup(&mf->width, &mf->height); |
681 | 681 | ||
682 | switch (code) { | 682 | switch (code) { |
683 | case V4L2_MBUS_FMT_YUYV8_2X8: | 683 | case MEDIA_BUS_FMT_YUYV8_2X8: |
684 | cspace = V4L2_COLORSPACE_SRGB; | 684 | cspace = V4L2_COLORSPACE_SRGB; |
685 | break; | 685 | break; |
686 | default: | 686 | default: |
@@ -710,14 +710,14 @@ static int ov9740_try_fmt(struct v4l2_subdev *sd, | |||
710 | ov9740_res_roundup(&mf->width, &mf->height); | 710 | ov9740_res_roundup(&mf->width, &mf->height); |
711 | 711 | ||
712 | mf->field = V4L2_FIELD_NONE; | 712 | mf->field = V4L2_FIELD_NONE; |
713 | mf->code = V4L2_MBUS_FMT_YUYV8_2X8; | 713 | mf->code = MEDIA_BUS_FMT_YUYV8_2X8; |
714 | mf->colorspace = V4L2_COLORSPACE_SRGB; | 714 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
715 | 715 | ||
716 | return 0; | 716 | return 0; |
717 | } | 717 | } |
718 | 718 | ||
719 | static int ov9740_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 719 | static int ov9740_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
720 | enum v4l2_mbus_pixelcode *code) | 720 | u32 *code) |
721 | { | 721 | { |
722 | if (index >= ARRAY_SIZE(ov9740_codes)) | 722 | if (index >= ARRAY_SIZE(ov9740_codes)) |
723 | return -EINVAL; | 723 | return -EINVAL; |
diff --git a/drivers/media/i2c/soc_camera/rj54n1cb0c.c b/drivers/media/i2c/soc_camera/rj54n1cb0c.c index 7e6d97847874..1752428c43c5 100644 --- a/drivers/media/i2c/soc_camera/rj54n1cb0c.c +++ b/drivers/media/i2c/soc_camera/rj54n1cb0c.c | |||
@@ -111,13 +111,13 @@ | |||
111 | 111 | ||
112 | /* RJ54N1CB0C has only one fixed colorspace per pixelcode */ | 112 | /* RJ54N1CB0C has only one fixed colorspace per pixelcode */ |
113 | struct rj54n1_datafmt { | 113 | struct rj54n1_datafmt { |
114 | enum v4l2_mbus_pixelcode code; | 114 | u32 code; |
115 | enum v4l2_colorspace colorspace; | 115 | enum v4l2_colorspace colorspace; |
116 | }; | 116 | }; |
117 | 117 | ||
118 | /* Find a data format by a pixel code in an array */ | 118 | /* Find a data format by a pixel code in an array */ |
119 | static const struct rj54n1_datafmt *rj54n1_find_datafmt( | 119 | static const struct rj54n1_datafmt *rj54n1_find_datafmt( |
120 | enum v4l2_mbus_pixelcode code, const struct rj54n1_datafmt *fmt, | 120 | u32 code, const struct rj54n1_datafmt *fmt, |
121 | int n) | 121 | int n) |
122 | { | 122 | { |
123 | int i; | 123 | int i; |
@@ -129,15 +129,15 @@ static const struct rj54n1_datafmt *rj54n1_find_datafmt( | |||
129 | } | 129 | } |
130 | 130 | ||
131 | static const struct rj54n1_datafmt rj54n1_colour_fmts[] = { | 131 | static const struct rj54n1_datafmt rj54n1_colour_fmts[] = { |
132 | {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}, | 132 | {MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}, |
133 | {V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG}, | 133 | {MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG}, |
134 | {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, | 134 | {MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, |
135 | {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, | 135 | {MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, |
136 | {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, | 136 | {MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, |
137 | {V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, V4L2_COLORSPACE_SRGB}, | 137 | {MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, V4L2_COLORSPACE_SRGB}, |
138 | {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, | 138 | {MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, |
139 | {V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, V4L2_COLORSPACE_SRGB}, | 139 | {MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, V4L2_COLORSPACE_SRGB}, |
140 | {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, | 140 | {MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB}, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | struct rj54n1_clock_div { | 143 | struct rj54n1_clock_div { |
@@ -486,7 +486,7 @@ static int reg_write_multiple(struct i2c_client *client, | |||
486 | } | 486 | } |
487 | 487 | ||
488 | static int rj54n1_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 488 | static int rj54n1_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
489 | enum v4l2_mbus_pixelcode *code) | 489 | u32 *code) |
490 | { | 490 | { |
491 | if (index >= ARRAY_SIZE(rj54n1_colour_fmts)) | 491 | if (index >= ARRAY_SIZE(rj54n1_colour_fmts)) |
492 | return -EINVAL; | 492 | return -EINVAL; |
@@ -965,11 +965,11 @@ static int rj54n1_try_fmt(struct v4l2_subdev *sd, | |||
965 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 965 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
966 | struct rj54n1 *rj54n1 = to_rj54n1(client); | 966 | struct rj54n1 *rj54n1 = to_rj54n1(client); |
967 | const struct rj54n1_datafmt *fmt; | 967 | const struct rj54n1_datafmt *fmt; |
968 | int align = mf->code == V4L2_MBUS_FMT_SBGGR10_1X10 || | 968 | int align = mf->code == MEDIA_BUS_FMT_SBGGR10_1X10 || |
969 | mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE || | 969 | mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE || |
970 | mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE || | 970 | mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE || |
971 | mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE || | 971 | mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE || |
972 | mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE; | 972 | mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE; |
973 | 973 | ||
974 | dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n", | 974 | dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n", |
975 | __func__, mf->code, mf->width, mf->height); | 975 | __func__, mf->code, mf->width, mf->height); |
@@ -1025,55 +1025,55 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd, | |||
1025 | 1025 | ||
1026 | /* RA_SEL_UL is only relevant for raw modes, ignored otherwise. */ | 1026 | /* RA_SEL_UL is only relevant for raw modes, ignored otherwise. */ |
1027 | switch (mf->code) { | 1027 | switch (mf->code) { |
1028 | case V4L2_MBUS_FMT_YUYV8_2X8: | 1028 | case MEDIA_BUS_FMT_YUYV8_2X8: |
1029 | ret = reg_write(client, RJ54N1_OUT_SEL, 0); | 1029 | ret = reg_write(client, RJ54N1_OUT_SEL, 0); |
1030 | if (!ret) | 1030 | if (!ret) |
1031 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); | 1031 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); |
1032 | break; | 1032 | break; |
1033 | case V4L2_MBUS_FMT_YVYU8_2X8: | 1033 | case MEDIA_BUS_FMT_YVYU8_2X8: |
1034 | ret = reg_write(client, RJ54N1_OUT_SEL, 0); | 1034 | ret = reg_write(client, RJ54N1_OUT_SEL, 0); |
1035 | if (!ret) | 1035 | if (!ret) |
1036 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); | 1036 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); |
1037 | break; | 1037 | break; |
1038 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 1038 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
1039 | ret = reg_write(client, RJ54N1_OUT_SEL, 0x11); | 1039 | ret = reg_write(client, RJ54N1_OUT_SEL, 0x11); |
1040 | if (!ret) | 1040 | if (!ret) |
1041 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); | 1041 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); |
1042 | break; | 1042 | break; |
1043 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 1043 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
1044 | ret = reg_write(client, RJ54N1_OUT_SEL, 0x11); | 1044 | ret = reg_write(client, RJ54N1_OUT_SEL, 0x11); |
1045 | if (!ret) | 1045 | if (!ret) |
1046 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); | 1046 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); |
1047 | break; | 1047 | break; |
1048 | case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE: | 1048 | case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE: |
1049 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); | 1049 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); |
1050 | if (!ret) | 1050 | if (!ret) |
1051 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); | 1051 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); |
1052 | if (!ret) | 1052 | if (!ret) |
1053 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 0); | 1053 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 0); |
1054 | break; | 1054 | break; |
1055 | case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE: | 1055 | case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE: |
1056 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); | 1056 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); |
1057 | if (!ret) | 1057 | if (!ret) |
1058 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); | 1058 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8); |
1059 | if (!ret) | 1059 | if (!ret) |
1060 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 8); | 1060 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 8); |
1061 | break; | 1061 | break; |
1062 | case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE: | 1062 | case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE: |
1063 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); | 1063 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); |
1064 | if (!ret) | 1064 | if (!ret) |
1065 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); | 1065 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); |
1066 | if (!ret) | 1066 | if (!ret) |
1067 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 0); | 1067 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 0); |
1068 | break; | 1068 | break; |
1069 | case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE: | 1069 | case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE: |
1070 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); | 1070 | ret = reg_write(client, RJ54N1_OUT_SEL, 4); |
1071 | if (!ret) | 1071 | if (!ret) |
1072 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); | 1072 | ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8); |
1073 | if (!ret) | 1073 | if (!ret) |
1074 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 8); | 1074 | ret = reg_write(client, RJ54N1_RA_SEL_UL, 8); |
1075 | break; | 1075 | break; |
1076 | case V4L2_MBUS_FMT_SBGGR10_1X10: | 1076 | case MEDIA_BUS_FMT_SBGGR10_1X10: |
1077 | ret = reg_write(client, RJ54N1_OUT_SEL, 5); | 1077 | ret = reg_write(client, RJ54N1_OUT_SEL, 5); |
1078 | break; | 1078 | break; |
1079 | default: | 1079 | default: |
@@ -1083,7 +1083,7 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd, | |||
1083 | /* Special case: a raw mode with 10 bits of data per clock tick */ | 1083 | /* Special case: a raw mode with 10 bits of data per clock tick */ |
1084 | if (!ret) | 1084 | if (!ret) |
1085 | ret = reg_set(client, RJ54N1_OCLK_SEL_EN, | 1085 | ret = reg_set(client, RJ54N1_OCLK_SEL_EN, |
1086 | (mf->code == V4L2_MBUS_FMT_SBGGR10_1X10) << 1, 2); | 1086 | (mf->code == MEDIA_BUS_FMT_SBGGR10_1X10) << 1, 2); |
1087 | 1087 | ||
1088 | if (ret < 0) | 1088 | if (ret < 0) |
1089 | return ret; | 1089 | return ret; |
diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c index 416402eb4f82..9b853215d146 100644 --- a/drivers/media/i2c/soc_camera/tw9910.c +++ b/drivers/media/i2c/soc_camera/tw9910.c | |||
@@ -705,7 +705,7 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, | |||
705 | 705 | ||
706 | mf->width = priv->scale->width; | 706 | mf->width = priv->scale->width; |
707 | mf->height = priv->scale->height; | 707 | mf->height = priv->scale->height; |
708 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 708 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
709 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 709 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
710 | mf->field = V4L2_FIELD_INTERLACED_BT; | 710 | mf->field = V4L2_FIELD_INTERLACED_BT; |
711 | 711 | ||
@@ -724,7 +724,7 @@ static int tw9910_s_fmt(struct v4l2_subdev *sd, | |||
724 | /* | 724 | /* |
725 | * check color format | 725 | * check color format |
726 | */ | 726 | */ |
727 | if (mf->code != V4L2_MBUS_FMT_UYVY8_2X8) | 727 | if (mf->code != MEDIA_BUS_FMT_UYVY8_2X8) |
728 | return -EINVAL; | 728 | return -EINVAL; |
729 | 729 | ||
730 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 730 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
@@ -751,7 +751,7 @@ static int tw9910_try_fmt(struct v4l2_subdev *sd, | |||
751 | return -EINVAL; | 751 | return -EINVAL; |
752 | } | 752 | } |
753 | 753 | ||
754 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | 754 | mf->code = MEDIA_BUS_FMT_UYVY8_2X8; |
755 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 755 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
756 | 756 | ||
757 | /* | 757 | /* |
@@ -822,12 +822,12 @@ static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = { | |||
822 | }; | 822 | }; |
823 | 823 | ||
824 | static int tw9910_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 824 | static int tw9910_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
825 | enum v4l2_mbus_pixelcode *code) | 825 | u32 *code) |
826 | { | 826 | { |
827 | if (index) | 827 | if (index) |
828 | return -EINVAL; | 828 | return -EINVAL; |
829 | 829 | ||
830 | *code = V4L2_MBUS_FMT_UYVY8_2X8; | 830 | *code = MEDIA_BUS_FMT_UYVY8_2X8; |
831 | return 0; | 831 | return 0; |
832 | } | 832 | } |
833 | 833 | ||
diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c index 118f8ee88465..10c735c3a082 100644 --- a/drivers/media/i2c/sr030pc30.c +++ b/drivers/media/i2c/sr030pc30.c | |||
@@ -165,7 +165,7 @@ struct sr030pc30_info { | |||
165 | }; | 165 | }; |
166 | 166 | ||
167 | struct sr030pc30_format { | 167 | struct sr030pc30_format { |
168 | enum v4l2_mbus_pixelcode code; | 168 | u32 code; |
169 | enum v4l2_colorspace colorspace; | 169 | enum v4l2_colorspace colorspace; |
170 | u16 ispctl1_reg; | 170 | u16 ispctl1_reg; |
171 | }; | 171 | }; |
@@ -201,23 +201,23 @@ static const struct sr030pc30_frmsize sr030pc30_sizes[] = { | |||
201 | /* supported pixel formats */ | 201 | /* supported pixel formats */ |
202 | static const struct sr030pc30_format sr030pc30_formats[] = { | 202 | static const struct sr030pc30_format sr030pc30_formats[] = { |
203 | { | 203 | { |
204 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 204 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
205 | .colorspace = V4L2_COLORSPACE_JPEG, | 205 | .colorspace = V4L2_COLORSPACE_JPEG, |
206 | .ispctl1_reg = 0x03, | 206 | .ispctl1_reg = 0x03, |
207 | }, { | 207 | }, { |
208 | .code = V4L2_MBUS_FMT_YVYU8_2X8, | 208 | .code = MEDIA_BUS_FMT_YVYU8_2X8, |
209 | .colorspace = V4L2_COLORSPACE_JPEG, | 209 | .colorspace = V4L2_COLORSPACE_JPEG, |
210 | .ispctl1_reg = 0x02, | 210 | .ispctl1_reg = 0x02, |
211 | }, { | 211 | }, { |
212 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 212 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
213 | .colorspace = V4L2_COLORSPACE_JPEG, | 213 | .colorspace = V4L2_COLORSPACE_JPEG, |
214 | .ispctl1_reg = 0, | 214 | .ispctl1_reg = 0, |
215 | }, { | 215 | }, { |
216 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 216 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
217 | .colorspace = V4L2_COLORSPACE_JPEG, | 217 | .colorspace = V4L2_COLORSPACE_JPEG, |
218 | .ispctl1_reg = 0x01, | 218 | .ispctl1_reg = 0x01, |
219 | }, { | 219 | }, { |
220 | .code = V4L2_MBUS_FMT_RGB565_2X8_BE, | 220 | .code = MEDIA_BUS_FMT_RGB565_2X8_BE, |
221 | .colorspace = V4L2_COLORSPACE_JPEG, | 221 | .colorspace = V4L2_COLORSPACE_JPEG, |
222 | .ispctl1_reg = 0x40, | 222 | .ispctl1_reg = 0x40, |
223 | }, | 223 | }, |
@@ -472,7 +472,7 @@ static int sr030pc30_s_ctrl(struct v4l2_ctrl *ctrl) | |||
472 | } | 472 | } |
473 | 473 | ||
474 | static int sr030pc30_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 474 | static int sr030pc30_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
475 | enum v4l2_mbus_pixelcode *code) | 475 | u32 *code) |
476 | { | 476 | { |
477 | if (!code || index >= ARRAY_SIZE(sr030pc30_formats)) | 477 | if (!code || index >= ARRAY_SIZE(sr030pc30_formats)) |
478 | return -EINVAL; | 478 | return -EINVAL; |
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index b9dabc9f4050..204204259ac6 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c | |||
@@ -756,12 +756,12 @@ static int tvp514x_s_ctrl(struct v4l2_ctrl *ctrl) | |||
756 | */ | 756 | */ |
757 | static int | 757 | static int |
758 | tvp514x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 758 | tvp514x_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
759 | enum v4l2_mbus_pixelcode *code) | 759 | u32 *code) |
760 | { | 760 | { |
761 | if (index) | 761 | if (index) |
762 | return -EINVAL; | 762 | return -EINVAL; |
763 | 763 | ||
764 | *code = V4L2_MBUS_FMT_YUYV10_2X10; | 764 | *code = MEDIA_BUS_FMT_YUYV10_2X10; |
765 | return 0; | 765 | return 0; |
766 | } | 766 | } |
767 | 767 | ||
@@ -784,7 +784,7 @@ tvp514x_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f) | |||
784 | /* Calculate height and width based on current standard */ | 784 | /* Calculate height and width based on current standard */ |
785 | current_std = decoder->current_std; | 785 | current_std = decoder->current_std; |
786 | 786 | ||
787 | f->code = V4L2_MBUS_FMT_YUYV8_2X8; | 787 | f->code = MEDIA_BUS_FMT_YUYV8_2X8; |
788 | f->width = decoder->std_list[current_std].width; | 788 | f->width = decoder->std_list[current_std].width; |
789 | f->height = decoder->std_list[current_std].height; | 789 | f->height = decoder->std_list[current_std].height; |
790 | f->field = V4L2_FIELD_INTERLACED; | 790 | f->field = V4L2_FIELD_INTERLACED; |
@@ -942,7 +942,7 @@ static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd, | |||
942 | if (index != 0) | 942 | if (index != 0) |
943 | return -EINVAL; | 943 | return -EINVAL; |
944 | 944 | ||
945 | code->code = V4L2_MBUS_FMT_YUYV8_2X8; | 945 | code->code = MEDIA_BUS_FMT_YUYV8_2X8; |
946 | 946 | ||
947 | return 0; | 947 | return 0; |
948 | } | 948 | } |
@@ -967,7 +967,7 @@ static int tvp514x_get_pad_format(struct v4l2_subdev *sd, | |||
967 | return 0; | 967 | return 0; |
968 | } | 968 | } |
969 | 969 | ||
970 | format->format.code = V4L2_MBUS_FMT_YUYV8_2X8; | 970 | format->format.code = MEDIA_BUS_FMT_YUYV8_2X8; |
971 | format->format.width = tvp514x_std_list[decoder->current_std].width; | 971 | format->format.width = tvp514x_std_list[decoder->current_std].width; |
972 | format->format.height = tvp514x_std_list[decoder->current_std].height; | 972 | format->format.height = tvp514x_std_list[decoder->current_std].height; |
973 | format->format.colorspace = V4L2_COLORSPACE_SMPTE170M; | 973 | format->format.colorspace = V4L2_COLORSPACE_SMPTE170M; |
@@ -991,7 +991,7 @@ static int tvp514x_set_pad_format(struct v4l2_subdev *sd, | |||
991 | struct tvp514x_decoder *decoder = to_decoder(sd); | 991 | struct tvp514x_decoder *decoder = to_decoder(sd); |
992 | 992 | ||
993 | if (fmt->format.field != V4L2_FIELD_INTERLACED || | 993 | if (fmt->format.field != V4L2_FIELD_INTERLACED || |
994 | fmt->format.code != V4L2_MBUS_FMT_YUYV8_2X8 || | 994 | fmt->format.code != MEDIA_BUS_FMT_YUYV8_2X8 || |
995 | fmt->format.colorspace != V4L2_COLORSPACE_SMPTE170M || | 995 | fmt->format.colorspace != V4L2_COLORSPACE_SMPTE170M || |
996 | fmt->format.width != tvp514x_std_list[decoder->current_std].width || | 996 | fmt->format.width != tvp514x_std_list[decoder->current_std].width || |
997 | fmt->format.height != tvp514x_std_list[decoder->current_std].height) | 997 | fmt->format.height != tvp514x_std_list[decoder->current_std].height) |
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 193e7d6c29c8..68cdab9c0903 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c | |||
@@ -818,12 +818,12 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd) | |||
818 | } | 818 | } |
819 | 819 | ||
820 | static int tvp5150_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 820 | static int tvp5150_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
821 | enum v4l2_mbus_pixelcode *code) | 821 | u32 *code) |
822 | { | 822 | { |
823 | if (index) | 823 | if (index) |
824 | return -EINVAL; | 824 | return -EINVAL; |
825 | 825 | ||
826 | *code = V4L2_MBUS_FMT_UYVY8_2X8; | 826 | *code = MEDIA_BUS_FMT_UYVY8_2X8; |
827 | return 0; | 827 | return 0; |
828 | } | 828 | } |
829 | 829 | ||
@@ -840,7 +840,7 @@ static int tvp5150_mbus_fmt(struct v4l2_subdev *sd, | |||
840 | f->width = decoder->rect.width; | 840 | f->width = decoder->rect.width; |
841 | f->height = decoder->rect.height; | 841 | f->height = decoder->rect.height; |
842 | 842 | ||
843 | f->code = V4L2_MBUS_FMT_UYVY8_2X8; | 843 | f->code = MEDIA_BUS_FMT_UYVY8_2X8; |
844 | f->field = V4L2_FIELD_SEQ_TB; | 844 | f->field = V4L2_FIELD_SEQ_TB; |
845 | f->colorspace = V4L2_COLORSPACE_SMPTE170M; | 845 | f->colorspace = V4L2_COLORSPACE_SMPTE170M; |
846 | 846 | ||
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 51bac762638b..fe4870e22cfe 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c | |||
@@ -626,7 +626,7 @@ static int tvp7002_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f | |||
626 | 626 | ||
627 | f->width = bt->width; | 627 | f->width = bt->width; |
628 | f->height = bt->height; | 628 | f->height = bt->height; |
629 | f->code = V4L2_MBUS_FMT_YUYV10_1X20; | 629 | f->code = MEDIA_BUS_FMT_YUYV10_1X20; |
630 | f->field = device->current_timings->scanmode; | 630 | f->field = device->current_timings->scanmode; |
631 | f->colorspace = device->current_timings->color_space; | 631 | f->colorspace = device->current_timings->color_space; |
632 | 632 | ||
@@ -756,12 +756,12 @@ static int tvp7002_s_register(struct v4l2_subdev *sd, | |||
756 | */ | 756 | */ |
757 | 757 | ||
758 | static int tvp7002_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 758 | static int tvp7002_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
759 | enum v4l2_mbus_pixelcode *code) | 759 | u32 *code) |
760 | { | 760 | { |
761 | /* Check requested format index is within range */ | 761 | /* Check requested format index is within range */ |
762 | if (index) | 762 | if (index) |
763 | return -EINVAL; | 763 | return -EINVAL; |
764 | *code = V4L2_MBUS_FMT_YUYV10_1X20; | 764 | *code = MEDIA_BUS_FMT_YUYV10_1X20; |
765 | return 0; | 765 | return 0; |
766 | } | 766 | } |
767 | 767 | ||
@@ -859,7 +859,7 @@ tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
859 | if (code->index != 0) | 859 | if (code->index != 0) |
860 | return -EINVAL; | 860 | return -EINVAL; |
861 | 861 | ||
862 | code->code = V4L2_MBUS_FMT_YUYV10_1X20; | 862 | code->code = MEDIA_BUS_FMT_YUYV10_1X20; |
863 | 863 | ||
864 | return 0; | 864 | return 0; |
865 | } | 865 | } |
@@ -878,7 +878,7 @@ tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
878 | { | 878 | { |
879 | struct tvp7002 *tvp7002 = to_tvp7002(sd); | 879 | struct tvp7002 *tvp7002 = to_tvp7002(sd); |
880 | 880 | ||
881 | fmt->format.code = V4L2_MBUS_FMT_YUYV10_1X20; | 881 | fmt->format.code = MEDIA_BUS_FMT_YUYV10_1X20; |
882 | fmt->format.width = tvp7002->current_timings->timings.bt.width; | 882 | fmt->format.width = tvp7002->current_timings->timings.bt.width; |
883 | fmt->format.height = tvp7002->current_timings->timings.bt.height; | 883 | fmt->format.height = tvp7002->current_timings->timings.bt.height; |
884 | fmt->format.field = tvp7002->current_timings->scanmode; | 884 | fmt->format.field = tvp7002->current_timings->scanmode; |
diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index 373f2df52492..00e7f043977e 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c | |||
@@ -45,19 +45,19 @@ struct vs6624 { | |||
45 | }; | 45 | }; |
46 | 46 | ||
47 | static const struct vs6624_format { | 47 | static const struct vs6624_format { |
48 | enum v4l2_mbus_pixelcode mbus_code; | 48 | u32 mbus_code; |
49 | enum v4l2_colorspace colorspace; | 49 | enum v4l2_colorspace colorspace; |
50 | } vs6624_formats[] = { | 50 | } vs6624_formats[] = { |
51 | { | 51 | { |
52 | .mbus_code = V4L2_MBUS_FMT_UYVY8_2X8, | 52 | .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, |
53 | .colorspace = V4L2_COLORSPACE_JPEG, | 53 | .colorspace = V4L2_COLORSPACE_JPEG, |
54 | }, | 54 | }, |
55 | { | 55 | { |
56 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 56 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
57 | .colorspace = V4L2_COLORSPACE_JPEG, | 57 | .colorspace = V4L2_COLORSPACE_JPEG, |
58 | }, | 58 | }, |
59 | { | 59 | { |
60 | .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 60 | .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
61 | .colorspace = V4L2_COLORSPACE_SRGB, | 61 | .colorspace = V4L2_COLORSPACE_SRGB, |
62 | }, | 62 | }, |
63 | }; | 63 | }; |
@@ -65,7 +65,7 @@ static const struct vs6624_format { | |||
65 | static struct v4l2_mbus_framefmt vs6624_default_fmt = { | 65 | static struct v4l2_mbus_framefmt vs6624_default_fmt = { |
66 | .width = VGA_WIDTH, | 66 | .width = VGA_WIDTH, |
67 | .height = VGA_HEIGHT, | 67 | .height = VGA_HEIGHT, |
68 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 68 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
69 | .field = V4L2_FIELD_NONE, | 69 | .field = V4L2_FIELD_NONE, |
70 | .colorspace = V4L2_COLORSPACE_JPEG, | 70 | .colorspace = V4L2_COLORSPACE_JPEG, |
71 | }; | 71 | }; |
@@ -558,7 +558,7 @@ static int vs6624_s_ctrl(struct v4l2_ctrl *ctrl) | |||
558 | } | 558 | } |
559 | 559 | ||
560 | static int vs6624_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, | 560 | static int vs6624_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, |
561 | enum v4l2_mbus_pixelcode *code) | 561 | u32 *code) |
562 | { | 562 | { |
563 | if (index >= ARRAY_SIZE(vs6624_formats)) | 563 | if (index >= ARRAY_SIZE(vs6624_formats)) |
564 | return -EINVAL; | 564 | return -EINVAL; |
@@ -605,15 +605,15 @@ static int vs6624_s_mbus_fmt(struct v4l2_subdev *sd, | |||
605 | 605 | ||
606 | /* set image format */ | 606 | /* set image format */ |
607 | switch (fmt->code) { | 607 | switch (fmt->code) { |
608 | case V4L2_MBUS_FMT_UYVY8_2X8: | 608 | case MEDIA_BUS_FMT_UYVY8_2X8: |
609 | vs6624_write(sd, VS6624_IMG_FMT0, 0x0); | 609 | vs6624_write(sd, VS6624_IMG_FMT0, 0x0); |
610 | vs6624_write(sd, VS6624_YUV_SETUP, 0x1); | 610 | vs6624_write(sd, VS6624_YUV_SETUP, 0x1); |
611 | break; | 611 | break; |
612 | case V4L2_MBUS_FMT_YUYV8_2X8: | 612 | case MEDIA_BUS_FMT_YUYV8_2X8: |
613 | vs6624_write(sd, VS6624_IMG_FMT0, 0x0); | 613 | vs6624_write(sd, VS6624_IMG_FMT0, 0x0); |
614 | vs6624_write(sd, VS6624_YUV_SETUP, 0x3); | 614 | vs6624_write(sd, VS6624_YUV_SETUP, 0x3); |
615 | break; | 615 | break; |
616 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 616 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
617 | vs6624_write(sd, VS6624_IMG_FMT0, 0x4); | 617 | vs6624_write(sd, VS6624_IMG_FMT0, 0x4); |
618 | vs6624_write(sd, VS6624_RGB_SETUP, 0x0); | 618 | vs6624_write(sd, VS6624_RGB_SETUP, 0x0); |
619 | break; | 619 | break; |
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 37c334edc7e8..4d8e01c7b1b2 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c | |||
@@ -279,8 +279,14 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, | |||
279 | continue; | 279 | continue; |
280 | 280 | ||
281 | ret = entity->ops->link_validate(link); | 281 | ret = entity->ops->link_validate(link); |
282 | if (ret < 0 && ret != -ENOIOCTLCMD) | 282 | if (ret < 0 && ret != -ENOIOCTLCMD) { |
283 | dev_dbg(entity->parent->dev, | ||
284 | "link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n", | ||
285 | entity->name, link->source->index, | ||
286 | link->sink->entity->name, | ||
287 | link->sink->index, ret); | ||
283 | goto error; | 288 | goto error; |
289 | } | ||
284 | } | 290 | } |
285 | 291 | ||
286 | /* Either no links or validated links are fine. */ | 292 | /* Either no links or validated links are fine. */ |
@@ -288,6 +294,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, | |||
288 | 294 | ||
289 | if (!bitmap_full(active, entity->num_pads)) { | 295 | if (!bitmap_full(active, entity->num_pads)) { |
290 | ret = -EPIPE; | 296 | ret = -EPIPE; |
297 | dev_dbg(entity->parent->dev, | ||
298 | "\"%s\":%u must be connected by an enabled link\n", | ||
299 | entity->name, | ||
300 | (unsigned)find_first_zero_bit( | ||
301 | active, entity->num_pads)); | ||
291 | goto error; | 302 | goto error; |
292 | } | 303 | } |
293 | } | 304 | } |
diff --git a/drivers/media/pci/Kconfig b/drivers/media/pci/Kconfig index f8cec8e8cf82..218144a99016 100644 --- a/drivers/media/pci/Kconfig +++ b/drivers/media/pci/Kconfig | |||
@@ -46,6 +46,7 @@ source "drivers/media/pci/pt3/Kconfig" | |||
46 | source "drivers/media/pci/mantis/Kconfig" | 46 | source "drivers/media/pci/mantis/Kconfig" |
47 | source "drivers/media/pci/ngene/Kconfig" | 47 | source "drivers/media/pci/ngene/Kconfig" |
48 | source "drivers/media/pci/ddbridge/Kconfig" | 48 | source "drivers/media/pci/ddbridge/Kconfig" |
49 | source "drivers/media/pci/smipcie/Kconfig" | ||
49 | endif | 50 | endif |
50 | 51 | ||
51 | endif #MEDIA_PCI_SUPPORT | 52 | endif #MEDIA_PCI_SUPPORT |
diff --git a/drivers/media/pci/Makefile b/drivers/media/pci/Makefile index a12926e4b51f..0baf0d2967ee 100644 --- a/drivers/media/pci/Makefile +++ b/drivers/media/pci/Makefile | |||
@@ -11,7 +11,8 @@ obj-y += ttpci/ \ | |||
11 | mantis/ \ | 11 | mantis/ \ |
12 | ngene/ \ | 12 | ngene/ \ |
13 | ddbridge/ \ | 13 | ddbridge/ \ |
14 | saa7146/ | 14 | saa7146/ \ |
15 | smipcie/ | ||
15 | 16 | ||
16 | obj-$(CONFIG_VIDEO_IVTV) += ivtv/ | 17 | obj-$(CONFIG_VIDEO_IVTV) += ivtv/ |
17 | obj-$(CONFIG_VIDEO_ZORAN) += zoran/ | 18 | obj-$(CONFIG_VIDEO_ZORAN) += zoran/ |
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c index d8ec583c154c..41055606b969 100644 --- a/drivers/media/pci/bt8xx/bttv-cards.c +++ b/drivers/media/pci/bt8xx/bttv-cards.c | |||
@@ -3870,10 +3870,10 @@ static void osprey_eeprom(struct bttv *btv, const u8 ee[256]) | |||
3870 | } else { | 3870 | } else { |
3871 | unsigned short type; | 3871 | unsigned short type; |
3872 | 3872 | ||
3873 | for (i = 4*16; i < 8*16; i += 16) { | 3873 | for (i = 4 * 16; i < 8 * 16; i += 16) { |
3874 | u16 checksum = ip_compute_csum(ee + i, 16); | 3874 | u16 checksum = (__force u16)ip_compute_csum(ee + i, 16); |
3875 | 3875 | ||
3876 | if ((checksum&0xff) + (checksum>>8) == 0xff) | 3876 | if ((checksum & 0xff) + (checksum >> 8) == 0xff) |
3877 | break; | 3877 | break; |
3878 | } | 3878 | } |
3879 | if (i >= 8*16) | 3879 | if (i >= 8*16) |
diff --git a/drivers/media/pci/bt8xx/bttv-risc.c b/drivers/media/pci/bt8xx/bttv-risc.c index 82cc47d2e3fa..4d3f05a19af3 100644 --- a/drivers/media/pci/bt8xx/bttv-risc.c +++ b/drivers/media/pci/bt8xx/bttv-risc.c | |||
@@ -84,7 +84,7 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc, | |||
84 | continue; | 84 | continue; |
85 | while (offset && offset >= sg_dma_len(sg)) { | 85 | while (offset && offset >= sg_dma_len(sg)) { |
86 | offset -= sg_dma_len(sg); | 86 | offset -= sg_dma_len(sg); |
87 | sg++; | 87 | sg = sg_next(sg); |
88 | } | 88 | } |
89 | if (bpl <= sg_dma_len(sg)-offset) { | 89 | if (bpl <= sg_dma_len(sg)-offset) { |
90 | /* fits into current chunk */ | 90 | /* fits into current chunk */ |
@@ -100,13 +100,13 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc, | |||
100 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | 100 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); |
101 | todo -= (sg_dma_len(sg)-offset); | 101 | todo -= (sg_dma_len(sg)-offset); |
102 | offset = 0; | 102 | offset = 0; |
103 | sg++; | 103 | sg = sg_next(sg); |
104 | while (todo > sg_dma_len(sg)) { | 104 | while (todo > sg_dma_len(sg)) { |
105 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE| | 105 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE| |
106 | sg_dma_len(sg)); | 106 | sg_dma_len(sg)); |
107 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 107 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); |
108 | todo -= sg_dma_len(sg); | 108 | todo -= sg_dma_len(sg); |
109 | sg++; | 109 | sg = sg_next(sg); |
110 | } | 110 | } |
111 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_EOL| | 111 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_EOL| |
112 | todo); | 112 | todo); |
@@ -187,15 +187,15 @@ bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc, | |||
187 | /* go to next sg entry if needed */ | 187 | /* go to next sg entry if needed */ |
188 | while (yoffset && yoffset >= sg_dma_len(ysg)) { | 188 | while (yoffset && yoffset >= sg_dma_len(ysg)) { |
189 | yoffset -= sg_dma_len(ysg); | 189 | yoffset -= sg_dma_len(ysg); |
190 | ysg++; | 190 | ysg = sg_next(ysg); |
191 | } | 191 | } |
192 | while (uoffset && uoffset >= sg_dma_len(usg)) { | 192 | while (uoffset && uoffset >= sg_dma_len(usg)) { |
193 | uoffset -= sg_dma_len(usg); | 193 | uoffset -= sg_dma_len(usg); |
194 | usg++; | 194 | usg = sg_next(usg); |
195 | } | 195 | } |
196 | while (voffset && voffset >= sg_dma_len(vsg)) { | 196 | while (voffset && voffset >= sg_dma_len(vsg)) { |
197 | voffset -= sg_dma_len(vsg); | 197 | voffset -= sg_dma_len(vsg); |
198 | vsg++; | 198 | vsg = sg_next(vsg); |
199 | } | 199 | } |
200 | 200 | ||
201 | /* calculate max number of bytes we can write */ | 201 | /* calculate max number of bytes we can write */ |
diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c index 2d3afe0431a9..5a55630d09db 100644 --- a/drivers/media/pci/cx18/cx18-av-core.c +++ b/drivers/media/pci/cx18/cx18-av-core.c | |||
@@ -490,8 +490,8 @@ void cx18_av_std_setup(struct cx18 *cx) | |||
490 | 490 | ||
491 | /* Sets horizontal blanking delay and active lines */ | 491 | /* Sets horizontal blanking delay and active lines */ |
492 | cx18_av_write(cx, 0x470, hblank); | 492 | cx18_av_write(cx, 0x470, hblank); |
493 | cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) | | 493 | cx18_av_write(cx, 0x471, |
494 | (hactive << 4))); | 494 | (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff); |
495 | cx18_av_write(cx, 0x472, hactive >> 4); | 495 | cx18_av_write(cx, 0x472, hactive >> 4); |
496 | 496 | ||
497 | /* Sets burst gate delay */ | 497 | /* Sets burst gate delay */ |
@@ -499,14 +499,14 @@ void cx18_av_std_setup(struct cx18 *cx) | |||
499 | 499 | ||
500 | /* Sets vertical blanking delay and active duration */ | 500 | /* Sets vertical blanking delay and active duration */ |
501 | cx18_av_write(cx, 0x474, vblank); | 501 | cx18_av_write(cx, 0x474, vblank); |
502 | cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) | | 502 | cx18_av_write(cx, 0x475, |
503 | (vactive << 4))); | 503 | (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff); |
504 | cx18_av_write(cx, 0x476, vactive >> 4); | 504 | cx18_av_write(cx, 0x476, vactive >> 4); |
505 | cx18_av_write(cx, 0x477, vblank656); | 505 | cx18_av_write(cx, 0x477, vblank656); |
506 | 506 | ||
507 | /* Sets src decimation rate */ | 507 | /* Sets src decimation rate */ |
508 | cx18_av_write(cx, 0x478, 0xff & src_decimation); | 508 | cx18_av_write(cx, 0x478, src_decimation & 0xff); |
509 | cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8)); | 509 | cx18_av_write(cx, 0x479, (src_decimation >> 8) & 0xff); |
510 | 510 | ||
511 | /* Sets Luma and UV Low pass filters */ | 511 | /* Sets Luma and UV Low pass filters */ |
512 | cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); | 512 | cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); |
@@ -516,8 +516,8 @@ void cx18_av_std_setup(struct cx18 *cx) | |||
516 | 516 | ||
517 | /* Sets SC Step*/ | 517 | /* Sets SC Step*/ |
518 | cx18_av_write(cx, 0x47c, sc); | 518 | cx18_av_write(cx, 0x47c, sc); |
519 | cx18_av_write(cx, 0x47d, 0xff & sc >> 8); | 519 | cx18_av_write(cx, 0x47d, (sc >> 8) & 0xff); |
520 | cx18_av_write(cx, 0x47e, 0xff & sc >> 16); | 520 | cx18_av_write(cx, 0x47e, (sc >> 16) & 0xff); |
521 | 521 | ||
522 | if (std & V4L2_STD_625_50) { | 522 | if (std & V4L2_STD_625_50) { |
523 | state->slicer_line_delay = 1; | 523 | state->slicer_line_delay = 1; |
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt | |||
952 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; | 952 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; |
953 | int is_50Hz = !(state->std & V4L2_STD_525_60); | 953 | int is_50Hz = !(state->std & V4L2_STD_525_60); |
954 | 954 | ||
955 | if (fmt->code != V4L2_MBUS_FMT_FIXED) | 955 | if (fmt->code != MEDIA_BUS_FMT_FIXED) |
956 | return -EINVAL; | 956 | return -EINVAL; |
957 | 957 | ||
958 | fmt->field = V4L2_FIELD_INTERLACED; | 958 | fmt->field = V4L2_FIELD_INTERLACED; |
diff --git a/drivers/media/pci/cx18/cx18-cards.h b/drivers/media/pci/cx18/cx18-cards.h index add7391ecaba..f6b921f3b0ac 100644 --- a/drivers/media/pci/cx18/cx18-cards.h +++ b/drivers/media/pci/cx18/cx18-cards.h | |||
@@ -57,7 +57,8 @@ | |||
57 | /* V4L2 capability aliases */ | 57 | /* V4L2 capability aliases */ |
58 | #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ | 58 | #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ |
59 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | \ | 59 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | \ |
60 | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE) | 60 | V4L2_CAP_STREAMING | V4L2_CAP_VBI_CAPTURE | \ |
61 | V4L2_CAP_SLICED_VBI_CAPTURE) | ||
61 | 62 | ||
62 | struct cx18_card_video_input { | 63 | struct cx18_card_video_input { |
63 | u8 video_type; /* video input type */ | 64 | u8 video_type; /* video input type */ |
diff --git a/drivers/media/pci/cx18/cx18-controls.c b/drivers/media/pci/cx18/cx18-controls.c index 282a3d29fdaa..4aeb7c6b8ce1 100644 --- a/drivers/media/pci/cx18/cx18-controls.c +++ b/drivers/media/pci/cx18/cx18-controls.c | |||
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val) | |||
98 | /* fix videodecoder resolution */ | 98 | /* fix videodecoder resolution */ |
99 | fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); | 99 | fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); |
100 | fmt.height = cxhdl->height; | 100 | fmt.height = cxhdl->height; |
101 | fmt.code = V4L2_MBUS_FMT_FIXED; | 101 | fmt.code = MEDIA_BUS_FMT_FIXED; |
102 | v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &fmt); | 102 | v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &fmt); |
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
diff --git a/drivers/media/pci/cx18/cx18-driver.h b/drivers/media/pci/cx18/cx18-driver.h index 57f4688ea55b..dcfd7a1d317e 100644 --- a/drivers/media/pci/cx18/cx18-driver.h +++ b/drivers/media/pci/cx18/cx18-driver.h | |||
@@ -379,6 +379,7 @@ struct cx18_stream { | |||
379 | const char *name; /* name of the stream */ | 379 | const char *name; /* name of the stream */ |
380 | int type; /* stream type */ | 380 | int type; /* stream type */ |
381 | u32 handle; /* task handle */ | 381 | u32 handle; /* task handle */ |
382 | u32 v4l2_dev_caps; /* device capabilities */ | ||
382 | unsigned int mdl_base_idx; | 383 | unsigned int mdl_base_idx; |
383 | 384 | ||
384 | u32 id; | 385 | u32 id; |
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c index 6f2b59042b73..b8e4b68a9196 100644 --- a/drivers/media/pci/cx18/cx18-ioctl.c +++ b/drivers/media/pci/cx18/cx18-ioctl.c | |||
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh, | |||
294 | 294 | ||
295 | mbus_fmt.width = cx->cxhdl.width = w; | 295 | mbus_fmt.width = cx->cxhdl.width = w; |
296 | mbus_fmt.height = cx->cxhdl.height = h; | 296 | mbus_fmt.height = cx->cxhdl.height = h; |
297 | mbus_fmt.code = V4L2_MBUS_FMT_FIXED; | 297 | mbus_fmt.code = MEDIA_BUS_FMT_FIXED; |
298 | v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &mbus_fmt); | 298 | v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &mbus_fmt); |
299 | return cx18_g_fmt_vid_cap(file, fh, fmt); | 299 | return cx18_g_fmt_vid_cap(file, fh, fmt); |
300 | } | 300 | } |
@@ -393,15 +393,16 @@ static int cx18_querycap(struct file *file, void *fh, | |||
393 | struct v4l2_capability *vcap) | 393 | struct v4l2_capability *vcap) |
394 | { | 394 | { |
395 | struct cx18_open_id *id = fh2id(fh); | 395 | struct cx18_open_id *id = fh2id(fh); |
396 | struct cx18_stream *s = video_drvdata(file); | ||
396 | struct cx18 *cx = id->cx; | 397 | struct cx18 *cx = id->cx; |
397 | 398 | ||
398 | strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); | 399 | strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); |
399 | strlcpy(vcap->card, cx->card_name, sizeof(vcap->card)); | 400 | strlcpy(vcap->card, cx->card_name, sizeof(vcap->card)); |
400 | snprintf(vcap->bus_info, sizeof(vcap->bus_info), | 401 | snprintf(vcap->bus_info, sizeof(vcap->bus_info), |
401 | "PCI:%s", pci_name(cx->pci_dev)); | 402 | "PCI:%s", pci_name(cx->pci_dev)); |
402 | vcap->capabilities = cx->v4l2_cap; /* capabilities */ | 403 | vcap->capabilities = cx->v4l2_cap; /* capabilities */ |
403 | if (id->type == CX18_ENC_STREAM_TYPE_YUV) | 404 | vcap->device_caps = s->v4l2_dev_caps; /* device capabilities */ |
404 | vcap->capabilities |= V4L2_CAP_STREAMING; | 405 | vcap->capabilities |= V4L2_CAP_DEVICE_CAPS; |
405 | return 0; | 406 | return 0; |
406 | } | 407 | } |
407 | 408 | ||
diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c index f3541b5156ce..369445fcf3e5 100644 --- a/drivers/media/pci/cx18/cx18-streams.c +++ b/drivers/media/pci/cx18/cx18-streams.c | |||
@@ -58,11 +58,14 @@ static struct { | |||
58 | int vfl_type; | 58 | int vfl_type; |
59 | int num_offset; | 59 | int num_offset; |
60 | int dma; | 60 | int dma; |
61 | u32 caps; | ||
61 | } cx18_stream_info[] = { | 62 | } cx18_stream_info[] = { |
62 | { /* CX18_ENC_STREAM_TYPE_MPG */ | 63 | { /* CX18_ENC_STREAM_TYPE_MPG */ |
63 | "encoder MPEG", | 64 | "encoder MPEG", |
64 | VFL_TYPE_GRABBER, 0, | 65 | VFL_TYPE_GRABBER, 0, |
65 | PCI_DMA_FROMDEVICE, | 66 | PCI_DMA_FROMDEVICE, |
67 | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | | ||
68 | V4L2_CAP_AUDIO | V4L2_CAP_TUNER | ||
66 | }, | 69 | }, |
67 | { /* CX18_ENC_STREAM_TYPE_TS */ | 70 | { /* CX18_ENC_STREAM_TYPE_TS */ |
68 | "TS", | 71 | "TS", |
@@ -73,11 +76,15 @@ static struct { | |||
73 | "encoder YUV", | 76 | "encoder YUV", |
74 | VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, | 77 | VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, |
75 | PCI_DMA_FROMDEVICE, | 78 | PCI_DMA_FROMDEVICE, |
79 | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | | ||
80 | V4L2_CAP_STREAMING | V4L2_CAP_AUDIO | V4L2_CAP_TUNER | ||
76 | }, | 81 | }, |
77 | { /* CX18_ENC_STREAM_TYPE_VBI */ | 82 | { /* CX18_ENC_STREAM_TYPE_VBI */ |
78 | "encoder VBI", | 83 | "encoder VBI", |
79 | VFL_TYPE_VBI, 0, | 84 | VFL_TYPE_VBI, 0, |
80 | PCI_DMA_FROMDEVICE, | 85 | PCI_DMA_FROMDEVICE, |
86 | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE | | ||
87 | V4L2_CAP_READWRITE | V4L2_CAP_TUNER | ||
81 | }, | 88 | }, |
82 | { /* CX18_ENC_STREAM_TYPE_PCM */ | 89 | { /* CX18_ENC_STREAM_TYPE_PCM */ |
83 | "encoder PCM audio", | 90 | "encoder PCM audio", |
@@ -93,6 +100,7 @@ static struct { | |||
93 | "encoder radio", | 100 | "encoder radio", |
94 | VFL_TYPE_RADIO, 0, | 101 | VFL_TYPE_RADIO, 0, |
95 | PCI_DMA_NONE, | 102 | PCI_DMA_NONE, |
103 | V4L2_CAP_RADIO | V4L2_CAP_TUNER | ||
96 | }, | 104 | }, |
97 | }; | 105 | }; |
98 | 106 | ||
@@ -260,6 +268,7 @@ static void cx18_stream_init(struct cx18 *cx, int type) | |||
260 | s->handle = CX18_INVALID_TASK_HANDLE; | 268 | s->handle = CX18_INVALID_TASK_HANDLE; |
261 | 269 | ||
262 | s->dma = cx18_stream_info[type].dma; | 270 | s->dma = cx18_stream_info[type].dma; |
271 | s->v4l2_dev_caps = cx18_stream_info[type].caps; | ||
263 | s->buffers = cx->stream_buffers[type]; | 272 | s->buffers = cx->stream_buffers[type]; |
264 | s->buf_size = cx->stream_buf_size[type]; | 273 | s->buf_size = cx->stream_buf_size[type]; |
265 | INIT_LIST_HEAD(&s->buf_pool); | 274 | INIT_LIST_HEAD(&s->buf_pool); |
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 3948db386fb5..e4901a503c73 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c | |||
@@ -1148,6 +1148,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
1148 | dev->ts1.ts_packet_count = mpeglines; | 1148 | dev->ts1.ts_packet_count = mpeglines; |
1149 | *num_planes = 1; | 1149 | *num_planes = 1; |
1150 | sizes[0] = mpeglinesize * mpeglines; | 1150 | sizes[0] = mpeglinesize * mpeglines; |
1151 | alloc_ctxs[0] = dev->alloc_ctx; | ||
1151 | *num_buffers = mpegbufs; | 1152 | *num_buffers = mpegbufs; |
1152 | return 0; | 1153 | return 0; |
1153 | } | 1154 | } |
@@ -1166,11 +1167,8 @@ static void buffer_finish(struct vb2_buffer *vb) | |||
1166 | struct cx23885_dev *dev = vb->vb2_queue->drv_priv; | 1167 | struct cx23885_dev *dev = vb->vb2_queue->drv_priv; |
1167 | struct cx23885_buffer *buf = container_of(vb, | 1168 | struct cx23885_buffer *buf = container_of(vb, |
1168 | struct cx23885_buffer, vb); | 1169 | struct cx23885_buffer, vb); |
1169 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
1170 | 1170 | ||
1171 | cx23885_free_buffer(dev, buf); | 1171 | cx23885_free_buffer(dev, buf); |
1172 | |||
1173 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
1174 | } | 1172 | } |
1175 | 1173 | ||
1176 | static void buffer_queue(struct vb2_buffer *vb) | 1174 | static void buffer_queue(struct vb2_buffer *vb) |
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c index 88c257d1161b..db99ca2613ba 100644 --- a/drivers/media/pci/cx23885/cx23885-cards.c +++ b/drivers/media/pci/cx23885/cx23885-cards.c | |||
@@ -680,6 +680,32 @@ struct cx23885_board cx23885_boards[] = { | |||
680 | .portb = CX23885_MPEG_DVB, | 680 | .portb = CX23885_MPEG_DVB, |
681 | .portc = CX23885_MPEG_DVB, | 681 | .portc = CX23885_MPEG_DVB, |
682 | }, | 682 | }, |
683 | [CX23885_BOARD_DVBSKY_T980C] = { | ||
684 | .name = "DVBSky T980C", | ||
685 | .portb = CX23885_MPEG_DVB, | ||
686 | }, | ||
687 | [CX23885_BOARD_DVBSKY_S950C] = { | ||
688 | .name = "DVBSky S950C", | ||
689 | .portb = CX23885_MPEG_DVB, | ||
690 | }, | ||
691 | [CX23885_BOARD_TT_CT2_4500_CI] = { | ||
692 | .name = "Technotrend TT-budget CT2-4500 CI", | ||
693 | .portb = CX23885_MPEG_DVB, | ||
694 | }, | ||
695 | [CX23885_BOARD_DVBSKY_S950] = { | ||
696 | .name = "DVBSky S950", | ||
697 | .portb = CX23885_MPEG_DVB, | ||
698 | }, | ||
699 | [CX23885_BOARD_DVBSKY_S952] = { | ||
700 | .name = "DVBSky S952", | ||
701 | .portb = CX23885_MPEG_DVB, | ||
702 | .portc = CX23885_MPEG_DVB, | ||
703 | }, | ||
704 | [CX23885_BOARD_DVBSKY_T982] = { | ||
705 | .name = "DVBSky T982", | ||
706 | .portb = CX23885_MPEG_DVB, | ||
707 | .portc = CX23885_MPEG_DVB, | ||
708 | }, | ||
683 | }; | 709 | }; |
684 | const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); | 710 | const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); |
685 | 711 | ||
@@ -939,6 +965,30 @@ struct cx23885_subid cx23885_subids[] = { | |||
939 | .subvendor = 0x4254, | 965 | .subvendor = 0x4254, |
940 | .subdevice = 0x9580, | 966 | .subdevice = 0x9580, |
941 | .card = CX23885_BOARD_DVBSKY_T9580, | 967 | .card = CX23885_BOARD_DVBSKY_T9580, |
968 | }, { | ||
969 | .subvendor = 0x4254, | ||
970 | .subdevice = 0x980c, | ||
971 | .card = CX23885_BOARD_DVBSKY_T980C, | ||
972 | }, { | ||
973 | .subvendor = 0x4254, | ||
974 | .subdevice = 0x950c, | ||
975 | .card = CX23885_BOARD_DVBSKY_S950C, | ||
976 | }, { | ||
977 | .subvendor = 0x13c2, | ||
978 | .subdevice = 0x3013, | ||
979 | .card = CX23885_BOARD_TT_CT2_4500_CI, | ||
980 | }, { | ||
981 | .subvendor = 0x4254, | ||
982 | .subdevice = 0x0950, | ||
983 | .card = CX23885_BOARD_DVBSKY_S950, | ||
984 | }, { | ||
985 | .subvendor = 0x4254, | ||
986 | .subdevice = 0x0952, | ||
987 | .card = CX23885_BOARD_DVBSKY_S952, | ||
988 | }, { | ||
989 | .subvendor = 0x4254, | ||
990 | .subdevice = 0x0982, | ||
991 | .card = CX23885_BOARD_DVBSKY_T982, | ||
942 | }, | 992 | }, |
943 | }; | 993 | }; |
944 | const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); | 994 | const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); |
@@ -1534,6 +1584,8 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) | |||
1534 | mdelay(60); | 1584 | mdelay(60); |
1535 | break; | 1585 | break; |
1536 | case CX23885_BOARD_DVBSKY_T9580: | 1586 | case CX23885_BOARD_DVBSKY_T9580: |
1587 | case CX23885_BOARD_DVBSKY_S952: | ||
1588 | case CX23885_BOARD_DVBSKY_T982: | ||
1537 | /* enable GPIO3-18 pins */ | 1589 | /* enable GPIO3-18 pins */ |
1538 | cx_write(MC417_CTL, 0x00000037); | 1590 | cx_write(MC417_CTL, 0x00000037); |
1539 | cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1); | 1591 | cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1); |
@@ -1541,6 +1593,45 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) | |||
1541 | mdelay(100); | 1593 | mdelay(100); |
1542 | cx23885_gpio_set(dev, GPIO_2 | GPIO_11); | 1594 | cx23885_gpio_set(dev, GPIO_2 | GPIO_11); |
1543 | break; | 1595 | break; |
1596 | case CX23885_BOARD_DVBSKY_T980C: | ||
1597 | case CX23885_BOARD_DVBSKY_S950C: | ||
1598 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
1599 | /* | ||
1600 | * GPIO-0 INTA from CiMax, input | ||
1601 | * GPIO-1 reset CiMax, output, high active | ||
1602 | * GPIO-2 reset demod, output, low active | ||
1603 | * GPIO-3 to GPIO-10 data/addr for CAM | ||
1604 | * GPIO-11 ~CS0 to CiMax1 | ||
1605 | * GPIO-12 ~CS1 to CiMax2 | ||
1606 | * GPIO-13 ADL0 load LSB addr | ||
1607 | * GPIO-14 ADL1 load MSB addr | ||
1608 | * GPIO-15 ~RDY from CiMax | ||
1609 | * GPIO-17 ~RD to CiMax | ||
1610 | * GPIO-18 ~WR to CiMax | ||
1611 | */ | ||
1612 | |||
1613 | cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */ | ||
1614 | cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */ | ||
1615 | mdelay(100); /* reset delay */ | ||
1616 | cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */ | ||
1617 | cx_clear(GP0_IO, 0x00010002); | ||
1618 | cx_write(MC417_CTL, 0x00000037); /* enable GPIO3-18 pins */ | ||
1619 | |||
1620 | /* GPIO-15 IN as ~ACK, rest as OUT */ | ||
1621 | cx_write(MC417_OEN, 0x00001000); | ||
1622 | |||
1623 | /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */ | ||
1624 | cx_write(MC417_RWD, 0x0000c300); | ||
1625 | |||
1626 | /* enable irq */ | ||
1627 | cx_write(GPIO_ISM, 0x00000000); /* INTERRUPTS active low */ | ||
1628 | break; | ||
1629 | case CX23885_BOARD_DVBSKY_S950: | ||
1630 | cx23885_gpio_enable(dev, GPIO_2, 1); | ||
1631 | cx23885_gpio_clear(dev, GPIO_2); | ||
1632 | msleep(100); | ||
1633 | cx23885_gpio_set(dev, GPIO_2); | ||
1634 | break; | ||
1544 | } | 1635 | } |
1545 | } | 1636 | } |
1546 | 1637 | ||
@@ -1621,6 +1712,13 @@ int cx23885_ir_init(struct cx23885_dev *dev) | |||
1621 | case CX23885_BOARD_MYGICA_X8507: | 1712 | case CX23885_BOARD_MYGICA_X8507: |
1622 | case CX23885_BOARD_TBS_6980: | 1713 | case CX23885_BOARD_TBS_6980: |
1623 | case CX23885_BOARD_TBS_6981: | 1714 | case CX23885_BOARD_TBS_6981: |
1715 | case CX23885_BOARD_DVBSKY_T9580: | ||
1716 | case CX23885_BOARD_DVBSKY_T980C: | ||
1717 | case CX23885_BOARD_DVBSKY_S950C: | ||
1718 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
1719 | case CX23885_BOARD_DVBSKY_S950: | ||
1720 | case CX23885_BOARD_DVBSKY_S952: | ||
1721 | case CX23885_BOARD_DVBSKY_T982: | ||
1624 | if (!enable_885_ir) | 1722 | if (!enable_885_ir) |
1625 | break; | 1723 | break; |
1626 | dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE); | 1724 | dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE); |
@@ -1667,6 +1765,13 @@ void cx23885_ir_fini(struct cx23885_dev *dev) | |||
1667 | case CX23885_BOARD_MYGICA_X8507: | 1765 | case CX23885_BOARD_MYGICA_X8507: |
1668 | case CX23885_BOARD_TBS_6980: | 1766 | case CX23885_BOARD_TBS_6980: |
1669 | case CX23885_BOARD_TBS_6981: | 1767 | case CX23885_BOARD_TBS_6981: |
1768 | case CX23885_BOARD_DVBSKY_T9580: | ||
1769 | case CX23885_BOARD_DVBSKY_T980C: | ||
1770 | case CX23885_BOARD_DVBSKY_S950C: | ||
1771 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
1772 | case CX23885_BOARD_DVBSKY_S950: | ||
1773 | case CX23885_BOARD_DVBSKY_S952: | ||
1774 | case CX23885_BOARD_DVBSKY_T982: | ||
1670 | cx23885_irq_remove(dev, PCI_MSK_AV_CORE); | 1775 | cx23885_irq_remove(dev, PCI_MSK_AV_CORE); |
1671 | /* sd_ir is a duplicate pointer to the AV Core, just clear it */ | 1776 | /* sd_ir is a duplicate pointer to the AV Core, just clear it */ |
1672 | dev->sd_ir = NULL; | 1777 | dev->sd_ir = NULL; |
@@ -1714,6 +1819,13 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev) | |||
1714 | case CX23885_BOARD_MYGICA_X8507: | 1819 | case CX23885_BOARD_MYGICA_X8507: |
1715 | case CX23885_BOARD_TBS_6980: | 1820 | case CX23885_BOARD_TBS_6980: |
1716 | case CX23885_BOARD_TBS_6981: | 1821 | case CX23885_BOARD_TBS_6981: |
1822 | case CX23885_BOARD_DVBSKY_T9580: | ||
1823 | case CX23885_BOARD_DVBSKY_T980C: | ||
1824 | case CX23885_BOARD_DVBSKY_S950C: | ||
1825 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
1826 | case CX23885_BOARD_DVBSKY_S950: | ||
1827 | case CX23885_BOARD_DVBSKY_S952: | ||
1828 | case CX23885_BOARD_DVBSKY_T982: | ||
1717 | if (dev->sd_ir) | 1829 | if (dev->sd_ir) |
1718 | cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE); | 1830 | cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE); |
1719 | break; | 1831 | break; |
@@ -1817,6 +1929,10 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
1817 | case CX23885_BOARD_TEVII_S471: | 1929 | case CX23885_BOARD_TEVII_S471: |
1818 | case CX23885_BOARD_DVBWORLD_2005: | 1930 | case CX23885_BOARD_DVBWORLD_2005: |
1819 | case CX23885_BOARD_PROF_8000: | 1931 | case CX23885_BOARD_PROF_8000: |
1932 | case CX23885_BOARD_DVBSKY_T980C: | ||
1933 | case CX23885_BOARD_DVBSKY_S950C: | ||
1934 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
1935 | case CX23885_BOARD_DVBSKY_S950: | ||
1820 | ts1->gen_ctrl_val = 0x5; /* Parallel */ | 1936 | ts1->gen_ctrl_val = 0x5; /* Parallel */ |
1821 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | 1937 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ |
1822 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | 1938 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; |
@@ -1865,6 +1981,7 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
1865 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | 1981 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; |
1866 | break; | 1982 | break; |
1867 | case CX23885_BOARD_DVBSKY_T9580: | 1983 | case CX23885_BOARD_DVBSKY_T9580: |
1984 | case CX23885_BOARD_DVBSKY_T982: | ||
1868 | ts1->gen_ctrl_val = 0x5; /* Parallel */ | 1985 | ts1->gen_ctrl_val = 0x5; /* Parallel */ |
1869 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | 1986 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ |
1870 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | 1987 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; |
@@ -1872,6 +1989,14 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
1872 | ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | 1989 | ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ |
1873 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | 1990 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; |
1874 | break; | 1991 | break; |
1992 | case CX23885_BOARD_DVBSKY_S952: | ||
1993 | ts1->gen_ctrl_val = 0x5; /* Parallel */ | ||
1994 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | ||
1995 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | ||
1996 | ts2->gen_ctrl_val = 0xe; /* Serial bus */ | ||
1997 | ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | ||
1998 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | ||
1999 | break; | ||
1875 | case CX23885_BOARD_HAUPPAUGE_HVR1250: | 2000 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
1876 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 2001 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
1877 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 2002 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
@@ -1935,6 +2060,12 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
1935 | case CX23885_BOARD_TBS_6980: | 2060 | case CX23885_BOARD_TBS_6980: |
1936 | case CX23885_BOARD_TBS_6981: | 2061 | case CX23885_BOARD_TBS_6981: |
1937 | case CX23885_BOARD_DVBSKY_T9580: | 2062 | case CX23885_BOARD_DVBSKY_T9580: |
2063 | case CX23885_BOARD_DVBSKY_T980C: | ||
2064 | case CX23885_BOARD_DVBSKY_S950C: | ||
2065 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
2066 | case CX23885_BOARD_DVBSKY_S950: | ||
2067 | case CX23885_BOARD_DVBSKY_S952: | ||
2068 | case CX23885_BOARD_DVBSKY_T982: | ||
1938 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, | 2069 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
1939 | &dev->i2c_bus[2].i2c_adap, | 2070 | &dev->i2c_bus[2].i2c_adap, |
1940 | "cx25840", 0x88 >> 1, NULL); | 2071 | "cx25840", 0x88 >> 1, NULL); |
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c index 3bd386c371f7..1d9d0f86ca8c 100644 --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c | |||
@@ -1453,17 +1453,12 @@ int cx23885_buf_prepare(struct cx23885_buffer *buf, struct cx23885_tsport *port) | |||
1453 | struct cx23885_dev *dev = port->dev; | 1453 | struct cx23885_dev *dev = port->dev; |
1454 | int size = port->ts_packet_size * port->ts_packet_count; | 1454 | int size = port->ts_packet_size * port->ts_packet_count; |
1455 | struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb, 0); | 1455 | struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb, 0); |
1456 | int rc; | ||
1457 | 1456 | ||
1458 | dprintk(1, "%s: %p\n", __func__, buf); | 1457 | dprintk(1, "%s: %p\n", __func__, buf); |
1459 | if (vb2_plane_size(&buf->vb, 0) < size) | 1458 | if (vb2_plane_size(&buf->vb, 0) < size) |
1460 | return -EINVAL; | 1459 | return -EINVAL; |
1461 | vb2_set_plane_payload(&buf->vb, 0, size); | 1460 | vb2_set_plane_payload(&buf->vb, 0, size); |
1462 | 1461 | ||
1463 | rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
1464 | if (!rc) | ||
1465 | return -EIO; | ||
1466 | |||
1467 | cx23885_risc_databuffer(dev->pci, &buf->risc, | 1462 | cx23885_risc_databuffer(dev->pci, &buf->risc, |
1468 | sgt->sgl, | 1463 | sgt->sgl, |
1469 | port->ts_packet_size, port->ts_packet_count, 0); | 1464 | port->ts_packet_size, port->ts_packet_count, 0); |
@@ -1997,9 +1992,14 @@ static int cx23885_initdev(struct pci_dev *pci_dev, | |||
1997 | if (!pci_dma_supported(pci_dev, 0xffffffff)) { | 1992 | if (!pci_dma_supported(pci_dev, 0xffffffff)) { |
1998 | printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); | 1993 | printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); |
1999 | err = -EIO; | 1994 | err = -EIO; |
2000 | goto fail_irq; | 1995 | goto fail_context; |
2001 | } | 1996 | } |
2002 | 1997 | ||
1998 | dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev); | ||
1999 | if (IS_ERR(dev->alloc_ctx)) { | ||
2000 | err = PTR_ERR(dev->alloc_ctx); | ||
2001 | goto fail_context; | ||
2002 | } | ||
2003 | err = request_irq(pci_dev->irq, cx23885_irq, | 2003 | err = request_irq(pci_dev->irq, cx23885_irq, |
2004 | IRQF_SHARED, dev->name, dev); | 2004 | IRQF_SHARED, dev->name, dev); |
2005 | if (err < 0) { | 2005 | if (err < 0) { |
@@ -2028,6 +2028,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev, | |||
2028 | return 0; | 2028 | return 0; |
2029 | 2029 | ||
2030 | fail_irq: | 2030 | fail_irq: |
2031 | vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); | ||
2032 | fail_context: | ||
2031 | cx23885_dev_unregister(dev); | 2033 | cx23885_dev_unregister(dev); |
2032 | fail_ctrl: | 2034 | fail_ctrl: |
2033 | v4l2_ctrl_handler_free(hdl); | 2035 | v4l2_ctrl_handler_free(hdl); |
@@ -2053,6 +2055,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev) | |||
2053 | free_irq(pci_dev->irq, dev); | 2055 | free_irq(pci_dev->irq, dev); |
2054 | 2056 | ||
2055 | cx23885_dev_unregister(dev); | 2057 | cx23885_dev_unregister(dev); |
2058 | vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); | ||
2056 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | 2059 | v4l2_ctrl_handler_free(&dev->ctrl_handler); |
2057 | v4l2_device_unregister(v4l2_dev); | 2060 | v4l2_device_unregister(v4l2_dev); |
2058 | kfree(dev); | 2061 | kfree(dev); |
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index 4cb90317ff45..c47d18270cfc 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c | |||
@@ -71,6 +71,7 @@ | |||
71 | #include "si2165.h" | 71 | #include "si2165.h" |
72 | #include "si2168.h" | 72 | #include "si2168.h" |
73 | #include "si2157.h" | 73 | #include "si2157.h" |
74 | #include "sp2.h" | ||
74 | #include "m88ds3103.h" | 75 | #include "m88ds3103.h" |
75 | #include "m88ts2022.h" | 76 | #include "m88ts2022.h" |
76 | 77 | ||
@@ -101,6 +102,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
101 | port->ts_packet_count = 32; | 102 | port->ts_packet_count = 32; |
102 | *num_planes = 1; | 103 | *num_planes = 1; |
103 | sizes[0] = port->ts_packet_size * port->ts_packet_count; | 104 | sizes[0] = port->ts_packet_size * port->ts_packet_count; |
105 | alloc_ctxs[0] = port->dev->alloc_ctx; | ||
104 | *num_buffers = 32; | 106 | *num_buffers = 32; |
105 | return 0; | 107 | return 0; |
106 | } | 108 | } |
@@ -121,11 +123,8 @@ static void buffer_finish(struct vb2_buffer *vb) | |||
121 | struct cx23885_dev *dev = port->dev; | 123 | struct cx23885_dev *dev = port->dev; |
122 | struct cx23885_buffer *buf = container_of(vb, | 124 | struct cx23885_buffer *buf = container_of(vb, |
123 | struct cx23885_buffer, vb); | 125 | struct cx23885_buffer, vb); |
124 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
125 | 126 | ||
126 | cx23885_free_buffer(dev, buf); | 127 | cx23885_free_buffer(dev, buf); |
127 | |||
128 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
129 | } | 128 | } |
130 | 129 | ||
131 | static void buffer_queue(struct vb2_buffer *vb) | 130 | static void buffer_queue(struct vb2_buffer *vb) |
@@ -616,6 +615,103 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe, | |||
616 | return 0; | 615 | return 0; |
617 | } | 616 | } |
618 | 617 | ||
618 | static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe, | ||
619 | fe_sec_voltage_t voltage) | ||
620 | { | ||
621 | struct cx23885_tsport *port = fe->dvb->priv; | ||
622 | struct cx23885_dev *dev = port->dev; | ||
623 | |||
624 | cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1); | ||
625 | |||
626 | switch (voltage) { | ||
627 | case SEC_VOLTAGE_13: | ||
628 | cx23885_gpio_set(dev, GPIO_13); | ||
629 | cx23885_gpio_clear(dev, GPIO_12); | ||
630 | break; | ||
631 | case SEC_VOLTAGE_18: | ||
632 | cx23885_gpio_set(dev, GPIO_13); | ||
633 | cx23885_gpio_set(dev, GPIO_12); | ||
634 | break; | ||
635 | case SEC_VOLTAGE_OFF: | ||
636 | cx23885_gpio_clear(dev, GPIO_13); | ||
637 | cx23885_gpio_clear(dev, GPIO_12); | ||
638 | break; | ||
639 | } | ||
640 | /* call the frontend set_voltage function */ | ||
641 | return port->fe_set_voltage(fe, voltage); | ||
642 | } | ||
643 | |||
644 | static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr, | ||
645 | u8 data, int *mem) | ||
646 | { | ||
647 | /* MC417 */ | ||
648 | #define SP2_DATA 0x000000ff | ||
649 | #define SP2_WR 0x00008000 | ||
650 | #define SP2_RD 0x00004000 | ||
651 | #define SP2_ACK 0x00001000 | ||
652 | #define SP2_ADHI 0x00000800 | ||
653 | #define SP2_ADLO 0x00000400 | ||
654 | #define SP2_CS1 0x00000200 | ||
655 | #define SP2_CS0 0x00000100 | ||
656 | #define SP2_EN_ALL 0x00001000 | ||
657 | #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD) | ||
658 | |||
659 | struct cx23885_tsport *port = priv; | ||
660 | struct cx23885_dev *dev = port->dev; | ||
661 | int ret; | ||
662 | int tmp = 0; | ||
663 | unsigned long timeout; | ||
664 | |||
665 | mutex_lock(&dev->gpio_lock); | ||
666 | |||
667 | /* write addr */ | ||
668 | cx_write(MC417_OEN, SP2_EN_ALL); | ||
669 | cx_write(MC417_RWD, SP2_CTRL_OFF | | ||
670 | SP2_ADLO | (0xff & addr)); | ||
671 | cx_clear(MC417_RWD, SP2_ADLO); | ||
672 | cx_write(MC417_RWD, SP2_CTRL_OFF | | ||
673 | SP2_ADHI | (0xff & (addr >> 8))); | ||
674 | cx_clear(MC417_RWD, SP2_ADHI); | ||
675 | |||
676 | if (read) | ||
677 | /* data in */ | ||
678 | cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA); | ||
679 | else | ||
680 | /* data out */ | ||
681 | cx_write(MC417_RWD, SP2_CTRL_OFF | data); | ||
682 | |||
683 | /* chip select 0 */ | ||
684 | cx_clear(MC417_RWD, SP2_CS0); | ||
685 | |||
686 | /* read/write */ | ||
687 | cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR); | ||
688 | |||
689 | /* wait for a maximum of 1 msec */ | ||
690 | timeout = jiffies + msecs_to_jiffies(1); | ||
691 | while (!time_after(jiffies, timeout)) { | ||
692 | tmp = cx_read(MC417_RWD); | ||
693 | if ((tmp & SP2_ACK) == 0) | ||
694 | break; | ||
695 | usleep_range(50, 100); | ||
696 | } | ||
697 | |||
698 | cx_set(MC417_RWD, SP2_CTRL_OFF); | ||
699 | *mem = tmp & 0xff; | ||
700 | |||
701 | mutex_unlock(&dev->gpio_lock); | ||
702 | |||
703 | if (!read) { | ||
704 | if (*mem < 0) { | ||
705 | ret = -EREMOTEIO; | ||
706 | goto err; | ||
707 | } | ||
708 | } | ||
709 | |||
710 | return 0; | ||
711 | err: | ||
712 | return ret; | ||
713 | } | ||
714 | |||
619 | static int cx23885_dvb_set_frontend(struct dvb_frontend *fe) | 715 | static int cx23885_dvb_set_frontend(struct dvb_frontend *fe) |
620 | { | 716 | { |
621 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; | 717 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; |
@@ -793,6 +889,32 @@ static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = { | |||
793 | .agc = 0x99, | 889 | .agc = 0x99, |
794 | }; | 890 | }; |
795 | 891 | ||
892 | static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = { | ||
893 | .i2c_addr = 0x68, | ||
894 | .clock = 27000000, | ||
895 | .i2c_wr_max = 33, | ||
896 | .clock_out = 0, | ||
897 | .ts_mode = M88DS3103_TS_CI, | ||
898 | .ts_clk = 10000, | ||
899 | .ts_clk_pol = 1, | ||
900 | .lnb_en_pol = 1, | ||
901 | .lnb_hv_pol = 0, | ||
902 | .agc = 0x99, | ||
903 | }; | ||
904 | |||
905 | static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = { | ||
906 | .i2c_addr = 0x68, | ||
907 | .clock = 27000000, | ||
908 | .i2c_wr_max = 33, | ||
909 | .clock_out = 0, | ||
910 | .ts_mode = M88DS3103_TS_SERIAL, | ||
911 | .ts_clk = 96000, | ||
912 | .ts_clk_pol = 0, | ||
913 | .lnb_en_pol = 1, | ||
914 | .lnb_hv_pol = 0, | ||
915 | .agc = 0x99, | ||
916 | }; | ||
917 | |||
796 | static int netup_altera_fpga_rw(void *device, int flag, int data, int read) | 918 | static int netup_altera_fpga_rw(void *device, int flag, int data, int read) |
797 | { | 919 | { |
798 | struct cx23885_dev *dev = (struct cx23885_dev *)device; | 920 | struct cx23885_dev *dev = (struct cx23885_dev *)device; |
@@ -944,11 +1066,13 @@ static int dvb_register(struct cx23885_tsport *port) | |||
944 | struct vb2_dvb_frontend *fe0, *fe1 = NULL; | 1066 | struct vb2_dvb_frontend *fe0, *fe1 = NULL; |
945 | struct si2168_config si2168_config; | 1067 | struct si2168_config si2168_config; |
946 | struct si2157_config si2157_config; | 1068 | struct si2157_config si2157_config; |
1069 | struct sp2_config sp2_config; | ||
947 | struct m88ts2022_config m88ts2022_config; | 1070 | struct m88ts2022_config m88ts2022_config; |
948 | struct i2c_board_info info; | 1071 | struct i2c_board_info info; |
949 | struct i2c_adapter *adapter; | 1072 | struct i2c_adapter *adapter; |
950 | struct i2c_client *client_demod; | 1073 | struct i2c_client *client_demod = NULL, *client_tuner = NULL, *client_ci = NULL; |
951 | struct i2c_client *client_tuner; | 1074 | const struct m88ds3103_config *p_m88ds3103_config = NULL; |
1075 | int (*p_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage) = NULL; | ||
952 | int mfe_shared = 0; /* bus not shared by default */ | 1076 | int mfe_shared = 0; /* bus not shared by default */ |
953 | int ret; | 1077 | int ret; |
954 | 1078 | ||
@@ -973,11 +1097,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
973 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, | 1097 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
974 | &hauppauge_generic_config, | 1098 | &hauppauge_generic_config, |
975 | &i2c_bus->i2c_adap); | 1099 | &i2c_bus->i2c_adap); |
976 | if (fe0->dvb.frontend != NULL) { | 1100 | if (fe0->dvb.frontend == NULL) |
977 | dvb_attach(mt2131_attach, fe0->dvb.frontend, | 1101 | break; |
978 | &i2c_bus->i2c_adap, | 1102 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
979 | &hauppauge_generic_tunerconfig, 0); | 1103 | &i2c_bus->i2c_adap, |
980 | } | 1104 | &hauppauge_generic_tunerconfig, 0); |
981 | break; | 1105 | break; |
982 | case CX23885_BOARD_HAUPPAUGE_HVR1270: | 1106 | case CX23885_BOARD_HAUPPAUGE_HVR1270: |
983 | case CX23885_BOARD_HAUPPAUGE_HVR1275: | 1107 | case CX23885_BOARD_HAUPPAUGE_HVR1275: |
@@ -985,11 +1109,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
985 | fe0->dvb.frontend = dvb_attach(lgdt3305_attach, | 1109 | fe0->dvb.frontend = dvb_attach(lgdt3305_attach, |
986 | &hauppauge_lgdt3305_config, | 1110 | &hauppauge_lgdt3305_config, |
987 | &i2c_bus->i2c_adap); | 1111 | &i2c_bus->i2c_adap); |
988 | if (fe0->dvb.frontend != NULL) { | 1112 | if (fe0->dvb.frontend == NULL) |
989 | dvb_attach(tda18271_attach, fe0->dvb.frontend, | 1113 | break; |
990 | 0x60, &dev->i2c_bus[1].i2c_adap, | 1114 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
991 | &hauppauge_hvr127x_config); | 1115 | 0x60, &dev->i2c_bus[1].i2c_adap, |
992 | } | 1116 | &hauppauge_hvr127x_config); |
993 | if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275) | 1117 | if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275) |
994 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); | 1118 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
995 | break; | 1119 | break; |
@@ -999,11 +1123,12 @@ static int dvb_register(struct cx23885_tsport *port) | |||
999 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, | 1123 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
1000 | &hcw_s5h1411_config, | 1124 | &hcw_s5h1411_config, |
1001 | &i2c_bus->i2c_adap); | 1125 | &i2c_bus->i2c_adap); |
1002 | if (fe0->dvb.frontend != NULL) { | 1126 | if (fe0->dvb.frontend == NULL) |
1003 | dvb_attach(tda18271_attach, fe0->dvb.frontend, | 1127 | break; |
1004 | 0x60, &dev->i2c_bus[1].i2c_adap, | 1128 | |
1005 | &hauppauge_tda18271_config); | 1129 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
1006 | } | 1130 | 0x60, &dev->i2c_bus[1].i2c_adap, |
1131 | &hauppauge_tda18271_config); | ||
1007 | 1132 | ||
1008 | tda18271_attach(&dev->ts1.analog_fe, | 1133 | tda18271_attach(&dev->ts1.analog_fe, |
1009 | 0x60, &dev->i2c_bus[1].i2c_adap, | 1134 | 0x60, &dev->i2c_bus[1].i2c_adap, |
@@ -1018,14 +1143,15 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1018 | dvb_attach(s5h1409_attach, | 1143 | dvb_attach(s5h1409_attach, |
1019 | &hauppauge_ezqam_config, | 1144 | &hauppauge_ezqam_config, |
1020 | &i2c_bus->i2c_adap); | 1145 | &i2c_bus->i2c_adap); |
1021 | if (fe0->dvb.frontend != NULL) { | 1146 | if (fe0->dvb.frontend == NULL) |
1022 | dvb_attach(tda829x_attach, fe0->dvb.frontend, | 1147 | break; |
1023 | &dev->i2c_bus[1].i2c_adap, 0x42, | 1148 | |
1024 | &tda829x_no_probe); | 1149 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
1025 | dvb_attach(tda18271_attach, fe0->dvb.frontend, | 1150 | &dev->i2c_bus[1].i2c_adap, 0x42, |
1026 | 0x60, &dev->i2c_bus[1].i2c_adap, | 1151 | &tda829x_no_probe); |
1027 | &hauppauge_tda18271_config); | 1152 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
1028 | } | 1153 | 0x60, &dev->i2c_bus[1].i2c_adap, |
1154 | &hauppauge_tda18271_config); | ||
1029 | break; | 1155 | break; |
1030 | case 0: | 1156 | case 0: |
1031 | default: | 1157 | default: |
@@ -1033,11 +1159,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1033 | dvb_attach(s5h1409_attach, | 1159 | dvb_attach(s5h1409_attach, |
1034 | &hauppauge_generic_config, | 1160 | &hauppauge_generic_config, |
1035 | &i2c_bus->i2c_adap); | 1161 | &i2c_bus->i2c_adap); |
1036 | if (fe0->dvb.frontend != NULL) | 1162 | if (fe0->dvb.frontend == NULL) |
1037 | dvb_attach(mt2131_attach, fe0->dvb.frontend, | 1163 | break; |
1038 | &i2c_bus->i2c_adap, | 1164 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
1039 | &hauppauge_generic_tunerconfig, 0); | 1165 | &i2c_bus->i2c_adap, |
1040 | break; | 1166 | &hauppauge_generic_tunerconfig, 0); |
1041 | } | 1167 | } |
1042 | break; | 1168 | break; |
1043 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: | 1169 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
@@ -1045,32 +1171,33 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1045 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, | 1171 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
1046 | &hauppauge_hvr1800lp_config, | 1172 | &hauppauge_hvr1800lp_config, |
1047 | &i2c_bus->i2c_adap); | 1173 | &i2c_bus->i2c_adap); |
1048 | if (fe0->dvb.frontend != NULL) { | 1174 | if (fe0->dvb.frontend == NULL) |
1049 | dvb_attach(mt2131_attach, fe0->dvb.frontend, | 1175 | break; |
1050 | &i2c_bus->i2c_adap, | 1176 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
1051 | &hauppauge_generic_tunerconfig, 0); | 1177 | &i2c_bus->i2c_adap, |
1052 | } | 1178 | &hauppauge_generic_tunerconfig, 0); |
1053 | break; | 1179 | break; |
1054 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: | 1180 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: |
1055 | i2c_bus = &dev->i2c_bus[0]; | 1181 | i2c_bus = &dev->i2c_bus[0]; |
1056 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, | 1182 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
1057 | &fusionhdtv_5_express, | 1183 | &fusionhdtv_5_express, |
1058 | &i2c_bus->i2c_adap); | 1184 | &i2c_bus->i2c_adap); |
1059 | if (fe0->dvb.frontend != NULL) { | 1185 | if (fe0->dvb.frontend == NULL) |
1060 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, | 1186 | break; |
1061 | &i2c_bus->i2c_adap, 0x61, | 1187 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
1062 | TUNER_LG_TDVS_H06XF); | 1188 | &i2c_bus->i2c_adap, 0x61, |
1063 | } | 1189 | TUNER_LG_TDVS_H06XF); |
1064 | break; | 1190 | break; |
1065 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 1191 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
1066 | i2c_bus = &dev->i2c_bus[1]; | 1192 | i2c_bus = &dev->i2c_bus[1]; |
1067 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, | 1193 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
1068 | &hauppauge_hvr1500q_config, | 1194 | &hauppauge_hvr1500q_config, |
1069 | &dev->i2c_bus[0].i2c_adap); | 1195 | &dev->i2c_bus[0].i2c_adap); |
1070 | if (fe0->dvb.frontend != NULL) | 1196 | if (fe0->dvb.frontend == NULL) |
1071 | dvb_attach(xc5000_attach, fe0->dvb.frontend, | 1197 | break; |
1072 | &i2c_bus->i2c_adap, | 1198 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
1073 | &hauppauge_hvr1500q_tunerconfig); | 1199 | &i2c_bus->i2c_adap, |
1200 | &hauppauge_hvr1500q_tunerconfig); | ||
1074 | break; | 1201 | break; |
1075 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 1202 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
1076 | i2c_bus = &dev->i2c_bus[1]; | 1203 | i2c_bus = &dev->i2c_bus[1]; |
@@ -1101,14 +1228,14 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1101 | fe0->dvb.frontend = dvb_attach(tda10048_attach, | 1228 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
1102 | &hauppauge_hvr1200_config, | 1229 | &hauppauge_hvr1200_config, |
1103 | &i2c_bus->i2c_adap); | 1230 | &i2c_bus->i2c_adap); |
1104 | if (fe0->dvb.frontend != NULL) { | 1231 | if (fe0->dvb.frontend == NULL) |
1105 | dvb_attach(tda829x_attach, fe0->dvb.frontend, | 1232 | break; |
1106 | &dev->i2c_bus[1].i2c_adap, 0x42, | 1233 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
1107 | &tda829x_no_probe); | 1234 | &dev->i2c_bus[1].i2c_adap, 0x42, |
1108 | dvb_attach(tda18271_attach, fe0->dvb.frontend, | 1235 | &tda829x_no_probe); |
1109 | 0x60, &dev->i2c_bus[1].i2c_adap, | 1236 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
1110 | &hauppauge_hvr1200_tuner_config); | 1237 | 0x60, &dev->i2c_bus[1].i2c_adap, |
1111 | } | 1238 | &hauppauge_hvr1200_tuner_config); |
1112 | break; | 1239 | break; |
1113 | case CX23885_BOARD_HAUPPAUGE_HVR1210: | 1240 | case CX23885_BOARD_HAUPPAUGE_HVR1210: |
1114 | i2c_bus = &dev->i2c_bus[0]; | 1241 | i2c_bus = &dev->i2c_bus[0]; |
@@ -1367,12 +1494,10 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1367 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, | 1494 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, |
1368 | &mygica_x8506_lgs8gl5_config, | 1495 | &mygica_x8506_lgs8gl5_config, |
1369 | &i2c_bus->i2c_adap); | 1496 | &i2c_bus->i2c_adap); |
1370 | if (fe0->dvb.frontend != NULL) { | 1497 | if (fe0->dvb.frontend == NULL) |
1371 | dvb_attach(xc5000_attach, | 1498 | break; |
1372 | fe0->dvb.frontend, | 1499 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
1373 | &i2c_bus2->i2c_adap, | 1500 | &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config); |
1374 | &mygica_x8506_xc5000_config); | ||
1375 | } | ||
1376 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); | 1501 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
1377 | break; | 1502 | break; |
1378 | case CX23885_BOARD_MYGICA_X8507: | 1503 | case CX23885_BOARD_MYGICA_X8507: |
@@ -1381,12 +1506,12 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1381 | fe0->dvb.frontend = dvb_attach(mb86a20s_attach, | 1506 | fe0->dvb.frontend = dvb_attach(mb86a20s_attach, |
1382 | &mygica_x8507_mb86a20s_config, | 1507 | &mygica_x8507_mb86a20s_config, |
1383 | &i2c_bus->i2c_adap); | 1508 | &i2c_bus->i2c_adap); |
1384 | if (fe0->dvb.frontend != NULL) { | 1509 | if (fe0->dvb.frontend == NULL) |
1385 | dvb_attach(xc5000_attach, | 1510 | break; |
1386 | fe0->dvb.frontend, | 1511 | |
1387 | &i2c_bus2->i2c_adap, | 1512 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
1388 | &mygica_x8507_xc5000_config); | 1513 | &i2c_bus2->i2c_adap, |
1389 | } | 1514 | &mygica_x8507_xc5000_config); |
1390 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); | 1515 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
1391 | break; | 1516 | break; |
1392 | case CX23885_BOARD_MAGICPRO_PROHDTVE2: | 1517 | case CX23885_BOARD_MAGICPRO_PROHDTVE2: |
@@ -1395,12 +1520,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1395 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, | 1520 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, |
1396 | &magicpro_prohdtve2_lgs8g75_config, | 1521 | &magicpro_prohdtve2_lgs8g75_config, |
1397 | &i2c_bus->i2c_adap); | 1522 | &i2c_bus->i2c_adap); |
1398 | if (fe0->dvb.frontend != NULL) { | 1523 | if (fe0->dvb.frontend == NULL) |
1399 | dvb_attach(xc5000_attach, | 1524 | break; |
1400 | fe0->dvb.frontend, | 1525 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
1401 | &i2c_bus2->i2c_adap, | 1526 | &i2c_bus2->i2c_adap, |
1402 | &magicpro_prohdtve2_xc5000_config); | 1527 | &magicpro_prohdtve2_xc5000_config); |
1403 | } | ||
1404 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); | 1528 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
1405 | break; | 1529 | break; |
1406 | case CX23885_BOARD_HAUPPAUGE_HVR1850: | 1530 | case CX23885_BOARD_HAUPPAUGE_HVR1850: |
@@ -1408,10 +1532,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1408 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, | 1532 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
1409 | &hcw_s5h1411_config, | 1533 | &hcw_s5h1411_config, |
1410 | &i2c_bus->i2c_adap); | 1534 | &i2c_bus->i2c_adap); |
1411 | if (fe0->dvb.frontend != NULL) | 1535 | if (fe0->dvb.frontend == NULL) |
1412 | dvb_attach(tda18271_attach, fe0->dvb.frontend, | 1536 | break; |
1413 | 0x60, &dev->i2c_bus[0].i2c_adap, | 1537 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
1414 | &hauppauge_tda18271_config); | 1538 | 0x60, &dev->i2c_bus[0].i2c_adap, |
1539 | &hauppauge_tda18271_config); | ||
1415 | 1540 | ||
1416 | tda18271_attach(&dev->ts1.analog_fe, | 1541 | tda18271_attach(&dev->ts1.analog_fe, |
1417 | 0x60, &dev->i2c_bus[1].i2c_adap, | 1542 | 0x60, &dev->i2c_bus[1].i2c_adap, |
@@ -1423,10 +1548,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1423 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, | 1548 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
1424 | &hcw_s5h1411_config, | 1549 | &hcw_s5h1411_config, |
1425 | &i2c_bus->i2c_adap); | 1550 | &i2c_bus->i2c_adap); |
1426 | if (fe0->dvb.frontend != NULL) | 1551 | if (fe0->dvb.frontend == NULL) |
1427 | dvb_attach(tda18271_attach, fe0->dvb.frontend, | 1552 | break; |
1428 | 0x60, &dev->i2c_bus[0].i2c_adap, | 1553 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
1429 | &hauppauge_tda18271_config); | 1554 | 0x60, &dev->i2c_bus[0].i2c_adap, |
1555 | &hauppauge_tda18271_config); | ||
1430 | break; | 1556 | break; |
1431 | case CX23885_BOARD_MYGICA_X8558PRO: | 1557 | case CX23885_BOARD_MYGICA_X8558PRO: |
1432 | switch (port->nr) { | 1558 | switch (port->nr) { |
@@ -1436,12 +1562,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1436 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, | 1562 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, |
1437 | &mygica_x8558pro_atbm8830_cfg1, | 1563 | &mygica_x8558pro_atbm8830_cfg1, |
1438 | &i2c_bus->i2c_adap); | 1564 | &i2c_bus->i2c_adap); |
1439 | if (fe0->dvb.frontend != NULL) { | 1565 | if (fe0->dvb.frontend == NULL) |
1440 | dvb_attach(max2165_attach, | 1566 | break; |
1441 | fe0->dvb.frontend, | 1567 | dvb_attach(max2165_attach, fe0->dvb.frontend, |
1442 | &i2c_bus->i2c_adap, | 1568 | &i2c_bus->i2c_adap, |
1443 | &mygic_x8558pro_max2165_cfg1); | 1569 | &mygic_x8558pro_max2165_cfg1); |
1444 | } | ||
1445 | break; | 1570 | break; |
1446 | /* port C */ | 1571 | /* port C */ |
1447 | case 2: | 1572 | case 2: |
@@ -1449,13 +1574,11 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1449 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, | 1574 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, |
1450 | &mygica_x8558pro_atbm8830_cfg2, | 1575 | &mygica_x8558pro_atbm8830_cfg2, |
1451 | &i2c_bus->i2c_adap); | 1576 | &i2c_bus->i2c_adap); |
1452 | if (fe0->dvb.frontend != NULL) { | 1577 | if (fe0->dvb.frontend == NULL) |
1453 | dvb_attach(max2165_attach, | 1578 | break; |
1454 | fe0->dvb.frontend, | 1579 | dvb_attach(max2165_attach, fe0->dvb.frontend, |
1455 | &i2c_bus->i2c_adap, | 1580 | &i2c_bus->i2c_adap, |
1456 | &mygic_x8558pro_max2165_cfg2); | 1581 | &mygic_x8558pro_max2165_cfg2); |
1457 | } | ||
1458 | break; | ||
1459 | } | 1582 | } |
1460 | break; | 1583 | break; |
1461 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: | 1584 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: |
@@ -1467,15 +1590,15 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1467 | fe0->dvb.frontend = dvb_attach(stv0367ter_attach, | 1590 | fe0->dvb.frontend = dvb_attach(stv0367ter_attach, |
1468 | &netup_stv0367_config[port->nr - 1], | 1591 | &netup_stv0367_config[port->nr - 1], |
1469 | &i2c_bus->i2c_adap); | 1592 | &i2c_bus->i2c_adap); |
1470 | if (fe0->dvb.frontend != NULL) { | 1593 | if (fe0->dvb.frontend == NULL) |
1471 | if (NULL == dvb_attach(xc5000_attach, | 1594 | break; |
1472 | fe0->dvb.frontend, | 1595 | if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend, |
1473 | &i2c_bus->i2c_adap, | 1596 | &i2c_bus->i2c_adap, |
1474 | &netup_xc5000_config[port->nr - 1])) | 1597 | &netup_xc5000_config[port->nr - 1])) |
1475 | goto frontend_detach; | 1598 | goto frontend_detach; |
1476 | /* load xc5000 firmware */ | 1599 | /* load xc5000 firmware */ |
1477 | fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend); | 1600 | fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend); |
1478 | } | 1601 | |
1479 | /* MFE frontend 2 */ | 1602 | /* MFE frontend 2 */ |
1480 | fe1 = vb2_dvb_get_frontend(&port->frontends, 2); | 1603 | fe1 = vb2_dvb_get_frontend(&port->frontends, 2); |
1481 | if (fe1 == NULL) | 1604 | if (fe1 == NULL) |
@@ -1484,14 +1607,15 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1484 | fe1->dvb.frontend = dvb_attach(stv0367cab_attach, | 1607 | fe1->dvb.frontend = dvb_attach(stv0367cab_attach, |
1485 | &netup_stv0367_config[port->nr - 1], | 1608 | &netup_stv0367_config[port->nr - 1], |
1486 | &i2c_bus->i2c_adap); | 1609 | &i2c_bus->i2c_adap); |
1487 | if (fe1->dvb.frontend != NULL) { | 1610 | if (fe1->dvb.frontend == NULL) |
1488 | fe1->dvb.frontend->id = 1; | 1611 | break; |
1489 | if (NULL == dvb_attach(xc5000_attach, | 1612 | |
1490 | fe1->dvb.frontend, | 1613 | fe1->dvb.frontend->id = 1; |
1491 | &i2c_bus->i2c_adap, | 1614 | if (NULL == dvb_attach(xc5000_attach, |
1492 | &netup_xc5000_config[port->nr - 1])) | 1615 | fe1->dvb.frontend, |
1493 | goto frontend_detach; | 1616 | &i2c_bus->i2c_adap, |
1494 | } | 1617 | &netup_xc5000_config[port->nr - 1])) |
1618 | goto frontend_detach; | ||
1495 | break; | 1619 | break; |
1496 | case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: | 1620 | case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: |
1497 | i2c_bus = &dev->i2c_bus[0]; | 1621 | i2c_bus = &dev->i2c_bus[0]; |
@@ -1503,26 +1627,26 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1503 | fe0->dvb.frontend = dvb_attach(drxk_attach, | 1627 | fe0->dvb.frontend = dvb_attach(drxk_attach, |
1504 | &terratec_drxk_config[0], | 1628 | &terratec_drxk_config[0], |
1505 | &i2c_bus->i2c_adap); | 1629 | &i2c_bus->i2c_adap); |
1506 | if (fe0->dvb.frontend != NULL) { | 1630 | if (fe0->dvb.frontend == NULL) |
1507 | if (!dvb_attach(mt2063_attach, | 1631 | break; |
1508 | fe0->dvb.frontend, | 1632 | if (!dvb_attach(mt2063_attach, |
1509 | &terratec_mt2063_config[0], | 1633 | fe0->dvb.frontend, |
1510 | &i2c_bus2->i2c_adap)) | 1634 | &terratec_mt2063_config[0], |
1511 | goto frontend_detach; | 1635 | &i2c_bus2->i2c_adap)) |
1512 | } | 1636 | goto frontend_detach; |
1513 | break; | 1637 | break; |
1514 | /* port c */ | 1638 | /* port c */ |
1515 | case 2: | 1639 | case 2: |
1516 | fe0->dvb.frontend = dvb_attach(drxk_attach, | 1640 | fe0->dvb.frontend = dvb_attach(drxk_attach, |
1517 | &terratec_drxk_config[1], | 1641 | &terratec_drxk_config[1], |
1518 | &i2c_bus->i2c_adap); | 1642 | &i2c_bus->i2c_adap); |
1519 | if (fe0->dvb.frontend != NULL) { | 1643 | if (fe0->dvb.frontend == NULL) |
1520 | if (!dvb_attach(mt2063_attach, | 1644 | break; |
1521 | fe0->dvb.frontend, | 1645 | if (!dvb_attach(mt2063_attach, |
1522 | &terratec_mt2063_config[1], | 1646 | fe0->dvb.frontend, |
1523 | &i2c_bus2->i2c_adap)) | 1647 | &terratec_mt2063_config[1], |
1524 | goto frontend_detach; | 1648 | &i2c_bus2->i2c_adap)) |
1525 | } | 1649 | goto frontend_detach; |
1526 | break; | 1650 | break; |
1527 | } | 1651 | } |
1528 | break; | 1652 | break; |
@@ -1532,10 +1656,10 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1532 | fe0->dvb.frontend = dvb_attach(ds3000_attach, | 1656 | fe0->dvb.frontend = dvb_attach(ds3000_attach, |
1533 | &tevii_ds3000_config, | 1657 | &tevii_ds3000_config, |
1534 | &i2c_bus->i2c_adap); | 1658 | &i2c_bus->i2c_adap); |
1535 | if (fe0->dvb.frontend != NULL) { | 1659 | if (fe0->dvb.frontend == NULL) |
1536 | dvb_attach(ts2020_attach, fe0->dvb.frontend, | 1660 | break; |
1537 | &tevii_ts2020_config, &i2c_bus->i2c_adap); | 1661 | dvb_attach(ts2020_attach, fe0->dvb.frontend, |
1538 | } | 1662 | &tevii_ts2020_config, &i2c_bus->i2c_adap); |
1539 | break; | 1663 | break; |
1540 | case CX23885_BOARD_PROF_8000: | 1664 | case CX23885_BOARD_PROF_8000: |
1541 | i2c_bus = &dev->i2c_bus[0]; | 1665 | i2c_bus = &dev->i2c_bus[0]; |
@@ -1544,15 +1668,15 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1544 | &prof_8000_stv090x_config, | 1668 | &prof_8000_stv090x_config, |
1545 | &i2c_bus->i2c_adap, | 1669 | &i2c_bus->i2c_adap, |
1546 | STV090x_DEMODULATOR_0); | 1670 | STV090x_DEMODULATOR_0); |
1547 | if (fe0->dvb.frontend != NULL) { | 1671 | if (fe0->dvb.frontend == NULL) |
1548 | if (!dvb_attach(stb6100_attach, | 1672 | break; |
1549 | fe0->dvb.frontend, | 1673 | if (!dvb_attach(stb6100_attach, |
1550 | &prof_8000_stb6100_config, | 1674 | fe0->dvb.frontend, |
1551 | &i2c_bus->i2c_adap)) | 1675 | &prof_8000_stb6100_config, |
1552 | goto frontend_detach; | 1676 | &i2c_bus->i2c_adap)) |
1677 | goto frontend_detach; | ||
1553 | 1678 | ||
1554 | fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage; | 1679 | fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage; |
1555 | } | ||
1556 | break; | 1680 | break; |
1557 | case CX23885_BOARD_HAUPPAUGE_HVR4400: | 1681 | case CX23885_BOARD_HAUPPAUGE_HVR4400: |
1558 | i2c_bus = &dev->i2c_bus[0]; | 1682 | i2c_bus = &dev->i2c_bus[0]; |
@@ -1563,30 +1687,31 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1563 | fe0->dvb.frontend = dvb_attach(tda10071_attach, | 1687 | fe0->dvb.frontend = dvb_attach(tda10071_attach, |
1564 | &hauppauge_tda10071_config, | 1688 | &hauppauge_tda10071_config, |
1565 | &i2c_bus->i2c_adap); | 1689 | &i2c_bus->i2c_adap); |
1566 | if (fe0->dvb.frontend != NULL) { | 1690 | if (fe0->dvb.frontend == NULL) |
1567 | if (!dvb_attach(a8293_attach, fe0->dvb.frontend, | 1691 | break; |
1568 | &i2c_bus->i2c_adap, | 1692 | if (!dvb_attach(a8293_attach, fe0->dvb.frontend, |
1569 | &hauppauge_a8293_config)) | 1693 | &i2c_bus->i2c_adap, |
1570 | goto frontend_detach; | 1694 | &hauppauge_a8293_config)) |
1571 | } | 1695 | goto frontend_detach; |
1572 | break; | 1696 | break; |
1573 | /* port c */ | 1697 | /* port c */ |
1574 | case 2: | 1698 | case 2: |
1575 | fe0->dvb.frontend = dvb_attach(si2165_attach, | 1699 | fe0->dvb.frontend = dvb_attach(si2165_attach, |
1576 | &hauppauge_hvr4400_si2165_config, | 1700 | &hauppauge_hvr4400_si2165_config, |
1577 | &i2c_bus->i2c_adap); | 1701 | &i2c_bus->i2c_adap); |
1578 | if (fe0->dvb.frontend != NULL) { | 1702 | if (fe0->dvb.frontend == NULL) |
1579 | fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; | 1703 | break; |
1580 | if (!dvb_attach(tda18271_attach, | 1704 | fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; |
1581 | fe0->dvb.frontend, | 1705 | if (!dvb_attach(tda18271_attach, |
1582 | 0x60, &i2c_bus2->i2c_adap, | 1706 | fe0->dvb.frontend, |
1583 | &hauppauge_hvr4400_tuner_config)) | 1707 | 0x60, &i2c_bus2->i2c_adap, |
1584 | goto frontend_detach; | 1708 | &hauppauge_hvr4400_tuner_config)) |
1585 | } | 1709 | goto frontend_detach; |
1586 | break; | 1710 | break; |
1587 | } | 1711 | } |
1588 | break; | 1712 | break; |
1589 | case CX23885_BOARD_DVBSKY_T9580: | 1713 | case CX23885_BOARD_DVBSKY_T9580: |
1714 | case CX23885_BOARD_DVBSKY_S950: | ||
1590 | i2c_bus = &dev->i2c_bus[0]; | 1715 | i2c_bus = &dev->i2c_bus[0]; |
1591 | i2c_bus2 = &dev->i2c_bus[1]; | 1716 | i2c_bus2 = &dev->i2c_bus[1]; |
1592 | switch (port->nr) { | 1717 | switch (port->nr) { |
@@ -1680,6 +1805,201 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1680 | break; | 1805 | break; |
1681 | } | 1806 | } |
1682 | break; | 1807 | break; |
1808 | case CX23885_BOARD_DVBSKY_T980C: | ||
1809 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
1810 | i2c_bus = &dev->i2c_bus[1]; | ||
1811 | i2c_bus2 = &dev->i2c_bus[0]; | ||
1812 | |||
1813 | /* attach frontend */ | ||
1814 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
1815 | si2168_config.i2c_adapter = &adapter; | ||
1816 | si2168_config.fe = &fe0->dvb.frontend; | ||
1817 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | ||
1818 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1819 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); | ||
1820 | info.addr = 0x64; | ||
1821 | info.platform_data = &si2168_config; | ||
1822 | request_module(info.type); | ||
1823 | client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); | ||
1824 | if (client_demod == NULL || | ||
1825 | client_demod->dev.driver == NULL) | ||
1826 | goto frontend_detach; | ||
1827 | if (!try_module_get(client_demod->dev.driver->owner)) { | ||
1828 | i2c_unregister_device(client_demod); | ||
1829 | goto frontend_detach; | ||
1830 | } | ||
1831 | port->i2c_client_demod = client_demod; | ||
1832 | |||
1833 | /* attach tuner */ | ||
1834 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
1835 | si2157_config.fe = fe0->dvb.frontend; | ||
1836 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1837 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); | ||
1838 | info.addr = 0x60; | ||
1839 | info.platform_data = &si2157_config; | ||
1840 | request_module(info.type); | ||
1841 | client_tuner = i2c_new_device(adapter, &info); | ||
1842 | if (client_tuner == NULL || | ||
1843 | client_tuner->dev.driver == NULL) { | ||
1844 | module_put(client_demod->dev.driver->owner); | ||
1845 | i2c_unregister_device(client_demod); | ||
1846 | goto frontend_detach; | ||
1847 | } | ||
1848 | if (!try_module_get(client_tuner->dev.driver->owner)) { | ||
1849 | i2c_unregister_device(client_tuner); | ||
1850 | module_put(client_demod->dev.driver->owner); | ||
1851 | i2c_unregister_device(client_demod); | ||
1852 | goto frontend_detach; | ||
1853 | } | ||
1854 | port->i2c_client_tuner = client_tuner; | ||
1855 | break; | ||
1856 | case CX23885_BOARD_DVBSKY_S950C: | ||
1857 | i2c_bus = &dev->i2c_bus[1]; | ||
1858 | i2c_bus2 = &dev->i2c_bus[0]; | ||
1859 | |||
1860 | /* attach frontend */ | ||
1861 | fe0->dvb.frontend = dvb_attach(m88ds3103_attach, | ||
1862 | &dvbsky_s950c_m88ds3103_config, | ||
1863 | &i2c_bus->i2c_adap, &adapter); | ||
1864 | if (fe0->dvb.frontend == NULL) | ||
1865 | break; | ||
1866 | |||
1867 | /* attach tuner */ | ||
1868 | memset(&m88ts2022_config, 0, sizeof(m88ts2022_config)); | ||
1869 | m88ts2022_config.fe = fe0->dvb.frontend; | ||
1870 | m88ts2022_config.clock = 27000000; | ||
1871 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1872 | strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE); | ||
1873 | info.addr = 0x60; | ||
1874 | info.platform_data = &m88ts2022_config; | ||
1875 | request_module(info.type); | ||
1876 | client_tuner = i2c_new_device(adapter, &info); | ||
1877 | if (client_tuner == NULL || | ||
1878 | client_tuner->dev.driver == NULL) | ||
1879 | goto frontend_detach; | ||
1880 | if (!try_module_get(client_tuner->dev.driver->owner)) { | ||
1881 | i2c_unregister_device(client_tuner); | ||
1882 | goto frontend_detach; | ||
1883 | } | ||
1884 | |||
1885 | /* delegate signal strength measurement to tuner */ | ||
1886 | fe0->dvb.frontend->ops.read_signal_strength = | ||
1887 | fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; | ||
1888 | |||
1889 | port->i2c_client_tuner = client_tuner; | ||
1890 | break; | ||
1891 | case CX23885_BOARD_DVBSKY_S952: | ||
1892 | switch (port->nr) { | ||
1893 | /* port b */ | ||
1894 | case 1: | ||
1895 | i2c_bus = &dev->i2c_bus[1]; | ||
1896 | p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config; | ||
1897 | p_set_voltage = dvbsky_t9580_set_voltage; | ||
1898 | break; | ||
1899 | /* port c */ | ||
1900 | case 2: | ||
1901 | i2c_bus = &dev->i2c_bus[0]; | ||
1902 | p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config; | ||
1903 | p_set_voltage = dvbsky_s952_portc_set_voltage; | ||
1904 | break; | ||
1905 | } | ||
1906 | |||
1907 | /* attach frontend */ | ||
1908 | fe0->dvb.frontend = dvb_attach(m88ds3103_attach, | ||
1909 | p_m88ds3103_config, | ||
1910 | &i2c_bus->i2c_adap, &adapter); | ||
1911 | if (fe0->dvb.frontend == NULL) | ||
1912 | break; | ||
1913 | |||
1914 | /* attach tuner */ | ||
1915 | memset(&m88ts2022_config, 0, sizeof(m88ts2022_config)); | ||
1916 | m88ts2022_config.fe = fe0->dvb.frontend; | ||
1917 | m88ts2022_config.clock = 27000000; | ||
1918 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1919 | strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE); | ||
1920 | info.addr = 0x60; | ||
1921 | info.platform_data = &m88ts2022_config; | ||
1922 | request_module(info.type); | ||
1923 | client_tuner = i2c_new_device(adapter, &info); | ||
1924 | if (client_tuner == NULL || | ||
1925 | client_tuner->dev.driver == NULL) | ||
1926 | goto frontend_detach; | ||
1927 | if (!try_module_get(client_tuner->dev.driver->owner)) { | ||
1928 | i2c_unregister_device(client_tuner); | ||
1929 | goto frontend_detach; | ||
1930 | } | ||
1931 | |||
1932 | /* delegate signal strength measurement to tuner */ | ||
1933 | fe0->dvb.frontend->ops.read_signal_strength = | ||
1934 | fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; | ||
1935 | |||
1936 | /* | ||
1937 | * for setting the voltage we need to set GPIOs on | ||
1938 | * the card. | ||
1939 | */ | ||
1940 | port->fe_set_voltage = | ||
1941 | fe0->dvb.frontend->ops.set_voltage; | ||
1942 | fe0->dvb.frontend->ops.set_voltage = p_set_voltage; | ||
1943 | |||
1944 | port->i2c_client_tuner = client_tuner; | ||
1945 | break; | ||
1946 | case CX23885_BOARD_DVBSKY_T982: | ||
1947 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
1948 | switch (port->nr) { | ||
1949 | /* port b */ | ||
1950 | case 1: | ||
1951 | i2c_bus = &dev->i2c_bus[1]; | ||
1952 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | ||
1953 | break; | ||
1954 | /* port c */ | ||
1955 | case 2: | ||
1956 | i2c_bus = &dev->i2c_bus[0]; | ||
1957 | si2168_config.ts_mode = SI2168_TS_SERIAL; | ||
1958 | break; | ||
1959 | } | ||
1960 | |||
1961 | /* attach frontend */ | ||
1962 | si2168_config.i2c_adapter = &adapter; | ||
1963 | si2168_config.fe = &fe0->dvb.frontend; | ||
1964 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1965 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); | ||
1966 | info.addr = 0x64; | ||
1967 | info.platform_data = &si2168_config; | ||
1968 | request_module(info.type); | ||
1969 | client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); | ||
1970 | if (client_demod == NULL || | ||
1971 | client_demod->dev.driver == NULL) | ||
1972 | goto frontend_detach; | ||
1973 | if (!try_module_get(client_demod->dev.driver->owner)) { | ||
1974 | i2c_unregister_device(client_demod); | ||
1975 | goto frontend_detach; | ||
1976 | } | ||
1977 | port->i2c_client_demod = client_demod; | ||
1978 | |||
1979 | /* attach tuner */ | ||
1980 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
1981 | si2157_config.fe = fe0->dvb.frontend; | ||
1982 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1983 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); | ||
1984 | info.addr = 0x60; | ||
1985 | info.platform_data = &si2157_config; | ||
1986 | request_module(info.type); | ||
1987 | client_tuner = i2c_new_device(adapter, &info); | ||
1988 | if (client_tuner == NULL || | ||
1989 | client_tuner->dev.driver == NULL) { | ||
1990 | module_put(client_demod->dev.driver->owner); | ||
1991 | i2c_unregister_device(client_demod); | ||
1992 | goto frontend_detach; | ||
1993 | } | ||
1994 | if (!try_module_get(client_tuner->dev.driver->owner)) { | ||
1995 | i2c_unregister_device(client_tuner); | ||
1996 | module_put(client_demod->dev.driver->owner); | ||
1997 | i2c_unregister_device(client_demod); | ||
1998 | port->i2c_client_demod = NULL; | ||
1999 | goto frontend_detach; | ||
2000 | } | ||
2001 | port->i2c_client_tuner = client_tuner; | ||
2002 | break; | ||
1683 | default: | 2003 | default: |
1684 | printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " | 2004 | printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " |
1685 | " isn't supported yet\n", | 2005 | " isn't supported yet\n", |
@@ -1754,7 +2074,10 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1754 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); | 2074 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); |
1755 | break; | 2075 | break; |
1756 | } | 2076 | } |
1757 | case CX23885_BOARD_DVBSKY_T9580: { | 2077 | case CX23885_BOARD_DVBSKY_T9580: |
2078 | case CX23885_BOARD_DVBSKY_S950: | ||
2079 | case CX23885_BOARD_DVBSKY_S952: | ||
2080 | case CX23885_BOARD_DVBSKY_T982: { | ||
1758 | u8 eeprom[256]; /* 24C02 i2c eeprom */ | 2081 | u8 eeprom[256]; /* 24C02 i2c eeprom */ |
1759 | 2082 | ||
1760 | if (port->nr > 2) | 2083 | if (port->nr > 2) |
@@ -1764,12 +2087,67 @@ static int dvb_register(struct cx23885_tsport *port) | |||
1764 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; | 2087 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; |
1765 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, | 2088 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, |
1766 | sizeof(eeprom)); | 2089 | sizeof(eeprom)); |
1767 | printk(KERN_INFO "DVBSky T9580 port %d MAC address: %pM\n", | 2090 | printk(KERN_INFO "%s port %d MAC address: %pM\n", |
1768 | port->nr, eeprom + 0xc0 + (port->nr-1) * 8); | 2091 | cx23885_boards[dev->board].name, port->nr, |
2092 | eeprom + 0xc0 + (port->nr-1) * 8); | ||
1769 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + | 2093 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + |
1770 | (port->nr-1) * 8, 6); | 2094 | (port->nr-1) * 8, 6); |
1771 | break; | 2095 | break; |
1772 | } | 2096 | } |
2097 | case CX23885_BOARD_DVBSKY_S950C: | ||
2098 | case CX23885_BOARD_DVBSKY_T980C: | ||
2099 | case CX23885_BOARD_TT_CT2_4500_CI: { | ||
2100 | u8 eeprom[256]; /* 24C02 i2c eeprom */ | ||
2101 | |||
2102 | /* attach CI */ | ||
2103 | memset(&sp2_config, 0, sizeof(sp2_config)); | ||
2104 | sp2_config.dvb_adap = &port->frontends.adapter; | ||
2105 | sp2_config.priv = port; | ||
2106 | sp2_config.ci_control = cx23885_sp2_ci_ctrl; | ||
2107 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
2108 | strlcpy(info.type, "sp2", I2C_NAME_SIZE); | ||
2109 | info.addr = 0x40; | ||
2110 | info.platform_data = &sp2_config; | ||
2111 | request_module(info.type); | ||
2112 | client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info); | ||
2113 | if (client_ci == NULL || | ||
2114 | client_ci->dev.driver == NULL) { | ||
2115 | if (client_tuner) { | ||
2116 | module_put(client_tuner->dev.driver->owner); | ||
2117 | i2c_unregister_device(client_tuner); | ||
2118 | } | ||
2119 | if (client_demod) { | ||
2120 | module_put(client_demod->dev.driver->owner); | ||
2121 | i2c_unregister_device(client_demod); | ||
2122 | } | ||
2123 | goto frontend_detach; | ||
2124 | } | ||
2125 | if (!try_module_get(client_ci->dev.driver->owner)) { | ||
2126 | i2c_unregister_device(client_ci); | ||
2127 | if (client_tuner) { | ||
2128 | module_put(client_tuner->dev.driver->owner); | ||
2129 | i2c_unregister_device(client_tuner); | ||
2130 | } | ||
2131 | if (client_demod) { | ||
2132 | module_put(client_demod->dev.driver->owner); | ||
2133 | i2c_unregister_device(client_demod); | ||
2134 | } | ||
2135 | goto frontend_detach; | ||
2136 | } | ||
2137 | port->i2c_client_ci = client_ci; | ||
2138 | |||
2139 | if (port->nr != 1) | ||
2140 | break; | ||
2141 | |||
2142 | /* Read entire EEPROM */ | ||
2143 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; | ||
2144 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, | ||
2145 | sizeof(eeprom)); | ||
2146 | printk(KERN_INFO "%s MAC address: %pM\n", | ||
2147 | cx23885_boards[dev->board].name, eeprom + 0xc0); | ||
2148 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6); | ||
2149 | break; | ||
2150 | } | ||
1773 | } | 2151 | } |
1774 | 2152 | ||
1775 | return ret; | 2153 | return ret; |
@@ -1810,7 +2188,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port) | |||
1810 | 2188 | ||
1811 | fe0 = vb2_dvb_get_frontend(&port->frontends, i); | 2189 | fe0 = vb2_dvb_get_frontend(&port->frontends, i); |
1812 | if (!fe0) | 2190 | if (!fe0) |
1813 | err = -EINVAL; | 2191 | return -EINVAL; |
1814 | 2192 | ||
1815 | dprintk(1, "%s\n", __func__); | 2193 | dprintk(1, "%s\n", __func__); |
1816 | dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", | 2194 | dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", |
@@ -1853,6 +2231,13 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port) | |||
1853 | struct vb2_dvb_frontend *fe0; | 2231 | struct vb2_dvb_frontend *fe0; |
1854 | struct i2c_client *client; | 2232 | struct i2c_client *client; |
1855 | 2233 | ||
2234 | /* remove I2C client for CI */ | ||
2235 | client = port->i2c_client_ci; | ||
2236 | if (client) { | ||
2237 | module_put(client->dev.driver->owner); | ||
2238 | i2c_unregister_device(client); | ||
2239 | } | ||
2240 | |||
1856 | /* remove I2C client for tuner */ | 2241 | /* remove I2C client for tuner */ |
1857 | client = port->i2c_client_tuner; | 2242 | client = port->i2c_client_tuner; |
1858 | if (client) { | 2243 | if (client) { |
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c index 9d37fe661691..088799c3b49b 100644 --- a/drivers/media/pci/cx23885/cx23885-input.c +++ b/drivers/media/pci/cx23885/cx23885-input.c | |||
@@ -87,6 +87,13 @@ void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events) | |||
87 | case CX23885_BOARD_MYGICA_X8507: | 87 | case CX23885_BOARD_MYGICA_X8507: |
88 | case CX23885_BOARD_TBS_6980: | 88 | case CX23885_BOARD_TBS_6980: |
89 | case CX23885_BOARD_TBS_6981: | 89 | case CX23885_BOARD_TBS_6981: |
90 | case CX23885_BOARD_DVBSKY_T9580: | ||
91 | case CX23885_BOARD_DVBSKY_T980C: | ||
92 | case CX23885_BOARD_DVBSKY_S950C: | ||
93 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
94 | case CX23885_BOARD_DVBSKY_S950: | ||
95 | case CX23885_BOARD_DVBSKY_S952: | ||
96 | case CX23885_BOARD_DVBSKY_T982: | ||
90 | /* | 97 | /* |
91 | * The only boards we handle right now. However other boards | 98 | * The only boards we handle right now. However other boards |
92 | * using the CX2388x integrated IR controller should be similar | 99 | * using the CX2388x integrated IR controller should be similar |
@@ -139,6 +146,13 @@ static int cx23885_input_ir_start(struct cx23885_dev *dev) | |||
139 | case CX23885_BOARD_HAUPPAUGE_HVR1290: | 146 | case CX23885_BOARD_HAUPPAUGE_HVR1290: |
140 | case CX23885_BOARD_HAUPPAUGE_HVR1250: | 147 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
141 | case CX23885_BOARD_MYGICA_X8507: | 148 | case CX23885_BOARD_MYGICA_X8507: |
149 | case CX23885_BOARD_DVBSKY_T9580: | ||
150 | case CX23885_BOARD_DVBSKY_T980C: | ||
151 | case CX23885_BOARD_DVBSKY_S950C: | ||
152 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
153 | case CX23885_BOARD_DVBSKY_S950: | ||
154 | case CX23885_BOARD_DVBSKY_S952: | ||
155 | case CX23885_BOARD_DVBSKY_T982: | ||
142 | /* | 156 | /* |
143 | * The IR controller on this board only returns pulse widths. | 157 | * The IR controller on this board only returns pulse widths. |
144 | * Any other mode setting will fail to set up the device. | 158 | * Any other mode setting will fail to set up the device. |
@@ -305,6 +319,23 @@ int cx23885_input_init(struct cx23885_dev *dev) | |||
305 | /* A guess at the remote */ | 319 | /* A guess at the remote */ |
306 | rc_map = RC_MAP_TBS_NEC; | 320 | rc_map = RC_MAP_TBS_NEC; |
307 | break; | 321 | break; |
322 | case CX23885_BOARD_DVBSKY_T9580: | ||
323 | case CX23885_BOARD_DVBSKY_T980C: | ||
324 | case CX23885_BOARD_DVBSKY_S950C: | ||
325 | case CX23885_BOARD_DVBSKY_S950: | ||
326 | case CX23885_BOARD_DVBSKY_S952: | ||
327 | case CX23885_BOARD_DVBSKY_T982: | ||
328 | /* Integrated CX23885 IR controller */ | ||
329 | driver_type = RC_DRIVER_IR_RAW; | ||
330 | allowed_protos = RC_BIT_ALL; | ||
331 | rc_map = RC_MAP_DVBSKY; | ||
332 | break; | ||
333 | case CX23885_BOARD_TT_CT2_4500_CI: | ||
334 | /* Integrated CX23885 IR controller */ | ||
335 | driver_type = RC_DRIVER_IR_RAW; | ||
336 | allowed_protos = RC_BIT_ALL; | ||
337 | rc_map = RC_MAP_TT_1500; | ||
338 | break; | ||
308 | default: | 339 | default: |
309 | return -ENODEV; | 340 | return -ENODEV; |
310 | } | 341 | } |
diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c index a7c6ef8f3ea3..d362d3838c84 100644 --- a/drivers/media/pci/cx23885/cx23885-vbi.c +++ b/drivers/media/pci/cx23885/cx23885-vbi.c | |||
@@ -132,6 +132,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
132 | lines = VBI_NTSC_LINE_COUNT; | 132 | lines = VBI_NTSC_LINE_COUNT; |
133 | *num_planes = 1; | 133 | *num_planes = 1; |
134 | sizes[0] = lines * VBI_LINE_LENGTH * 2; | 134 | sizes[0] = lines * VBI_LINE_LENGTH * 2; |
135 | alloc_ctxs[0] = dev->alloc_ctx; | ||
135 | return 0; | 136 | return 0; |
136 | } | 137 | } |
137 | 138 | ||
@@ -142,7 +143,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
142 | struct cx23885_buffer, vb); | 143 | struct cx23885_buffer, vb); |
143 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | 144 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); |
144 | unsigned lines = VBI_PAL_LINE_COUNT; | 145 | unsigned lines = VBI_PAL_LINE_COUNT; |
145 | int ret; | ||
146 | 146 | ||
147 | if (dev->tvnorm & V4L2_STD_525_60) | 147 | if (dev->tvnorm & V4L2_STD_525_60) |
148 | lines = VBI_NTSC_LINE_COUNT; | 148 | lines = VBI_NTSC_LINE_COUNT; |
@@ -151,10 +151,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
151 | return -EINVAL; | 151 | return -EINVAL; |
152 | vb2_set_plane_payload(vb, 0, lines * VBI_LINE_LENGTH * 2); | 152 | vb2_set_plane_payload(vb, 0, lines * VBI_LINE_LENGTH * 2); |
153 | 153 | ||
154 | ret = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
155 | if (!ret) | ||
156 | return -EIO; | ||
157 | |||
158 | cx23885_risc_vbibuffer(dev->pci, &buf->risc, | 154 | cx23885_risc_vbibuffer(dev->pci, &buf->risc, |
159 | sgt->sgl, | 155 | sgt->sgl, |
160 | 0, VBI_LINE_LENGTH * lines, | 156 | 0, VBI_LINE_LENGTH * lines, |
@@ -165,14 +161,10 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
165 | 161 | ||
166 | static void buffer_finish(struct vb2_buffer *vb) | 162 | static void buffer_finish(struct vb2_buffer *vb) |
167 | { | 163 | { |
168 | struct cx23885_dev *dev = vb->vb2_queue->drv_priv; | ||
169 | struct cx23885_buffer *buf = container_of(vb, | 164 | struct cx23885_buffer *buf = container_of(vb, |
170 | struct cx23885_buffer, vb); | 165 | struct cx23885_buffer, vb); |
171 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
172 | 166 | ||
173 | cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); | 167 | cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); |
174 | |||
175 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
176 | } | 168 | } |
177 | 169 | ||
178 | /* | 170 | /* |
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 682a4f95df6b..5e93c682a3f5 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c | |||
@@ -323,6 +323,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
323 | 323 | ||
324 | *num_planes = 1; | 324 | *num_planes = 1; |
325 | sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; | 325 | sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; |
326 | alloc_ctxs[0] = dev->alloc_ctx; | ||
326 | return 0; | 327 | return 0; |
327 | } | 328 | } |
328 | 329 | ||
@@ -334,7 +335,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
334 | u32 line0_offset, line1_offset; | 335 | u32 line0_offset, line1_offset; |
335 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | 336 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); |
336 | int field_tff; | 337 | int field_tff; |
337 | int ret; | ||
338 | 338 | ||
339 | buf->bpl = (dev->width * dev->fmt->depth) >> 3; | 339 | buf->bpl = (dev->width * dev->fmt->depth) >> 3; |
340 | 340 | ||
@@ -342,10 +342,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
342 | return -EINVAL; | 342 | return -EINVAL; |
343 | vb2_set_plane_payload(vb, 0, dev->height * buf->bpl); | 343 | vb2_set_plane_payload(vb, 0, dev->height * buf->bpl); |
344 | 344 | ||
345 | ret = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
346 | if (!ret) | ||
347 | return -EIO; | ||
348 | |||
349 | switch (dev->field) { | 345 | switch (dev->field) { |
350 | case V4L2_FIELD_TOP: | 346 | case V4L2_FIELD_TOP: |
351 | cx23885_risc_buffer(dev->pci, &buf->risc, | 347 | cx23885_risc_buffer(dev->pci, &buf->risc, |
@@ -413,14 +409,10 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
413 | 409 | ||
414 | static void buffer_finish(struct vb2_buffer *vb) | 410 | static void buffer_finish(struct vb2_buffer *vb) |
415 | { | 411 | { |
416 | struct cx23885_dev *dev = vb->vb2_queue->drv_priv; | ||
417 | struct cx23885_buffer *buf = container_of(vb, | 412 | struct cx23885_buffer *buf = container_of(vb, |
418 | struct cx23885_buffer, vb); | 413 | struct cx23885_buffer, vb); |
419 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
420 | 414 | ||
421 | cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); | 415 | cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); |
422 | |||
423 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
424 | } | 416 | } |
425 | 417 | ||
426 | /* | 418 | /* |
@@ -608,7 +600,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
608 | dev->field = f->fmt.pix.field; | 600 | dev->field = f->fmt.pix.field; |
609 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, | 601 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, |
610 | dev->width, dev->height, dev->field); | 602 | dev->width, dev->height, dev->field); |
611 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); | 603 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); |
612 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); | 604 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); |
613 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); | 605 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); |
614 | /* s_mbus_fmt overwrites f->fmt.pix.field, restore it */ | 606 | /* s_mbus_fmt overwrites f->fmt.pix.field, restore it */ |
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h index 6c35e6115969..f55cd12da0fd 100644 --- a/drivers/media/pci/cx23885/cx23885.h +++ b/drivers/media/pci/cx23885/cx23885.h | |||
@@ -93,6 +93,12 @@ | |||
93 | #define CX23885_BOARD_HAUPPAUGE_IMPACTVCBE 43 | 93 | #define CX23885_BOARD_HAUPPAUGE_IMPACTVCBE 43 |
94 | #define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2 44 | 94 | #define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2 44 |
95 | #define CX23885_BOARD_DVBSKY_T9580 45 | 95 | #define CX23885_BOARD_DVBSKY_T9580 45 |
96 | #define CX23885_BOARD_DVBSKY_T980C 46 | ||
97 | #define CX23885_BOARD_DVBSKY_S950C 47 | ||
98 | #define CX23885_BOARD_TT_CT2_4500_CI 48 | ||
99 | #define CX23885_BOARD_DVBSKY_S950 49 | ||
100 | #define CX23885_BOARD_DVBSKY_S952 50 | ||
101 | #define CX23885_BOARD_DVBSKY_T982 51 | ||
96 | 102 | ||
97 | #define GPIO_0 0x00000001 | 103 | #define GPIO_0 0x00000001 |
98 | #define GPIO_1 0x00000002 | 104 | #define GPIO_1 0x00000002 |
@@ -296,6 +302,7 @@ struct cx23885_tsport { | |||
296 | 302 | ||
297 | struct i2c_client *i2c_client_demod; | 303 | struct i2c_client *i2c_client_demod; |
298 | struct i2c_client *i2c_client_tuner; | 304 | struct i2c_client *i2c_client_tuner; |
305 | struct i2c_client *i2c_client_ci; | ||
299 | 306 | ||
300 | int (*set_frontend)(struct dvb_frontend *fe); | 307 | int (*set_frontend)(struct dvb_frontend *fe); |
301 | int (*fe_set_voltage)(struct dvb_frontend *fe, | 308 | int (*fe_set_voltage)(struct dvb_frontend *fe, |
@@ -418,6 +425,7 @@ struct cx23885_dev { | |||
418 | struct vb2_queue vb2_vidq; | 425 | struct vb2_queue vb2_vidq; |
419 | struct cx23885_dmaqueue vbiq; | 426 | struct cx23885_dmaqueue vbiq; |
420 | struct vb2_queue vb2_vbiq; | 427 | struct vb2_queue vb2_vbiq; |
428 | void *alloc_ctx; | ||
421 | 429 | ||
422 | spinlock_t slock; | 430 | spinlock_t slock; |
423 | 431 | ||
diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c index e81173c41e5a..389fffd2f36f 100644 --- a/drivers/media/pci/cx25821/cx25821-core.c +++ b/drivers/media/pci/cx25821/cx25821-core.c | |||
@@ -996,7 +996,7 @@ static __le32 *cx25821_risc_field(__le32 * rp, struct scatterlist *sglist, | |||
996 | for (line = 0; line < lines; line++) { | 996 | for (line = 0; line < lines; line++) { |
997 | while (offset && offset >= sg_dma_len(sg)) { | 997 | while (offset && offset >= sg_dma_len(sg)) { |
998 | offset -= sg_dma_len(sg); | 998 | offset -= sg_dma_len(sg); |
999 | sg++; | 999 | sg = sg_next(sg); |
1000 | } | 1000 | } |
1001 | if (bpl <= sg_dma_len(sg) - offset) { | 1001 | if (bpl <= sg_dma_len(sg) - offset) { |
1002 | /* fits into current chunk */ | 1002 | /* fits into current chunk */ |
@@ -1014,14 +1014,14 @@ static __le32 *cx25821_risc_field(__le32 * rp, struct scatterlist *sglist, | |||
1014 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1014 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1015 | todo -= (sg_dma_len(sg) - offset); | 1015 | todo -= (sg_dma_len(sg) - offset); |
1016 | offset = 0; | 1016 | offset = 0; |
1017 | sg++; | 1017 | sg = sg_next(sg); |
1018 | while (todo > sg_dma_len(sg)) { | 1018 | while (todo > sg_dma_len(sg)) { |
1019 | *(rp++) = cpu_to_le32(RISC_WRITE | | 1019 | *(rp++) = cpu_to_le32(RISC_WRITE | |
1020 | sg_dma_len(sg)); | 1020 | sg_dma_len(sg)); |
1021 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); | 1021 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
1022 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1022 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1023 | todo -= sg_dma_len(sg); | 1023 | todo -= sg_dma_len(sg); |
1024 | sg++; | 1024 | sg = sg_next(sg); |
1025 | } | 1025 | } |
1026 | *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo); | 1026 | *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo); |
1027 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); | 1027 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
@@ -1101,7 +1101,7 @@ static __le32 *cx25821_risc_field_audio(__le32 * rp, struct scatterlist *sglist, | |||
1101 | for (line = 0; line < lines; line++) { | 1101 | for (line = 0; line < lines; line++) { |
1102 | while (offset && offset >= sg_dma_len(sg)) { | 1102 | while (offset && offset >= sg_dma_len(sg)) { |
1103 | offset -= sg_dma_len(sg); | 1103 | offset -= sg_dma_len(sg); |
1104 | sg++; | 1104 | sg = sg_next(sg); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | if (lpi && line > 0 && !(line % lpi)) | 1107 | if (lpi && line > 0 && !(line % lpi)) |
@@ -1125,14 +1125,14 @@ static __le32 *cx25821_risc_field_audio(__le32 * rp, struct scatterlist *sglist, | |||
1125 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1125 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1126 | todo -= (sg_dma_len(sg) - offset); | 1126 | todo -= (sg_dma_len(sg) - offset); |
1127 | offset = 0; | 1127 | offset = 0; |
1128 | sg++; | 1128 | sg = sg_next(sg); |
1129 | while (todo > sg_dma_len(sg)) { | 1129 | while (todo > sg_dma_len(sg)) { |
1130 | *(rp++) = cpu_to_le32(RISC_WRITE | | 1130 | *(rp++) = cpu_to_le32(RISC_WRITE | |
1131 | sg_dma_len(sg)); | 1131 | sg_dma_len(sg)); |
1132 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); | 1132 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
1133 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1133 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1134 | todo -= sg_dma_len(sg); | 1134 | todo -= sg_dma_len(sg); |
1135 | sg++; | 1135 | sg = sg_next(sg); |
1136 | } | 1136 | } |
1137 | *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo); | 1137 | *(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo); |
1138 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); | 1138 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
diff --git a/drivers/media/pci/cx88/Kconfig b/drivers/media/pci/cx88/Kconfig index a63a9ad163b2..14b813d634a8 100644 --- a/drivers/media/pci/cx88/Kconfig +++ b/drivers/media/pci/cx88/Kconfig | |||
@@ -2,8 +2,7 @@ config VIDEO_CX88 | |||
2 | tristate "Conexant 2388x (bt878 successor) support" | 2 | tristate "Conexant 2388x (bt878 successor) support" |
3 | depends on VIDEO_DEV && PCI && I2C && RC_CORE | 3 | depends on VIDEO_DEV && PCI && I2C && RC_CORE |
4 | select I2C_ALGOBIT | 4 | select I2C_ALGOBIT |
5 | select VIDEO_BTCX | 5 | select VIDEOBUF2_DMA_SG |
6 | select VIDEOBUF_DMA_SG | ||
7 | select VIDEO_TUNER | 6 | select VIDEO_TUNER |
8 | select VIDEO_TVEEPROM | 7 | select VIDEO_TVEEPROM |
9 | select VIDEO_WM8775 if MEDIA_SUBDRV_AUTOSELECT | 8 | select VIDEO_WM8775 if MEDIA_SUBDRV_AUTOSELECT |
@@ -45,7 +44,7 @@ config VIDEO_CX88_BLACKBIRD | |||
45 | config VIDEO_CX88_DVB | 44 | config VIDEO_CX88_DVB |
46 | tristate "DVB/ATSC Support for cx2388x based TV cards" | 45 | tristate "DVB/ATSC Support for cx2388x based TV cards" |
47 | depends on VIDEO_CX88 && DVB_CORE | 46 | depends on VIDEO_CX88 && DVB_CORE |
48 | select VIDEOBUF_DVB | 47 | select VIDEOBUF2_DVB |
49 | select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT | 48 | select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT |
50 | select DVB_MT352 if MEDIA_SUBDRV_AUTOSELECT | 49 | select DVB_MT352 if MEDIA_SUBDRV_AUTOSELECT |
51 | select DVB_ZL10353 if MEDIA_SUBDRV_AUTOSELECT | 50 | select DVB_ZL10353 if MEDIA_SUBDRV_AUTOSELECT |
diff --git a/drivers/media/pci/cx88/Makefile b/drivers/media/pci/cx88/Makefile index 8619c1becee2..d3679c3ee248 100644 --- a/drivers/media/pci/cx88/Makefile +++ b/drivers/media/pci/cx88/Makefile | |||
@@ -11,7 +11,6 @@ obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o | |||
11 | obj-$(CONFIG_VIDEO_CX88_VP3054) += cx88-vp3054-i2c.o | 11 | obj-$(CONFIG_VIDEO_CX88_VP3054) += cx88-vp3054-i2c.o |
12 | 12 | ||
13 | ccflags-y += -Idrivers/media/i2c | 13 | ccflags-y += -Idrivers/media/i2c |
14 | ccflags-y += -Idrivers/media/common | ||
15 | ccflags-y += -Idrivers/media/tuners | 14 | ccflags-y += -Idrivers/media/tuners |
16 | ccflags-y += -Idrivers/media/dvb-core | 15 | ccflags-y += -Idrivers/media/dvb-core |
17 | ccflags-y += -Idrivers/media/dvb-frontends | 16 | ccflags-y += -Idrivers/media/dvb-frontends |
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c index a72579a9f67f..7f8dc60028d5 100644 --- a/drivers/media/pci/cx88/cx88-alsa.c +++ b/drivers/media/pci/cx88/cx88-alsa.c | |||
@@ -61,8 +61,11 @@ | |||
61 | 61 | ||
62 | struct cx88_audio_buffer { | 62 | struct cx88_audio_buffer { |
63 | unsigned int bpl; | 63 | unsigned int bpl; |
64 | struct btcx_riscmem risc; | 64 | struct cx88_riscmem risc; |
65 | struct videobuf_dmabuf dma; | 65 | void *vaddr; |
66 | struct scatterlist *sglist; | ||
67 | int sglen; | ||
68 | int nr_pages; | ||
66 | }; | 69 | }; |
67 | 70 | ||
68 | struct cx88_audio_dev { | 71 | struct cx88_audio_dev { |
@@ -84,8 +87,6 @@ struct cx88_audio_dev { | |||
84 | unsigned int period_size; | 87 | unsigned int period_size; |
85 | unsigned int num_periods; | 88 | unsigned int num_periods; |
86 | 89 | ||
87 | struct videobuf_dmabuf *dma_risc; | ||
88 | |||
89 | struct cx88_audio_buffer *buf; | 90 | struct cx88_audio_buffer *buf; |
90 | 91 | ||
91 | struct snd_pcm_substream *substream; | 92 | struct snd_pcm_substream *substream; |
@@ -290,19 +291,97 @@ static irqreturn_t cx8801_irq(int irq, void *dev_id) | |||
290 | return IRQ_RETVAL(handled); | 291 | return IRQ_RETVAL(handled); |
291 | } | 292 | } |
292 | 293 | ||
294 | static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages) | ||
295 | { | ||
296 | struct cx88_audio_buffer *buf = chip->buf; | ||
297 | struct page *pg; | ||
298 | int i; | ||
299 | |||
300 | buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); | ||
301 | if (NULL == buf->vaddr) { | ||
302 | dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); | ||
303 | return -ENOMEM; | ||
304 | } | ||
305 | |||
306 | dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n", | ||
307 | (unsigned long)buf->vaddr, | ||
308 | nr_pages << PAGE_SHIFT); | ||
309 | |||
310 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); | ||
311 | buf->nr_pages = nr_pages; | ||
312 | |||
313 | buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); | ||
314 | if (NULL == buf->sglist) | ||
315 | goto vzalloc_err; | ||
316 | |||
317 | sg_init_table(buf->sglist, buf->nr_pages); | ||
318 | for (i = 0; i < buf->nr_pages; i++) { | ||
319 | pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE); | ||
320 | if (NULL == pg) | ||
321 | goto vmalloc_to_page_err; | ||
322 | sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0); | ||
323 | } | ||
324 | return 0; | ||
325 | |||
326 | vmalloc_to_page_err: | ||
327 | vfree(buf->sglist); | ||
328 | buf->sglist = NULL; | ||
329 | vzalloc_err: | ||
330 | vfree(buf->vaddr); | ||
331 | buf->vaddr = NULL; | ||
332 | return -ENOMEM; | ||
333 | } | ||
334 | |||
335 | static int cx88_alsa_dma_map(struct cx88_audio_dev *dev) | ||
336 | { | ||
337 | struct cx88_audio_buffer *buf = dev->buf; | ||
338 | |||
339 | buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, | ||
340 | buf->nr_pages, PCI_DMA_FROMDEVICE); | ||
341 | |||
342 | if (0 == buf->sglen) { | ||
343 | pr_warn("%s: cx88_alsa_map_sg failed\n", __func__); | ||
344 | return -ENOMEM; | ||
345 | } | ||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev) | ||
350 | { | ||
351 | struct cx88_audio_buffer *buf = dev->buf; | ||
352 | |||
353 | if (!buf->sglen) | ||
354 | return 0; | ||
355 | |||
356 | dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); | ||
357 | buf->sglen = 0; | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | static int cx88_alsa_dma_free(struct cx88_audio_buffer *buf) | ||
362 | { | ||
363 | vfree(buf->sglist); | ||
364 | buf->sglist = NULL; | ||
365 | vfree(buf->vaddr); | ||
366 | buf->vaddr = NULL; | ||
367 | return 0; | ||
368 | } | ||
369 | |||
293 | 370 | ||
294 | static int dsp_buffer_free(snd_cx88_card_t *chip) | 371 | static int dsp_buffer_free(snd_cx88_card_t *chip) |
295 | { | 372 | { |
373 | struct cx88_riscmem *risc = &chip->buf->risc; | ||
374 | |||
296 | BUG_ON(!chip->dma_size); | 375 | BUG_ON(!chip->dma_size); |
297 | 376 | ||
298 | dprintk(2,"Freeing buffer\n"); | 377 | dprintk(2,"Freeing buffer\n"); |
299 | videobuf_dma_unmap(&chip->pci->dev, chip->dma_risc); | 378 | cx88_alsa_dma_unmap(chip); |
300 | videobuf_dma_free(chip->dma_risc); | 379 | cx88_alsa_dma_free(chip->buf); |
301 | btcx_riscmem_free(chip->pci,&chip->buf->risc); | 380 | if (risc->cpu) |
381 | pci_free_consistent(chip->pci, risc->size, risc->cpu, risc->dma); | ||
302 | kfree(chip->buf); | 382 | kfree(chip->buf); |
303 | 383 | ||
304 | chip->dma_risc = NULL; | 384 | chip->buf = NULL; |
305 | chip->dma_size = 0; | ||
306 | 385 | ||
307 | return 0; | 386 | return 0; |
308 | } | 387 | } |
@@ -387,7 +466,6 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream, | |||
387 | struct snd_pcm_hw_params * hw_params) | 466 | struct snd_pcm_hw_params * hw_params) |
388 | { | 467 | { |
389 | snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); | 468 | snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); |
390 | struct videobuf_dmabuf *dma; | ||
391 | 469 | ||
392 | struct cx88_audio_buffer *buf; | 470 | struct cx88_audio_buffer *buf; |
393 | int ret; | 471 | int ret; |
@@ -408,20 +486,19 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream, | |||
408 | if (NULL == buf) | 486 | if (NULL == buf) |
409 | return -ENOMEM; | 487 | return -ENOMEM; |
410 | 488 | ||
489 | chip->buf = buf; | ||
411 | buf->bpl = chip->period_size; | 490 | buf->bpl = chip->period_size; |
412 | 491 | ||
413 | dma = &buf->dma; | 492 | ret = cx88_alsa_dma_init(chip, |
414 | videobuf_dma_init(dma); | ||
415 | ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE, | ||
416 | (PAGE_ALIGN(chip->dma_size) >> PAGE_SHIFT)); | 493 | (PAGE_ALIGN(chip->dma_size) >> PAGE_SHIFT)); |
417 | if (ret < 0) | 494 | if (ret < 0) |
418 | goto error; | 495 | goto error; |
419 | 496 | ||
420 | ret = videobuf_dma_map(&chip->pci->dev, dma); | 497 | ret = cx88_alsa_dma_map(chip); |
421 | if (ret < 0) | 498 | if (ret < 0) |
422 | goto error; | 499 | goto error; |
423 | 500 | ||
424 | ret = cx88_risc_databuffer(chip->pci, &buf->risc, dma->sglist, | 501 | ret = cx88_risc_databuffer(chip->pci, &buf->risc, buf->sglist, |
425 | chip->period_size, chip->num_periods, 1); | 502 | chip->period_size, chip->num_periods, 1); |
426 | if (ret < 0) | 503 | if (ret < 0) |
427 | goto error; | 504 | goto error; |
@@ -430,10 +507,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream, | |||
430 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC); | 507 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC); |
431 | buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 508 | buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
432 | 509 | ||
433 | chip->buf = buf; | 510 | substream->runtime->dma_area = chip->buf->vaddr; |
434 | chip->dma_risc = dma; | ||
435 | |||
436 | substream->runtime->dma_area = chip->dma_risc->vaddr; | ||
437 | substream->runtime->dma_bytes = chip->dma_size; | 511 | substream->runtime->dma_bytes = chip->dma_size; |
438 | substream->runtime->dma_addr = 0; | 512 | substream->runtime->dma_addr = 0; |
439 | return 0; | 513 | return 0; |
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c index 150bb76e7839..4160ca4e5413 100644 --- a/drivers/media/pci/cx88/cx88-blackbird.c +++ b/drivers/media/pci/cx88/cx88-blackbird.c | |||
@@ -45,10 +45,6 @@ MODULE_AUTHOR("Jelle Foks <jelle@foks.us>, Gerd Knorr <kraxel@bytesex.org> [SuSE | |||
45 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
46 | MODULE_VERSION(CX88_VERSION); | 46 | MODULE_VERSION(CX88_VERSION); |
47 | 47 | ||
48 | static unsigned int mpegbufs = 32; | ||
49 | module_param(mpegbufs,int,0644); | ||
50 | MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32"); | ||
51 | |||
52 | static unsigned int debug; | 48 | static unsigned int debug; |
53 | module_param(debug,int,0644); | 49 | module_param(debug,int,0644); |
54 | MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); | 50 | MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); |
@@ -326,13 +322,13 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat | |||
326 | memory_read(dev->core, dev->mailbox - 4, &value); | 322 | memory_read(dev->core, dev->mailbox - 4, &value); |
327 | if (value != 0x12345678) { | 323 | if (value != 0x12345678) { |
328 | dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n"); | 324 | dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n"); |
329 | return -1; | 325 | return -EIO; |
330 | } | 326 | } |
331 | 327 | ||
332 | memory_read(dev->core, dev->mailbox, &flag); | 328 | memory_read(dev->core, dev->mailbox, &flag); |
333 | if (flag) { | 329 | if (flag) { |
334 | dprintk(0, "ERROR: Mailbox appears to be in use (%x)\n", flag); | 330 | dprintk(0, "ERROR: Mailbox appears to be in use (%x)\n", flag); |
335 | return -1; | 331 | return -EIO; |
336 | } | 332 | } |
337 | 333 | ||
338 | flag |= 1; /* tell 'em we're working on it */ | 334 | flag |= 1; /* tell 'em we're working on it */ |
@@ -352,14 +348,14 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat | |||
352 | memory_write(dev->core, dev->mailbox, flag); | 348 | memory_write(dev->core, dev->mailbox, flag); |
353 | 349 | ||
354 | /* wait for firmware to handle the API command */ | 350 | /* wait for firmware to handle the API command */ |
355 | timeout = jiffies + msecs_to_jiffies(10); | 351 | timeout = jiffies + msecs_to_jiffies(1000); |
356 | for (;;) { | 352 | for (;;) { |
357 | memory_read(dev->core, dev->mailbox, &flag); | 353 | memory_read(dev->core, dev->mailbox, &flag); |
358 | if (0 != (flag & 4)) | 354 | if (0 != (flag & 4)) |
359 | break; | 355 | break; |
360 | if (time_after(jiffies,timeout)) { | 356 | if (time_after(jiffies,timeout)) { |
361 | dprintk(0, "ERROR: API Mailbox timeout\n"); | 357 | dprintk(0, "ERROR: API Mailbox timeout %x\n", command); |
362 | return -1; | 358 | return -EIO; |
363 | } | 359 | } |
364 | udelay(10); | 360 | udelay(10); |
365 | } | 361 | } |
@@ -420,7 +416,7 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev) | |||
420 | } | 416 | } |
421 | } | 417 | } |
422 | dprintk(0, "Mailbox signature values not found!\n"); | 418 | dprintk(0, "Mailbox signature values not found!\n"); |
423 | return -1; | 419 | return -EIO; |
424 | } | 420 | } |
425 | 421 | ||
426 | static int blackbird_load_firmware(struct cx8802_dev *dev) | 422 | static int blackbird_load_firmware(struct cx8802_dev *dev) |
@@ -432,7 +428,7 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) | |||
432 | int i, retval = 0; | 428 | int i, retval = 0; |
433 | u32 value = 0; | 429 | u32 value = 0; |
434 | u32 checksum = 0; | 430 | u32 checksum = 0; |
435 | u32 *dataptr; | 431 | __le32 *dataptr; |
436 | 432 | ||
437 | retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); | 433 | retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); |
438 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); | 434 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); |
@@ -449,29 +445,28 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) | |||
449 | 445 | ||
450 | 446 | ||
451 | if (retval != 0) { | 447 | if (retval != 0) { |
452 | dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n", | 448 | pr_err("Hotplug firmware request failed (%s).\n", |
453 | CX2341X_FIRM_ENC_FILENAME); | 449 | CX2341X_FIRM_ENC_FILENAME); |
454 | dprintk(0, "Please fix your hotplug setup, the board will " | 450 | pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n"); |
455 | "not work without firmware loaded!\n"); | 451 | return -EIO; |
456 | return -1; | ||
457 | } | 452 | } |
458 | 453 | ||
459 | if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { | 454 | if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { |
460 | dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n", | 455 | pr_err("Firmware size mismatch (have %zd, expected %d)\n", |
461 | firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); | 456 | firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); |
462 | release_firmware(firmware); | 457 | release_firmware(firmware); |
463 | return -1; | 458 | return -EINVAL; |
464 | } | 459 | } |
465 | 460 | ||
466 | if (0 != memcmp(firmware->data, magic, 8)) { | 461 | if (0 != memcmp(firmware->data, magic, 8)) { |
467 | dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n"); | 462 | pr_err("Firmware magic mismatch, wrong file?\n"); |
468 | release_firmware(firmware); | 463 | release_firmware(firmware); |
469 | return -1; | 464 | return -EINVAL; |
470 | } | 465 | } |
471 | 466 | ||
472 | /* transfer to the chip */ | 467 | /* transfer to the chip */ |
473 | dprintk(1,"Loading firmware ...\n"); | 468 | dprintk(1,"Loading firmware ...\n"); |
474 | dataptr = (u32*)firmware->data; | 469 | dataptr = (__le32 *)firmware->data; |
475 | for (i = 0; i < (firmware->size >> 2); i++) { | 470 | for (i = 0; i < (firmware->size >> 2); i++) { |
476 | value = le32_to_cpu(*dataptr); | 471 | value = le32_to_cpu(*dataptr); |
477 | checksum += ~value; | 472 | checksum += ~value; |
@@ -484,12 +479,11 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) | |||
484 | memory_read(dev->core, i, &value); | 479 | memory_read(dev->core, i, &value); |
485 | checksum -= ~value; | 480 | checksum -= ~value; |
486 | } | 481 | } |
482 | release_firmware(firmware); | ||
487 | if (checksum) { | 483 | if (checksum) { |
488 | dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n"); | 484 | pr_err("Firmware load might have failed (checksum mismatch).\n"); |
489 | release_firmware(firmware); | 485 | return -EIO; |
490 | return -1; | ||
491 | } | 486 | } |
492 | release_firmware(firmware); | ||
493 | dprintk(0, "Firmware upload successful.\n"); | 487 | dprintk(0, "Firmware upload successful.\n"); |
494 | 488 | ||
495 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); | 489 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); |
@@ -521,12 +515,14 @@ DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | M | |||
521 | 515 | ||
522 | static void blackbird_codec_settings(struct cx8802_dev *dev) | 516 | static void blackbird_codec_settings(struct cx8802_dev *dev) |
523 | { | 517 | { |
518 | struct cx88_core *core = dev->core; | ||
519 | |||
524 | /* assign frame size */ | 520 | /* assign frame size */ |
525 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, | 521 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, |
526 | dev->height, dev->width); | 522 | core->height, core->width); |
527 | 523 | ||
528 | dev->cxhdl.width = dev->width; | 524 | dev->cxhdl.width = core->width; |
529 | dev->cxhdl.height = dev->height; | 525 | dev->cxhdl.height = core->height; |
530 | cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50); | 526 | cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50); |
531 | cx2341x_handler_setup(&dev->cxhdl); | 527 | cx2341x_handler_setup(&dev->cxhdl); |
532 | } | 528 | } |
@@ -540,9 +536,6 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) | |||
540 | dprintk(1,"Initialize codec\n"); | 536 | dprintk(1,"Initialize codec\n"); |
541 | retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ | 537 | retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ |
542 | if (retval < 0) { | 538 | if (retval < 0) { |
543 | |||
544 | dev->mpeg_active = 0; | ||
545 | |||
546 | /* ping was not successful, reset and upload firmware */ | 539 | /* ping was not successful, reset and upload firmware */ |
547 | cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */ | 540 | cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */ |
548 | cx_write(MO_SRST_IO, 1); /* SYS_RSTO=1 */ | 541 | cx_write(MO_SRST_IO, 1); /* SYS_RSTO=1 */ |
@@ -589,9 +582,8 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) | |||
589 | return 0; | 582 | return 0; |
590 | } | 583 | } |
591 | 584 | ||
592 | static int blackbird_start_codec(struct file *file, void *priv) | 585 | static int blackbird_start_codec(struct cx8802_dev *dev) |
593 | { | 586 | { |
594 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | ||
595 | struct cx88_core *core = dev->core; | 587 | struct cx88_core *core = dev->core; |
596 | /* start capturing to the host interface */ | 588 | /* start capturing to the host interface */ |
597 | u32 reg; | 589 | u32 reg; |
@@ -627,7 +619,6 @@ static int blackbird_start_codec(struct file *file, void *priv) | |||
627 | BLACKBIRD_RAW_BITS_NONE | 619 | BLACKBIRD_RAW_BITS_NONE |
628 | ); | 620 | ); |
629 | 621 | ||
630 | dev->mpeg_active = 1; | ||
631 | return 0; | 622 | return 0; |
632 | } | 623 | } |
633 | 624 | ||
@@ -641,51 +632,139 @@ static int blackbird_stop_codec(struct cx8802_dev *dev) | |||
641 | 632 | ||
642 | cx2341x_handler_set_busy(&dev->cxhdl, 0); | 633 | cx2341x_handler_set_busy(&dev->cxhdl, 0); |
643 | 634 | ||
644 | dev->mpeg_active = 0; | ||
645 | return 0; | 635 | return 0; |
646 | } | 636 | } |
647 | 637 | ||
648 | /* ------------------------------------------------------------------ */ | 638 | /* ------------------------------------------------------------------ */ |
649 | 639 | ||
650 | static int bb_buf_setup(struct videobuf_queue *q, | 640 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
651 | unsigned int *count, unsigned int *size) | 641 | unsigned int *num_buffers, unsigned int *num_planes, |
642 | unsigned int sizes[], void *alloc_ctxs[]) | ||
652 | { | 643 | { |
653 | struct cx8802_fh *fh = q->priv_data; | 644 | struct cx8802_dev *dev = q->drv_priv; |
654 | |||
655 | fh->dev->ts_packet_size = 188 * 4; /* was: 512 */ | ||
656 | fh->dev->ts_packet_count = mpegbufs; /* was: 100 */ | ||
657 | 645 | ||
658 | *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count; | 646 | *num_planes = 1; |
659 | *count = fh->dev->ts_packet_count; | 647 | dev->ts_packet_size = 188 * 4; |
648 | dev->ts_packet_count = 32; | ||
649 | sizes[0] = dev->ts_packet_size * dev->ts_packet_count; | ||
660 | return 0; | 650 | return 0; |
661 | } | 651 | } |
662 | 652 | ||
663 | static int | 653 | static int buffer_prepare(struct vb2_buffer *vb) |
664 | bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | ||
665 | enum v4l2_field field) | ||
666 | { | 654 | { |
667 | struct cx8802_fh *fh = q->priv_data; | 655 | struct cx8802_dev *dev = vb->vb2_queue->drv_priv; |
668 | return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field); | 656 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); |
657 | |||
658 | return cx8802_buf_prepare(vb->vb2_queue, dev, buf); | ||
669 | } | 659 | } |
670 | 660 | ||
671 | static void | 661 | static void buffer_finish(struct vb2_buffer *vb) |
672 | bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
673 | { | 662 | { |
674 | struct cx8802_fh *fh = q->priv_data; | 663 | struct cx8802_dev *dev = vb->vb2_queue->drv_priv; |
675 | cx8802_buf_queue(fh->dev, (struct cx88_buffer*)vb); | 664 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); |
665 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
666 | struct cx88_riscmem *risc = &buf->risc; | ||
667 | |||
668 | if (risc->cpu) | ||
669 | pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); | ||
670 | memset(risc, 0, sizeof(*risc)); | ||
671 | |||
672 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
676 | } | 673 | } |
677 | 674 | ||
678 | static void | 675 | static void buffer_queue(struct vb2_buffer *vb) |
679 | bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
680 | { | 676 | { |
681 | cx88_free_buffer(q, (struct cx88_buffer*)vb); | 677 | struct cx8802_dev *dev = vb->vb2_queue->drv_priv; |
678 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
679 | |||
680 | cx8802_buf_queue(dev, buf); | ||
681 | } | ||
682 | |||
683 | static int start_streaming(struct vb2_queue *q, unsigned int count) | ||
684 | { | ||
685 | struct cx8802_dev *dev = q->drv_priv; | ||
686 | struct cx88_dmaqueue *dmaq = &dev->mpegq; | ||
687 | struct cx8802_driver *drv; | ||
688 | struct cx88_buffer *buf; | ||
689 | unsigned long flags; | ||
690 | int err; | ||
691 | |||
692 | /* Make sure we can acquire the hardware */ | ||
693 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); | ||
694 | if (!drv) { | ||
695 | dprintk(1, "%s: blackbird driver is not loaded\n", __func__); | ||
696 | err = -ENODEV; | ||
697 | goto fail; | ||
698 | } | ||
699 | |||
700 | err = drv->request_acquire(drv); | ||
701 | if (err != 0) { | ||
702 | dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__, err); | ||
703 | goto fail; | ||
704 | } | ||
705 | |||
706 | if (blackbird_initialize_codec(dev) < 0) { | ||
707 | drv->request_release(drv); | ||
708 | err = -EINVAL; | ||
709 | goto fail; | ||
710 | } | ||
711 | |||
712 | err = blackbird_start_codec(dev); | ||
713 | if (err == 0) { | ||
714 | buf = list_entry(dmaq->active.next, struct cx88_buffer, list); | ||
715 | cx8802_start_dma(dev, dmaq, buf); | ||
716 | return 0; | ||
717 | } | ||
718 | |||
719 | fail: | ||
720 | spin_lock_irqsave(&dev->slock, flags); | ||
721 | while (!list_empty(&dmaq->active)) { | ||
722 | struct cx88_buffer *buf = list_entry(dmaq->active.next, | ||
723 | struct cx88_buffer, list); | ||
724 | |||
725 | list_del(&buf->list); | ||
726 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); | ||
727 | } | ||
728 | spin_unlock_irqrestore(&dev->slock, flags); | ||
729 | return err; | ||
682 | } | 730 | } |
683 | 731 | ||
684 | static struct videobuf_queue_ops blackbird_qops = { | 732 | static void stop_streaming(struct vb2_queue *q) |
685 | .buf_setup = bb_buf_setup, | 733 | { |
686 | .buf_prepare = bb_buf_prepare, | 734 | struct cx8802_dev *dev = q->drv_priv; |
687 | .buf_queue = bb_buf_queue, | 735 | struct cx88_dmaqueue *dmaq = &dev->mpegq; |
688 | .buf_release = bb_buf_release, | 736 | struct cx8802_driver *drv = NULL; |
737 | unsigned long flags; | ||
738 | |||
739 | cx8802_cancel_buffers(dev); | ||
740 | blackbird_stop_codec(dev); | ||
741 | |||
742 | /* Make sure we release the hardware */ | ||
743 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); | ||
744 | WARN_ON(!drv); | ||
745 | if (drv) | ||
746 | drv->request_release(drv); | ||
747 | |||
748 | spin_lock_irqsave(&dev->slock, flags); | ||
749 | while (!list_empty(&dmaq->active)) { | ||
750 | struct cx88_buffer *buf = list_entry(dmaq->active.next, | ||
751 | struct cx88_buffer, list); | ||
752 | |||
753 | list_del(&buf->list); | ||
754 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
755 | } | ||
756 | spin_unlock_irqrestore(&dev->slock, flags); | ||
757 | } | ||
758 | |||
759 | static struct vb2_ops blackbird_qops = { | ||
760 | .queue_setup = queue_setup, | ||
761 | .buf_prepare = buffer_prepare, | ||
762 | .buf_finish = buffer_finish, | ||
763 | .buf_queue = buffer_queue, | ||
764 | .wait_prepare = vb2_ops_wait_prepare, | ||
765 | .wait_finish = vb2_ops_wait_finish, | ||
766 | .start_streaming = start_streaming, | ||
767 | .stop_streaming = stop_streaming, | ||
689 | }; | 768 | }; |
690 | 769 | ||
691 | /* ------------------------------------------------------------------ */ | 770 | /* ------------------------------------------------------------------ */ |
@@ -693,8 +772,8 @@ static struct videobuf_queue_ops blackbird_qops = { | |||
693 | static int vidioc_querycap(struct file *file, void *priv, | 772 | static int vidioc_querycap(struct file *file, void *priv, |
694 | struct v4l2_capability *cap) | 773 | struct v4l2_capability *cap) |
695 | { | 774 | { |
696 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | 775 | struct cx8802_dev *dev = video_drvdata(file); |
697 | struct cx88_core *core = dev->core; | 776 | struct cx88_core *core = dev->core; |
698 | 777 | ||
699 | strcpy(cap->driver, "cx88_blackbird"); | 778 | strcpy(cap->driver, "cx88_blackbird"); |
700 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); | 779 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); |
@@ -714,131 +793,111 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | |||
714 | return 0; | 793 | return 0; |
715 | } | 794 | } |
716 | 795 | ||
717 | static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | 796 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
718 | struct v4l2_format *f) | 797 | struct v4l2_format *f) |
719 | { | 798 | { |
720 | struct cx8802_fh *fh = priv; | 799 | struct cx8802_dev *dev = video_drvdata(file); |
721 | struct cx8802_dev *dev = fh->dev; | 800 | struct cx88_core *core = dev->core; |
722 | 801 | ||
723 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 802 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
724 | f->fmt.pix.bytesperline = 0; | 803 | f->fmt.pix.bytesperline = 0; |
725 | f->fmt.pix.sizeimage = 188 * 4 * mpegbufs; /* 188 * 4 * 1024; */ | 804 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; |
726 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 805 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
727 | f->fmt.pix.width = dev->width; | 806 | f->fmt.pix.width = core->width; |
728 | f->fmt.pix.height = dev->height; | 807 | f->fmt.pix.height = core->height; |
729 | f->fmt.pix.field = fh->mpegq.field; | 808 | f->fmt.pix.field = core->field; |
730 | dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", | ||
731 | dev->width, dev->height, fh->mpegq.field ); | ||
732 | return 0; | 809 | return 0; |
733 | } | 810 | } |
734 | 811 | ||
735 | static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, | 812 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
736 | struct v4l2_format *f) | 813 | struct v4l2_format *f) |
737 | { | 814 | { |
738 | struct cx8802_fh *fh = priv; | 815 | struct cx8802_dev *dev = video_drvdata(file); |
739 | struct cx8802_dev *dev = fh->dev; | 816 | struct cx88_core *core = dev->core; |
817 | unsigned maxw, maxh; | ||
818 | enum v4l2_field field; | ||
740 | 819 | ||
741 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 820 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
742 | f->fmt.pix.bytesperline = 0; | 821 | f->fmt.pix.bytesperline = 0; |
743 | f->fmt.pix.sizeimage = 188 * 4 * mpegbufs; /* 188 * 4 * 1024; */ | 822 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; |
744 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 823 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
745 | dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", | 824 | |
746 | dev->width, dev->height, fh->mpegq.field ); | 825 | maxw = norm_maxw(core->tvnorm); |
826 | maxh = norm_maxh(core->tvnorm); | ||
827 | |||
828 | field = f->fmt.pix.field; | ||
829 | |||
830 | switch (field) { | ||
831 | case V4L2_FIELD_TOP: | ||
832 | case V4L2_FIELD_BOTTOM: | ||
833 | case V4L2_FIELD_INTERLACED: | ||
834 | case V4L2_FIELD_SEQ_BT: | ||
835 | case V4L2_FIELD_SEQ_TB: | ||
836 | break; | ||
837 | default: | ||
838 | field = (f->fmt.pix.height > maxh / 2) | ||
839 | ? V4L2_FIELD_INTERLACED | ||
840 | : V4L2_FIELD_BOTTOM; | ||
841 | break; | ||
842 | } | ||
843 | if (V4L2_FIELD_HAS_T_OR_B(field)) | ||
844 | maxh /= 2; | ||
845 | |||
846 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, | ||
847 | &f->fmt.pix.height, 32, maxh, 0, 0); | ||
848 | f->fmt.pix.field = field; | ||
747 | return 0; | 849 | return 0; |
748 | } | 850 | } |
749 | 851 | ||
750 | static int vidioc_s_fmt_vid_cap (struct file *file, void *priv, | 852 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, |
751 | struct v4l2_format *f) | 853 | struct v4l2_format *f) |
752 | { | 854 | { |
753 | struct cx8802_fh *fh = priv; | 855 | struct cx8802_dev *dev = video_drvdata(file); |
754 | struct cx8802_dev *dev = fh->dev; | ||
755 | struct cx88_core *core = dev->core; | 856 | struct cx88_core *core = dev->core; |
756 | 857 | ||
757 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 858 | if (vb2_is_busy(&dev->vb2_mpegq)) |
758 | f->fmt.pix.bytesperline = 0; | 859 | return -EBUSY; |
759 | f->fmt.pix.sizeimage = 188 * 4 * mpegbufs; /* 188 * 4 * 1024; */ | 860 | if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || |
760 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 861 | vb2_is_busy(&core->v4ldev->vb2_vbiq))) |
761 | dev->width = f->fmt.pix.width; | 862 | return -EBUSY; |
762 | dev->height = f->fmt.pix.height; | 863 | vidioc_try_fmt_vid_cap(file, priv, f); |
763 | fh->mpegq.field = f->fmt.pix.field; | 864 | core->width = f->fmt.pix.width; |
865 | core->height = f->fmt.pix.height; | ||
866 | core->field = f->fmt.pix.field; | ||
764 | cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); | 867 | cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); |
765 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, | 868 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, |
766 | f->fmt.pix.height, f->fmt.pix.width); | 869 | f->fmt.pix.height, f->fmt.pix.width); |
767 | dprintk(1, "VIDIOC_S_FMT: w: %d, h: %d, f: %d\n", | ||
768 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field ); | ||
769 | return 0; | 870 | return 0; |
770 | } | 871 | } |
771 | 872 | ||
772 | static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) | ||
773 | { | ||
774 | struct cx8802_fh *fh = priv; | ||
775 | return (videobuf_reqbufs(&fh->mpegq, p)); | ||
776 | } | ||
777 | |||
778 | static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) | ||
779 | { | ||
780 | struct cx8802_fh *fh = priv; | ||
781 | return (videobuf_querybuf(&fh->mpegq, p)); | ||
782 | } | ||
783 | |||
784 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) | ||
785 | { | ||
786 | struct cx8802_fh *fh = priv; | ||
787 | return (videobuf_qbuf(&fh->mpegq, p)); | ||
788 | } | ||
789 | |||
790 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) | ||
791 | { | ||
792 | struct cx8802_fh *fh = priv; | ||
793 | return (videobuf_dqbuf(&fh->mpegq, p, | ||
794 | file->f_flags & O_NONBLOCK)); | ||
795 | } | ||
796 | |||
797 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | ||
798 | { | ||
799 | struct cx8802_fh *fh = priv; | ||
800 | struct cx8802_dev *dev = fh->dev; | ||
801 | |||
802 | if (!dev->mpeg_active) | ||
803 | blackbird_start_codec(file, fh); | ||
804 | return videobuf_streamon(&fh->mpegq); | ||
805 | } | ||
806 | |||
807 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | ||
808 | { | ||
809 | struct cx8802_fh *fh = priv; | ||
810 | struct cx8802_dev *dev = fh->dev; | ||
811 | |||
812 | if (dev->mpeg_active) | ||
813 | blackbird_stop_codec(dev); | ||
814 | return videobuf_streamoff(&fh->mpegq); | ||
815 | } | ||
816 | |||
817 | static int vidioc_s_frequency (struct file *file, void *priv, | 873 | static int vidioc_s_frequency (struct file *file, void *priv, |
818 | const struct v4l2_frequency *f) | 874 | const struct v4l2_frequency *f) |
819 | { | 875 | { |
820 | struct cx8802_fh *fh = priv; | 876 | struct cx8802_dev *dev = video_drvdata(file); |
821 | struct cx8802_dev *dev = fh->dev; | 877 | struct cx88_core *core = dev->core; |
822 | struct cx88_core *core = dev->core; | 878 | bool streaming; |
823 | 879 | ||
824 | if (unlikely(UNSET == core->board.tuner_type)) | 880 | if (unlikely(UNSET == core->board.tuner_type)) |
825 | return -EINVAL; | 881 | return -EINVAL; |
826 | if (unlikely(f->tuner != 0)) | 882 | if (unlikely(f->tuner != 0)) |
827 | return -EINVAL; | 883 | return -EINVAL; |
828 | if (dev->mpeg_active) | 884 | streaming = vb2_start_streaming_called(&dev->vb2_mpegq); |
885 | if (streaming) | ||
829 | blackbird_stop_codec(dev); | 886 | blackbird_stop_codec(dev); |
830 | 887 | ||
831 | cx88_set_freq (core,f); | 888 | cx88_set_freq (core,f); |
832 | blackbird_initialize_codec(dev); | 889 | blackbird_initialize_codec(dev); |
833 | cx88_set_scale(dev->core, dev->width, dev->height, | 890 | cx88_set_scale(core, core->width, core->height, |
834 | fh->mpegq.field); | 891 | core->field); |
892 | if (streaming) | ||
893 | blackbird_start_codec(dev); | ||
835 | return 0; | 894 | return 0; |
836 | } | 895 | } |
837 | 896 | ||
838 | static int vidioc_log_status (struct file *file, void *priv) | 897 | static int vidioc_log_status (struct file *file, void *priv) |
839 | { | 898 | { |
840 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | 899 | struct cx8802_dev *dev = video_drvdata(file); |
841 | struct cx88_core *core = dev->core; | 900 | struct cx88_core *core = dev->core; |
842 | char name[32 + 2]; | 901 | char name[32 + 2]; |
843 | 902 | ||
844 | snprintf(name, sizeof(name), "%s/2", core->name); | 903 | snprintf(name, sizeof(name), "%s/2", core->name); |
@@ -850,15 +909,16 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
850 | static int vidioc_enum_input (struct file *file, void *priv, | 909 | static int vidioc_enum_input (struct file *file, void *priv, |
851 | struct v4l2_input *i) | 910 | struct v4l2_input *i) |
852 | { | 911 | { |
853 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 912 | struct cx8802_dev *dev = video_drvdata(file); |
913 | struct cx88_core *core = dev->core; | ||
854 | return cx88_enum_input (core,i); | 914 | return cx88_enum_input (core,i); |
855 | } | 915 | } |
856 | 916 | ||
857 | static int vidioc_g_frequency (struct file *file, void *priv, | 917 | static int vidioc_g_frequency (struct file *file, void *priv, |
858 | struct v4l2_frequency *f) | 918 | struct v4l2_frequency *f) |
859 | { | 919 | { |
860 | struct cx8802_fh *fh = priv; | 920 | struct cx8802_dev *dev = video_drvdata(file); |
861 | struct cx88_core *core = fh->dev->core; | 921 | struct cx88_core *core = dev->core; |
862 | 922 | ||
863 | if (unlikely(UNSET == core->board.tuner_type)) | 923 | if (unlikely(UNSET == core->board.tuner_type)) |
864 | return -EINVAL; | 924 | return -EINVAL; |
@@ -873,7 +933,8 @@ static int vidioc_g_frequency (struct file *file, void *priv, | |||
873 | 933 | ||
874 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) | 934 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) |
875 | { | 935 | { |
876 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 936 | struct cx8802_dev *dev = video_drvdata(file); |
937 | struct cx88_core *core = dev->core; | ||
877 | 938 | ||
878 | *i = core->input; | 939 | *i = core->input; |
879 | return 0; | 940 | return 0; |
@@ -881,24 +942,24 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) | |||
881 | 942 | ||
882 | static int vidioc_s_input (struct file *file, void *priv, unsigned int i) | 943 | static int vidioc_s_input (struct file *file, void *priv, unsigned int i) |
883 | { | 944 | { |
884 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 945 | struct cx8802_dev *dev = video_drvdata(file); |
946 | struct cx88_core *core = dev->core; | ||
885 | 947 | ||
886 | if (i >= 4) | 948 | if (i >= 4) |
887 | return -EINVAL; | 949 | return -EINVAL; |
888 | if (0 == INPUT(i).type) | 950 | if (0 == INPUT(i).type) |
889 | return -EINVAL; | 951 | return -EINVAL; |
890 | 952 | ||
891 | mutex_lock(&core->lock); | ||
892 | cx88_newstation(core); | 953 | cx88_newstation(core); |
893 | cx88_video_mux(core,i); | 954 | cx88_video_mux(core,i); |
894 | mutex_unlock(&core->lock); | ||
895 | return 0; | 955 | return 0; |
896 | } | 956 | } |
897 | 957 | ||
898 | static int vidioc_g_tuner (struct file *file, void *priv, | 958 | static int vidioc_g_tuner (struct file *file, void *priv, |
899 | struct v4l2_tuner *t) | 959 | struct v4l2_tuner *t) |
900 | { | 960 | { |
901 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 961 | struct cx8802_dev *dev = video_drvdata(file); |
962 | struct cx88_core *core = dev->core; | ||
902 | u32 reg; | 963 | u32 reg; |
903 | 964 | ||
904 | if (unlikely(UNSET == core->board.tuner_type)) | 965 | if (unlikely(UNSET == core->board.tuner_type)) |
@@ -920,7 +981,8 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
920 | static int vidioc_s_tuner (struct file *file, void *priv, | 981 | static int vidioc_s_tuner (struct file *file, void *priv, |
921 | const struct v4l2_tuner *t) | 982 | const struct v4l2_tuner *t) |
922 | { | 983 | { |
923 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 984 | struct cx8802_dev *dev = video_drvdata(file); |
985 | struct cx88_core *core = dev->core; | ||
924 | 986 | ||
925 | if (UNSET == core->board.tuner_type) | 987 | if (UNSET == core->board.tuner_type) |
926 | return -EINVAL; | 988 | return -EINVAL; |
@@ -933,7 +995,8 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
933 | 995 | ||
934 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) | 996 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) |
935 | { | 997 | { |
936 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 998 | struct cx8802_dev *dev = video_drvdata(file); |
999 | struct cx88_core *core = dev->core; | ||
937 | 1000 | ||
938 | *tvnorm = core->tvnorm; | 1001 | *tvnorm = core->tvnorm; |
939 | return 0; | 1002 | return 0; |
@@ -941,155 +1004,20 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) | |||
941 | 1004 | ||
942 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) | 1005 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) |
943 | { | 1006 | { |
944 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | ||
945 | |||
946 | mutex_lock(&core->lock); | ||
947 | cx88_set_tvnorm(core, id); | ||
948 | mutex_unlock(&core->lock); | ||
949 | return 0; | ||
950 | } | ||
951 | |||
952 | /* FIXME: cx88_ioctl_hook not implemented */ | ||
953 | |||
954 | static int mpeg_open(struct file *file) | ||
955 | { | ||
956 | struct video_device *vdev = video_devdata(file); | ||
957 | struct cx8802_dev *dev = video_drvdata(file); | 1007 | struct cx8802_dev *dev = video_drvdata(file); |
958 | struct cx8802_fh *fh; | 1008 | struct cx88_core *core = dev->core; |
959 | struct cx8802_driver *drv = NULL; | ||
960 | int err; | ||
961 | |||
962 | dprintk( 1, "%s\n", __func__); | ||
963 | |||
964 | mutex_lock(&dev->core->lock); | ||
965 | |||
966 | /* Make sure we can acquire the hardware */ | ||
967 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); | ||
968 | if (!drv) { | ||
969 | dprintk(1, "%s: blackbird driver is not loaded\n", __func__); | ||
970 | mutex_unlock(&dev->core->lock); | ||
971 | return -ENODEV; | ||
972 | } | ||
973 | |||
974 | err = drv->request_acquire(drv); | ||
975 | if (err != 0) { | ||
976 | dprintk(1,"%s: Unable to acquire hardware, %d\n", __func__, err); | ||
977 | mutex_unlock(&dev->core->lock); | ||
978 | return err; | ||
979 | } | ||
980 | |||
981 | if (!dev->core->mpeg_users && blackbird_initialize_codec(dev) < 0) { | ||
982 | drv->request_release(drv); | ||
983 | mutex_unlock(&dev->core->lock); | ||
984 | return -EINVAL; | ||
985 | } | ||
986 | dprintk(1, "open dev=%s\n", video_device_node_name(vdev)); | ||
987 | |||
988 | /* allocate + initialize per filehandle data */ | ||
989 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); | ||
990 | if (NULL == fh) { | ||
991 | drv->request_release(drv); | ||
992 | mutex_unlock(&dev->core->lock); | ||
993 | return -ENOMEM; | ||
994 | } | ||
995 | v4l2_fh_init(&fh->fh, vdev); | ||
996 | file->private_data = fh; | ||
997 | fh->dev = dev; | ||
998 | |||
999 | videobuf_queue_sg_init(&fh->mpegq, &blackbird_qops, | ||
1000 | &dev->pci->dev, &dev->slock, | ||
1001 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
1002 | V4L2_FIELD_INTERLACED, | ||
1003 | sizeof(struct cx88_buffer), | ||
1004 | fh, NULL); | ||
1005 | |||
1006 | /* FIXME: locking against other video device */ | ||
1007 | cx88_set_scale(dev->core, dev->width, dev->height, | ||
1008 | fh->mpegq.field); | ||
1009 | |||
1010 | dev->core->mpeg_users++; | ||
1011 | mutex_unlock(&dev->core->lock); | ||
1012 | v4l2_fh_add(&fh->fh); | ||
1013 | return 0; | ||
1014 | } | ||
1015 | |||
1016 | static int mpeg_release(struct file *file) | ||
1017 | { | ||
1018 | struct cx8802_fh *fh = file->private_data; | ||
1019 | struct cx8802_dev *dev = fh->dev; | ||
1020 | struct cx8802_driver *drv = NULL; | ||
1021 | |||
1022 | mutex_lock(&dev->core->lock); | ||
1023 | |||
1024 | if (dev->mpeg_active && dev->core->mpeg_users == 1) | ||
1025 | blackbird_stop_codec(dev); | ||
1026 | |||
1027 | cx8802_cancel_buffers(fh->dev); | ||
1028 | /* stop mpeg capture */ | ||
1029 | videobuf_stop(&fh->mpegq); | ||
1030 | |||
1031 | videobuf_mmap_free(&fh->mpegq); | ||
1032 | |||
1033 | v4l2_fh_del(&fh->fh); | ||
1034 | v4l2_fh_exit(&fh->fh); | ||
1035 | file->private_data = NULL; | ||
1036 | kfree(fh); | ||
1037 | |||
1038 | /* Make sure we release the hardware */ | ||
1039 | drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); | ||
1040 | WARN_ON(!drv); | ||
1041 | if (drv) | ||
1042 | drv->request_release(drv); | ||
1043 | |||
1044 | dev->core->mpeg_users--; | ||
1045 | |||
1046 | mutex_unlock(&dev->core->lock); | ||
1047 | |||
1048 | return 0; | ||
1049 | } | ||
1050 | |||
1051 | static ssize_t | ||
1052 | mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | ||
1053 | { | ||
1054 | struct cx8802_fh *fh = file->private_data; | ||
1055 | struct cx8802_dev *dev = fh->dev; | ||
1056 | |||
1057 | if (!dev->mpeg_active) | ||
1058 | blackbird_start_codec(file, fh); | ||
1059 | |||
1060 | return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0, | ||
1061 | file->f_flags & O_NONBLOCK); | ||
1062 | } | ||
1063 | |||
1064 | static unsigned int | ||
1065 | mpeg_poll(struct file *file, struct poll_table_struct *wait) | ||
1066 | { | ||
1067 | unsigned long req_events = poll_requested_events(wait); | ||
1068 | struct cx8802_fh *fh = file->private_data; | ||
1069 | struct cx8802_dev *dev = fh->dev; | ||
1070 | |||
1071 | if (!dev->mpeg_active && (req_events & (POLLIN | POLLRDNORM))) | ||
1072 | blackbird_start_codec(file, fh); | ||
1073 | |||
1074 | return v4l2_ctrl_poll(file, wait) | videobuf_poll_stream(file, &fh->mpegq, wait); | ||
1075 | } | ||
1076 | |||
1077 | static int | ||
1078 | mpeg_mmap(struct file *file, struct vm_area_struct * vma) | ||
1079 | { | ||
1080 | struct cx8802_fh *fh = file->private_data; | ||
1081 | 1009 | ||
1082 | return videobuf_mmap_mapper(&fh->mpegq, vma); | 1010 | return cx88_set_tvnorm(core, id); |
1083 | } | 1011 | } |
1084 | 1012 | ||
1085 | static const struct v4l2_file_operations mpeg_fops = | 1013 | static const struct v4l2_file_operations mpeg_fops = |
1086 | { | 1014 | { |
1087 | .owner = THIS_MODULE, | 1015 | .owner = THIS_MODULE, |
1088 | .open = mpeg_open, | 1016 | .open = v4l2_fh_open, |
1089 | .release = mpeg_release, | 1017 | .release = vb2_fop_release, |
1090 | .read = mpeg_read, | 1018 | .read = vb2_fop_read, |
1091 | .poll = mpeg_poll, | 1019 | .poll = vb2_fop_poll, |
1092 | .mmap = mpeg_mmap, | 1020 | .mmap = vb2_fop_mmap, |
1093 | .unlocked_ioctl = video_ioctl2, | 1021 | .unlocked_ioctl = video_ioctl2, |
1094 | }; | 1022 | }; |
1095 | 1023 | ||
@@ -1099,12 +1027,12 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | |||
1099 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | 1027 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
1100 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | 1028 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
1101 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | 1029 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
1102 | .vidioc_reqbufs = vidioc_reqbufs, | 1030 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1103 | .vidioc_querybuf = vidioc_querybuf, | 1031 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1104 | .vidioc_qbuf = vidioc_qbuf, | 1032 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1105 | .vidioc_dqbuf = vidioc_dqbuf, | 1033 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1106 | .vidioc_streamon = vidioc_streamon, | 1034 | .vidioc_streamon = vb2_ioctl_streamon, |
1107 | .vidioc_streamoff = vidioc_streamoff, | 1035 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1108 | .vidioc_s_frequency = vidioc_s_frequency, | 1036 | .vidioc_s_frequency = vidioc_s_frequency, |
1109 | .vidioc_log_status = vidioc_log_status, | 1037 | .vidioc_log_status = vidioc_log_status, |
1110 | .vidioc_enum_input = vidioc_enum_input, | 1038 | .vidioc_enum_input = vidioc_enum_input, |
@@ -1189,11 +1117,12 @@ static int blackbird_register_video(struct cx8802_dev *dev) | |||
1189 | { | 1117 | { |
1190 | int err; | 1118 | int err; |
1191 | 1119 | ||
1192 | dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, | 1120 | dev->mpeg_dev = cx88_vdev_init(dev->core, dev->pci, |
1193 | &cx8802_mpeg_template,"mpeg"); | 1121 | &cx8802_mpeg_template, "mpeg"); |
1194 | dev->mpeg_dev->ctrl_handler = &dev->cxhdl.hdl; | 1122 | dev->mpeg_dev->ctrl_handler = &dev->cxhdl.hdl; |
1195 | video_set_drvdata(dev->mpeg_dev, dev); | 1123 | video_set_drvdata(dev->mpeg_dev, dev); |
1196 | err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); | 1124 | dev->mpeg_dev->queue = &dev->vb2_mpegq; |
1125 | err = video_register_device(dev->mpeg_dev, VFL_TYPE_GRABBER, -1); | ||
1197 | if (err < 0) { | 1126 | if (err < 0) { |
1198 | printk(KERN_INFO "%s/2: can't register mpeg device\n", | 1127 | printk(KERN_INFO "%s/2: can't register mpeg device\n", |
1199 | dev->core->name); | 1128 | dev->core->name); |
@@ -1210,6 +1139,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1210 | { | 1139 | { |
1211 | struct cx88_core *core = drv->core; | 1140 | struct cx88_core *core = drv->core; |
1212 | struct cx8802_dev *dev = core->dvbdev; | 1141 | struct cx8802_dev *dev = core->dvbdev; |
1142 | struct vb2_queue *q; | ||
1213 | int err; | 1143 | int err; |
1214 | 1144 | ||
1215 | dprintk( 1, "%s\n", __func__); | 1145 | dprintk( 1, "%s\n", __func__); |
@@ -1223,15 +1153,9 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1223 | if (!(core->board.mpeg & CX88_MPEG_BLACKBIRD)) | 1153 | if (!(core->board.mpeg & CX88_MPEG_BLACKBIRD)) |
1224 | goto fail_core; | 1154 | goto fail_core; |
1225 | 1155 | ||
1226 | dev->width = 720; | ||
1227 | if (core->tvnorm & V4L2_STD_525_60) { | ||
1228 | dev->height = 480; | ||
1229 | } else { | ||
1230 | dev->height = 576; | ||
1231 | } | ||
1232 | dev->cxhdl.port = CX2341X_PORT_STREAMING; | 1156 | dev->cxhdl.port = CX2341X_PORT_STREAMING; |
1233 | dev->cxhdl.width = dev->width; | 1157 | dev->cxhdl.width = core->width; |
1234 | dev->cxhdl.height = dev->height; | 1158 | dev->cxhdl.height = core->height; |
1235 | dev->cxhdl.func = blackbird_mbox_func; | 1159 | dev->cxhdl.func = blackbird_mbox_func; |
1236 | dev->cxhdl.priv = dev; | 1160 | dev->cxhdl.priv = dev; |
1237 | err = cx2341x_handler_init(&dev->cxhdl, 36); | 1161 | err = cx2341x_handler_init(&dev->cxhdl, 36); |
@@ -1250,13 +1174,30 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1250 | // init_controls(core); | 1174 | // init_controls(core); |
1251 | cx88_set_tvnorm(core,core->tvnorm); | 1175 | cx88_set_tvnorm(core,core->tvnorm); |
1252 | cx88_video_mux(core,0); | 1176 | cx88_video_mux(core,0); |
1253 | cx2341x_handler_set_50hz(&dev->cxhdl, dev->height == 576); | 1177 | cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576); |
1254 | cx2341x_handler_setup(&dev->cxhdl); | 1178 | cx2341x_handler_setup(&dev->cxhdl); |
1179 | |||
1180 | q = &dev->vb2_mpegq; | ||
1181 | q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1182 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; | ||
1183 | q->gfp_flags = GFP_DMA32; | ||
1184 | q->min_buffers_needed = 2; | ||
1185 | q->drv_priv = dev; | ||
1186 | q->buf_struct_size = sizeof(struct cx88_buffer); | ||
1187 | q->ops = &blackbird_qops; | ||
1188 | q->mem_ops = &vb2_dma_sg_memops; | ||
1189 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1190 | q->lock = &core->lock; | ||
1191 | |||
1192 | err = vb2_queue_init(q); | ||
1193 | if (err < 0) | ||
1194 | goto fail_core; | ||
1195 | |||
1255 | blackbird_register_video(dev); | 1196 | blackbird_register_video(dev); |
1256 | 1197 | ||
1257 | return 0; | 1198 | return 0; |
1258 | 1199 | ||
1259 | fail_core: | 1200 | fail_core: |
1260 | return err; | 1201 | return err; |
1261 | } | 1202 | } |
1262 | 1203 | ||
diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c index 851754bf1291..8f2556ec3971 100644 --- a/drivers/media/pci/cx88/cx88-cards.c +++ b/drivers/media/pci/cx88/cx88-cards.c | |||
@@ -347,7 +347,7 @@ static const struct cx88_board cx88_boards[] = { | |||
347 | }, | 347 | }, |
348 | [CX88_BOARD_IODATA_GVVCP3PCI] = { | 348 | [CX88_BOARD_IODATA_GVVCP3PCI] = { |
349 | .name = "IODATA GV-VCP3/PCI", | 349 | .name = "IODATA GV-VCP3/PCI", |
350 | .tuner_type = TUNER_ABSENT, | 350 | .tuner_type = UNSET, |
351 | .radio_type = UNSET, | 351 | .radio_type = UNSET, |
352 | .tuner_addr = ADDR_UNSET, | 352 | .tuner_addr = ADDR_UNSET, |
353 | .radio_addr = ADDR_UNSET, | 353 | .radio_addr = ADDR_UNSET, |
@@ -436,7 +436,7 @@ static const struct cx88_board cx88_boards[] = { | |||
436 | }, | 436 | }, |
437 | [CX88_BOARD_KWORLD_DVB_T] = { | 437 | [CX88_BOARD_KWORLD_DVB_T] = { |
438 | .name = "KWorld/VStream XPert DVB-T", | 438 | .name = "KWorld/VStream XPert DVB-T", |
439 | .tuner_type = TUNER_ABSENT, | 439 | .tuner_type = UNSET, |
440 | .radio_type = UNSET, | 440 | .radio_type = UNSET, |
441 | .tuner_addr = ADDR_UNSET, | 441 | .tuner_addr = ADDR_UNSET, |
442 | .radio_addr = ADDR_UNSET, | 442 | .radio_addr = ADDR_UNSET, |
@@ -455,7 +455,7 @@ static const struct cx88_board cx88_boards[] = { | |||
455 | }, | 455 | }, |
456 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = { | 456 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = { |
457 | .name = "DViCO FusionHDTV DVB-T1", | 457 | .name = "DViCO FusionHDTV DVB-T1", |
458 | .tuner_type = TUNER_ABSENT, /* No analog tuner */ | 458 | .tuner_type = UNSET, /* No analog tuner */ |
459 | .radio_type = UNSET, | 459 | .radio_type = UNSET, |
460 | .tuner_addr = ADDR_UNSET, | 460 | .tuner_addr = ADDR_UNSET, |
461 | .radio_addr = ADDR_UNSET, | 461 | .radio_addr = ADDR_UNSET, |
@@ -542,7 +542,7 @@ static const struct cx88_board cx88_boards[] = { | |||
542 | }, | 542 | }, |
543 | [CX88_BOARD_HAUPPAUGE_DVB_T1] = { | 543 | [CX88_BOARD_HAUPPAUGE_DVB_T1] = { |
544 | .name = "Hauppauge Nova-T DVB-T", | 544 | .name = "Hauppauge Nova-T DVB-T", |
545 | .tuner_type = TUNER_ABSENT, | 545 | .tuner_type = UNSET, |
546 | .radio_type = UNSET, | 546 | .radio_type = UNSET, |
547 | .tuner_addr = ADDR_UNSET, | 547 | .tuner_addr = ADDR_UNSET, |
548 | .radio_addr = ADDR_UNSET, | 548 | .radio_addr = ADDR_UNSET, |
@@ -554,7 +554,7 @@ static const struct cx88_board cx88_boards[] = { | |||
554 | }, | 554 | }, |
555 | [CX88_BOARD_CONEXANT_DVB_T1] = { | 555 | [CX88_BOARD_CONEXANT_DVB_T1] = { |
556 | .name = "Conexant DVB-T reference design", | 556 | .name = "Conexant DVB-T reference design", |
557 | .tuner_type = TUNER_ABSENT, | 557 | .tuner_type = UNSET, |
558 | .radio_type = UNSET, | 558 | .radio_type = UNSET, |
559 | .tuner_addr = ADDR_UNSET, | 559 | .tuner_addr = ADDR_UNSET, |
560 | .radio_addr = ADDR_UNSET, | 560 | .radio_addr = ADDR_UNSET, |
@@ -579,7 +579,7 @@ static const struct cx88_board cx88_boards[] = { | |||
579 | }, | 579 | }, |
580 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = { | 580 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = { |
581 | .name = "DViCO FusionHDTV DVB-T Plus", | 581 | .name = "DViCO FusionHDTV DVB-T Plus", |
582 | .tuner_type = TUNER_ABSENT, /* No analog tuner */ | 582 | .tuner_type = UNSET, /* No analog tuner */ |
583 | .radio_type = UNSET, | 583 | .radio_type = UNSET, |
584 | .tuner_addr = ADDR_UNSET, | 584 | .tuner_addr = ADDR_UNSET, |
585 | .radio_addr = ADDR_UNSET, | 585 | .radio_addr = ADDR_UNSET, |
@@ -596,7 +596,7 @@ static const struct cx88_board cx88_boards[] = { | |||
596 | }, | 596 | }, |
597 | [CX88_BOARD_DNTV_LIVE_DVB_T] = { | 597 | [CX88_BOARD_DNTV_LIVE_DVB_T] = { |
598 | .name = "digitalnow DNTV Live! DVB-T", | 598 | .name = "digitalnow DNTV Live! DVB-T", |
599 | .tuner_type = TUNER_ABSENT, | 599 | .tuner_type = UNSET, |
600 | .radio_type = UNSET, | 600 | .radio_type = UNSET, |
601 | .tuner_addr = ADDR_UNSET, | 601 | .tuner_addr = ADDR_UNSET, |
602 | .radio_addr = ADDR_UNSET, | 602 | .radio_addr = ADDR_UNSET, |
@@ -787,7 +787,7 @@ static const struct cx88_board cx88_boards[] = { | |||
787 | }, | 787 | }, |
788 | [CX88_BOARD_ADSTECH_DVB_T_PCI] = { | 788 | [CX88_BOARD_ADSTECH_DVB_T_PCI] = { |
789 | .name = "ADS Tech Instant TV DVB-T PCI", | 789 | .name = "ADS Tech Instant TV DVB-T PCI", |
790 | .tuner_type = TUNER_ABSENT, | 790 | .tuner_type = UNSET, |
791 | .radio_type = UNSET, | 791 | .radio_type = UNSET, |
792 | .tuner_addr = ADDR_UNSET, | 792 | .tuner_addr = ADDR_UNSET, |
793 | .radio_addr = ADDR_UNSET, | 793 | .radio_addr = ADDR_UNSET, |
@@ -806,7 +806,7 @@ static const struct cx88_board cx88_boards[] = { | |||
806 | }, | 806 | }, |
807 | [CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1] = { | 807 | [CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1] = { |
808 | .name = "TerraTec Cinergy 1400 DVB-T", | 808 | .name = "TerraTec Cinergy 1400 DVB-T", |
809 | .tuner_type = TUNER_ABSENT, | 809 | .tuner_type = UNSET, |
810 | .input = { { | 810 | .input = { { |
811 | .type = CX88_VMUX_DVB, | 811 | .type = CX88_VMUX_DVB, |
812 | .vmux = 0, | 812 | .vmux = 0, |
@@ -924,7 +924,7 @@ static const struct cx88_board cx88_boards[] = { | |||
924 | }, | 924 | }, |
925 | [CX88_BOARD_WINFAST_DTV1000] = { | 925 | [CX88_BOARD_WINFAST_DTV1000] = { |
926 | .name = "WinFast DTV1000-T", | 926 | .name = "WinFast DTV1000-T", |
927 | .tuner_type = TUNER_ABSENT, | 927 | .tuner_type = UNSET, |
928 | .radio_type = UNSET, | 928 | .radio_type = UNSET, |
929 | .tuner_addr = ADDR_UNSET, | 929 | .tuner_addr = ADDR_UNSET, |
930 | .radio_addr = ADDR_UNSET, | 930 | .radio_addr = ADDR_UNSET, |
@@ -972,7 +972,7 @@ static const struct cx88_board cx88_boards[] = { | |||
972 | }, | 972 | }, |
973 | [CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1] = { | 973 | [CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1] = { |
974 | .name = "Hauppauge Nova-S-Plus DVB-S", | 974 | .name = "Hauppauge Nova-S-Plus DVB-S", |
975 | .tuner_type = TUNER_ABSENT, | 975 | .tuner_type = UNSET, |
976 | .radio_type = UNSET, | 976 | .radio_type = UNSET, |
977 | .tuner_addr = ADDR_UNSET, | 977 | .tuner_addr = ADDR_UNSET, |
978 | .radio_addr = ADDR_UNSET, | 978 | .radio_addr = ADDR_UNSET, |
@@ -998,7 +998,7 @@ static const struct cx88_board cx88_boards[] = { | |||
998 | }, | 998 | }, |
999 | [CX88_BOARD_HAUPPAUGE_NOVASE2_S1] = { | 999 | [CX88_BOARD_HAUPPAUGE_NOVASE2_S1] = { |
1000 | .name = "Hauppauge Nova-SE2 DVB-S", | 1000 | .name = "Hauppauge Nova-SE2 DVB-S", |
1001 | .tuner_type = TUNER_ABSENT, | 1001 | .tuner_type = UNSET, |
1002 | .radio_type = UNSET, | 1002 | .radio_type = UNSET, |
1003 | .tuner_addr = ADDR_UNSET, | 1003 | .tuner_addr = ADDR_UNSET, |
1004 | .radio_addr = ADDR_UNSET, | 1004 | .radio_addr = ADDR_UNSET, |
@@ -1010,7 +1010,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1010 | }, | 1010 | }, |
1011 | [CX88_BOARD_KWORLD_DVBS_100] = { | 1011 | [CX88_BOARD_KWORLD_DVBS_100] = { |
1012 | .name = "KWorld DVB-S 100", | 1012 | .name = "KWorld DVB-S 100", |
1013 | .tuner_type = TUNER_ABSENT, | 1013 | .tuner_type = UNSET, |
1014 | .radio_type = UNSET, | 1014 | .radio_type = UNSET, |
1015 | .tuner_addr = ADDR_UNSET, | 1015 | .tuner_addr = ADDR_UNSET, |
1016 | .radio_addr = ADDR_UNSET, | 1016 | .radio_addr = ADDR_UNSET, |
@@ -1102,7 +1102,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1102 | /* DTT 7579 Conexant CX22702-19 Conexant CX2388x */ | 1102 | /* DTT 7579 Conexant CX22702-19 Conexant CX2388x */ |
1103 | /* Manenti Marco <marco_manenti@colman.it> */ | 1103 | /* Manenti Marco <marco_manenti@colman.it> */ |
1104 | .name = "KWorld/VStream XPert DVB-T with cx22702", | 1104 | .name = "KWorld/VStream XPert DVB-T with cx22702", |
1105 | .tuner_type = TUNER_ABSENT, | 1105 | .tuner_type = UNSET, |
1106 | .radio_type = UNSET, | 1106 | .radio_type = UNSET, |
1107 | .tuner_addr = ADDR_UNSET, | 1107 | .tuner_addr = ADDR_UNSET, |
1108 | .radio_addr = ADDR_UNSET, | 1108 | .radio_addr = ADDR_UNSET, |
@@ -1121,7 +1121,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1121 | }, | 1121 | }, |
1122 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL] = { | 1122 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL] = { |
1123 | .name = "DViCO FusionHDTV DVB-T Dual Digital", | 1123 | .name = "DViCO FusionHDTV DVB-T Dual Digital", |
1124 | .tuner_type = TUNER_ABSENT, /* No analog tuner */ | 1124 | .tuner_type = UNSET, /* No analog tuner */ |
1125 | .radio_type = UNSET, | 1125 | .radio_type = UNSET, |
1126 | .tuner_addr = ADDR_UNSET, | 1126 | .tuner_addr = ADDR_UNSET, |
1127 | .radio_addr = ADDR_UNSET, | 1127 | .radio_addr = ADDR_UNSET, |
@@ -1356,7 +1356,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1356 | }, | 1356 | }, |
1357 | [CX88_BOARD_GENIATECH_DVBS] = { | 1357 | [CX88_BOARD_GENIATECH_DVBS] = { |
1358 | .name = "Geniatech DVB-S", | 1358 | .name = "Geniatech DVB-S", |
1359 | .tuner_type = TUNER_ABSENT, | 1359 | .tuner_type = UNSET, |
1360 | .radio_type = UNSET, | 1360 | .radio_type = UNSET, |
1361 | .tuner_addr = ADDR_UNSET, | 1361 | .tuner_addr = ADDR_UNSET, |
1362 | .radio_addr = ADDR_UNSET, | 1362 | .radio_addr = ADDR_UNSET, |
@@ -1494,7 +1494,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1494 | }, | 1494 | }, |
1495 | [CX88_BOARD_SAMSUNG_SMT_7020] = { | 1495 | [CX88_BOARD_SAMSUNG_SMT_7020] = { |
1496 | .name = "Samsung SMT 7020 DVB-S", | 1496 | .name = "Samsung SMT 7020 DVB-S", |
1497 | .tuner_type = TUNER_ABSENT, | 1497 | .tuner_type = UNSET, |
1498 | .radio_type = UNSET, | 1498 | .radio_type = UNSET, |
1499 | .tuner_addr = ADDR_UNSET, | 1499 | .tuner_addr = ADDR_UNSET, |
1500 | .radio_addr = ADDR_UNSET, | 1500 | .radio_addr = ADDR_UNSET, |
@@ -1506,7 +1506,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1506 | }, | 1506 | }, |
1507 | [CX88_BOARD_ADSTECH_PTV_390] = { | 1507 | [CX88_BOARD_ADSTECH_PTV_390] = { |
1508 | .name = "ADS Tech Instant Video PCI", | 1508 | .name = "ADS Tech Instant Video PCI", |
1509 | .tuner_type = TUNER_ABSENT, | 1509 | .tuner_type = UNSET, |
1510 | .radio_type = UNSET, | 1510 | .radio_type = UNSET, |
1511 | .tuner_addr = ADDR_UNSET, | 1511 | .tuner_addr = ADDR_UNSET, |
1512 | .radio_addr = ADDR_UNSET, | 1512 | .radio_addr = ADDR_UNSET, |
@@ -1553,7 +1553,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1553 | [CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO] = { | 1553 | [CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO] = { |
1554 | .name = "DViCO FusionHDTV 5 PCI nano", | 1554 | .name = "DViCO FusionHDTV 5 PCI nano", |
1555 | /* xc3008 tuner, digital only for now */ | 1555 | /* xc3008 tuner, digital only for now */ |
1556 | .tuner_type = TUNER_ABSENT, | 1556 | .tuner_type = UNSET, |
1557 | .radio_type = UNSET, | 1557 | .radio_type = UNSET, |
1558 | .tuner_addr = ADDR_UNSET, | 1558 | .tuner_addr = ADDR_UNSET, |
1559 | .radio_addr = ADDR_UNSET, | 1559 | .radio_addr = ADDR_UNSET, |
@@ -2069,7 +2069,7 @@ static const struct cx88_board cx88_boards[] = { | |||
2069 | }, | 2069 | }, |
2070 | [CX88_BOARD_TBS_8920] = { | 2070 | [CX88_BOARD_TBS_8920] = { |
2071 | .name = "TBS 8920 DVB-S/S2", | 2071 | .name = "TBS 8920 DVB-S/S2", |
2072 | .tuner_type = TUNER_ABSENT, | 2072 | .tuner_type = UNSET, |
2073 | .radio_type = UNSET, | 2073 | .radio_type = UNSET, |
2074 | .tuner_addr = ADDR_UNSET, | 2074 | .tuner_addr = ADDR_UNSET, |
2075 | .radio_addr = ADDR_UNSET, | 2075 | .radio_addr = ADDR_UNSET, |
@@ -2304,7 +2304,7 @@ static const struct cx88_board cx88_boards[] = { | |||
2304 | }, | 2304 | }, |
2305 | [CX88_BOARD_TWINHAN_VP1027_DVBS] = { | 2305 | [CX88_BOARD_TWINHAN_VP1027_DVBS] = { |
2306 | .name = "Twinhan VP-1027 DVB-S", | 2306 | .name = "Twinhan VP-1027 DVB-S", |
2307 | .tuner_type = TUNER_ABSENT, | 2307 | .tuner_type = UNSET, |
2308 | .radio_type = UNSET, | 2308 | .radio_type = UNSET, |
2309 | .tuner_addr = ADDR_UNSET, | 2309 | .tuner_addr = ADDR_UNSET, |
2310 | .radio_addr = ADDR_UNSET, | 2310 | .radio_addr = ADDR_UNSET, |
@@ -2921,33 +2921,33 @@ static const struct { | |||
2921 | int fm; | 2921 | int fm; |
2922 | const char *name; | 2922 | const char *name; |
2923 | } gdi_tuner[] = { | 2923 | } gdi_tuner[] = { |
2924 | [ 0x01 ] = { .id = TUNER_ABSENT, | 2924 | [ 0x01 ] = { .id = UNSET, |
2925 | .name = "NTSC_M" }, | 2925 | .name = "NTSC_M" }, |
2926 | [ 0x02 ] = { .id = TUNER_ABSENT, | 2926 | [ 0x02 ] = { .id = UNSET, |
2927 | .name = "PAL_B" }, | 2927 | .name = "PAL_B" }, |
2928 | [ 0x03 ] = { .id = TUNER_ABSENT, | 2928 | [ 0x03 ] = { .id = UNSET, |
2929 | .name = "PAL_I" }, | 2929 | .name = "PAL_I" }, |
2930 | [ 0x04 ] = { .id = TUNER_ABSENT, | 2930 | [ 0x04 ] = { .id = UNSET, |
2931 | .name = "PAL_D" }, | 2931 | .name = "PAL_D" }, |
2932 | [ 0x05 ] = { .id = TUNER_ABSENT, | 2932 | [ 0x05 ] = { .id = UNSET, |
2933 | .name = "SECAM" }, | 2933 | .name = "SECAM" }, |
2934 | 2934 | ||
2935 | [ 0x10 ] = { .id = TUNER_ABSENT, | 2935 | [ 0x10 ] = { .id = UNSET, |
2936 | .fm = 1, | 2936 | .fm = 1, |
2937 | .name = "TEMIC_4049" }, | 2937 | .name = "TEMIC_4049" }, |
2938 | [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5, | 2938 | [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5, |
2939 | .name = "TEMIC_4136" }, | 2939 | .name = "TEMIC_4136" }, |
2940 | [ 0x12 ] = { .id = TUNER_ABSENT, | 2940 | [ 0x12 ] = { .id = UNSET, |
2941 | .name = "TEMIC_4146" }, | 2941 | .name = "TEMIC_4146" }, |
2942 | 2942 | ||
2943 | [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME, | 2943 | [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME, |
2944 | .fm = 1, | 2944 | .fm = 1, |
2945 | .name = "PHILIPS_FQ1216_MK3" }, | 2945 | .name = "PHILIPS_FQ1216_MK3" }, |
2946 | [ 0x21 ] = { .id = TUNER_ABSENT, .fm = 1, | 2946 | [ 0x21 ] = { .id = UNSET, .fm = 1, |
2947 | .name = "PHILIPS_FQ1236_MK3" }, | 2947 | .name = "PHILIPS_FQ1236_MK3" }, |
2948 | [ 0x22 ] = { .id = TUNER_ABSENT, | 2948 | [ 0x22 ] = { .id = UNSET, |
2949 | .name = "PHILIPS_FI1236_MK3" }, | 2949 | .name = "PHILIPS_FI1236_MK3" }, |
2950 | [ 0x23 ] = { .id = TUNER_ABSENT, | 2950 | [ 0x23 ] = { .id = UNSET, |
2951 | .name = "PHILIPS_FI1216_MK3" }, | 2951 | .name = "PHILIPS_FI1216_MK3" }, |
2952 | }; | 2952 | }; |
2953 | 2953 | ||
@@ -3564,7 +3564,7 @@ static void cx88_card_setup(struct cx88_core *core) | |||
3564 | mode_mask &= ~T_RADIO; | 3564 | mode_mask &= ~T_RADIO; |
3565 | } | 3565 | } |
3566 | 3566 | ||
3567 | if (core->board.tuner_type != TUNER_ABSENT) { | 3567 | if (core->board.tuner_type != UNSET) { |
3568 | tun_setup.mode_mask = mode_mask; | 3568 | tun_setup.mode_mask = mode_mask; |
3569 | tun_setup.type = core->board.tuner_type; | 3569 | tun_setup.type = core->board.tuner_type; |
3570 | tun_setup.addr = core->board.tuner_addr; | 3570 | tun_setup.addr = core->board.tuner_addr; |
@@ -3691,6 +3691,11 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
3691 | core->nr = nr; | 3691 | core->nr = nr; |
3692 | sprintf(core->name, "cx88[%d]", core->nr); | 3692 | sprintf(core->name, "cx88[%d]", core->nr); |
3693 | 3693 | ||
3694 | core->tvnorm = V4L2_STD_NTSC_M; | ||
3695 | core->width = 320; | ||
3696 | core->height = 240; | ||
3697 | core->field = V4L2_FIELD_INTERLACED; | ||
3698 | |||
3694 | strcpy(core->v4l2_dev.name, core->name); | 3699 | strcpy(core->v4l2_dev.name, core->name); |
3695 | if (v4l2_device_register(NULL, &core->v4l2_dev)) { | 3700 | if (v4l2_device_register(NULL, &core->v4l2_dev)) { |
3696 | kfree(core); | 3701 | kfree(core); |
@@ -3772,7 +3777,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
3772 | cx88_i2c_init(core, pci); | 3777 | cx88_i2c_init(core, pci); |
3773 | 3778 | ||
3774 | /* load tuner module, if needed */ | 3779 | /* load tuner module, if needed */ |
3775 | if (TUNER_ABSENT != core->board.tuner_type) { | 3780 | if (UNSET != core->board.tuner_type) { |
3776 | /* Ignore 0x6b and 0x6f on cx88 boards. | 3781 | /* Ignore 0x6b and 0x6f on cx88 boards. |
3777 | * FusionHDTV5 RT Gold has an ir receiver at 0x6b | 3782 | * FusionHDTV5 RT Gold has an ir receiver at 0x6b |
3778 | * and an RTC at 0x6f which can get corrupted if probed. */ | 3783 | * and an RTC at 0x6f which can get corrupted if probed. */ |
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c index 71630238027b..dee177ed5fe9 100644 --- a/drivers/media/pci/cx88/cx88-core.c +++ b/drivers/media/pci/cx88/cx88-core.c | |||
@@ -76,11 +76,16 @@ static DEFINE_MUTEX(devlist); | |||
76 | static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, | 76 | static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, |
77 | unsigned int offset, u32 sync_line, | 77 | unsigned int offset, u32 sync_line, |
78 | unsigned int bpl, unsigned int padding, | 78 | unsigned int bpl, unsigned int padding, |
79 | unsigned int lines, unsigned int lpi) | 79 | unsigned int lines, unsigned int lpi, bool jump) |
80 | { | 80 | { |
81 | struct scatterlist *sg; | 81 | struct scatterlist *sg; |
82 | unsigned int line,todo,sol; | 82 | unsigned int line,todo,sol; |
83 | 83 | ||
84 | if (jump) { | ||
85 | (*rp++) = cpu_to_le32(RISC_JUMP); | ||
86 | (*rp++) = 0; | ||
87 | } | ||
88 | |||
84 | /* sync instruction */ | 89 | /* sync instruction */ |
85 | if (sync_line != NO_SYNC_LINE) | 90 | if (sync_line != NO_SYNC_LINE) |
86 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); | 91 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); |
@@ -90,7 +95,7 @@ static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, | |||
90 | for (line = 0; line < lines; line++) { | 95 | for (line = 0; line < lines; line++) { |
91 | while (offset && offset >= sg_dma_len(sg)) { | 96 | while (offset && offset >= sg_dma_len(sg)) { |
92 | offset -= sg_dma_len(sg); | 97 | offset -= sg_dma_len(sg); |
93 | sg++; | 98 | sg = sg_next(sg); |
94 | } | 99 | } |
95 | if (lpi && line>0 && !(line % lpi)) | 100 | if (lpi && line>0 && !(line % lpi)) |
96 | sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; | 101 | sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; |
@@ -109,13 +114,13 @@ static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, | |||
109 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | 114 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); |
110 | todo -= (sg_dma_len(sg)-offset); | 115 | todo -= (sg_dma_len(sg)-offset); |
111 | offset = 0; | 116 | offset = 0; |
112 | sg++; | 117 | sg = sg_next(sg); |
113 | while (todo > sg_dma_len(sg)) { | 118 | while (todo > sg_dma_len(sg)) { |
114 | *(rp++)=cpu_to_le32(RISC_WRITE| | 119 | *(rp++)=cpu_to_le32(RISC_WRITE| |
115 | sg_dma_len(sg)); | 120 | sg_dma_len(sg)); |
116 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 121 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); |
117 | todo -= sg_dma_len(sg); | 122 | todo -= sg_dma_len(sg); |
118 | sg++; | 123 | sg = sg_next(sg); |
119 | } | 124 | } |
120 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); | 125 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); |
121 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 126 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); |
@@ -127,14 +132,13 @@ static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist, | |||
127 | return rp; | 132 | return rp; |
128 | } | 133 | } |
129 | 134 | ||
130 | int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | 135 | int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, |
131 | struct scatterlist *sglist, | 136 | struct scatterlist *sglist, |
132 | unsigned int top_offset, unsigned int bottom_offset, | 137 | unsigned int top_offset, unsigned int bottom_offset, |
133 | unsigned int bpl, unsigned int padding, unsigned int lines) | 138 | unsigned int bpl, unsigned int padding, unsigned int lines) |
134 | { | 139 | { |
135 | u32 instructions,fields; | 140 | u32 instructions,fields; |
136 | __le32 *rp; | 141 | __le32 *rp; |
137 | int rc; | ||
138 | 142 | ||
139 | fields = 0; | 143 | fields = 0; |
140 | if (UNSET != top_offset) | 144 | if (UNSET != top_offset) |
@@ -147,18 +151,21 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
147 | can cause next bpl to start close to a page border. First DMA | 151 | can cause next bpl to start close to a page border. First DMA |
148 | region may be smaller than PAGE_SIZE */ | 152 | region may be smaller than PAGE_SIZE */ |
149 | instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); | 153 | instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); |
150 | instructions += 2; | 154 | instructions += 4; |
151 | if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0) | 155 | risc->size = instructions * 8; |
152 | return rc; | 156 | risc->dma = 0; |
157 | risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); | ||
158 | if (NULL == risc->cpu) | ||
159 | return -ENOMEM; | ||
153 | 160 | ||
154 | /* write risc instructions */ | 161 | /* write risc instructions */ |
155 | rp = risc->cpu; | 162 | rp = risc->cpu; |
156 | if (UNSET != top_offset) | 163 | if (UNSET != top_offset) |
157 | rp = cx88_risc_field(rp, sglist, top_offset, 0, | 164 | rp = cx88_risc_field(rp, sglist, top_offset, 0, |
158 | bpl, padding, lines, 0); | 165 | bpl, padding, lines, 0, true); |
159 | if (UNSET != bottom_offset) | 166 | if (UNSET != bottom_offset) |
160 | rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200, | 167 | rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200, |
161 | bpl, padding, lines, 0); | 168 | bpl, padding, lines, 0, top_offset == UNSET); |
162 | 169 | ||
163 | /* save pointer to jmp instruction address */ | 170 | /* save pointer to jmp instruction address */ |
164 | risc->jmp = rp; | 171 | risc->jmp = rp; |
@@ -166,26 +173,28 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
166 | return 0; | 173 | return 0; |
167 | } | 174 | } |
168 | 175 | ||
169 | int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc, | 176 | int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, |
170 | struct scatterlist *sglist, unsigned int bpl, | 177 | struct scatterlist *sglist, unsigned int bpl, |
171 | unsigned int lines, unsigned int lpi) | 178 | unsigned int lines, unsigned int lpi) |
172 | { | 179 | { |
173 | u32 instructions; | 180 | u32 instructions; |
174 | __le32 *rp; | 181 | __le32 *rp; |
175 | int rc; | ||
176 | 182 | ||
177 | /* estimate risc mem: worst case is one write per page border + | 183 | /* estimate risc mem: worst case is one write per page border + |
178 | one write per scan line + syncs + jump (all 2 dwords). Here | 184 | one write per scan line + syncs + jump (all 2 dwords). Here |
179 | there is no padding and no sync. First DMA region may be smaller | 185 | there is no padding and no sync. First DMA region may be smaller |
180 | than PAGE_SIZE */ | 186 | than PAGE_SIZE */ |
181 | instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; | 187 | instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; |
182 | instructions += 1; | 188 | instructions += 3; |
183 | if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0) | 189 | risc->size = instructions * 8; |
184 | return rc; | 190 | risc->dma = 0; |
191 | risc->cpu = pci_zalloc_consistent(pci, risc->size, &risc->dma); | ||
192 | if (NULL == risc->cpu) | ||
193 | return -ENOMEM; | ||
185 | 194 | ||
186 | /* write risc instructions */ | 195 | /* write risc instructions */ |
187 | rp = risc->cpu; | 196 | rp = risc->cpu; |
188 | rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi); | 197 | rp = cx88_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi, !lpi); |
189 | 198 | ||
190 | /* save pointer to jmp instruction address */ | 199 | /* save pointer to jmp instruction address */ |
191 | risc->jmp = rp; | 200 | risc->jmp = rp; |
@@ -193,39 +202,6 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
193 | return 0; | 202 | return 0; |
194 | } | 203 | } |
195 | 204 | ||
196 | int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, | ||
197 | u32 reg, u32 mask, u32 value) | ||
198 | { | ||
199 | __le32 *rp; | ||
200 | int rc; | ||
201 | |||
202 | if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) | ||
203 | return rc; | ||
204 | |||
205 | /* write risc instructions */ | ||
206 | rp = risc->cpu; | ||
207 | *(rp++) = cpu_to_le32(RISC_WRITECR | RISC_IRQ2 | RISC_IMM); | ||
208 | *(rp++) = cpu_to_le32(reg); | ||
209 | *(rp++) = cpu_to_le32(value); | ||
210 | *(rp++) = cpu_to_le32(mask); | ||
211 | *(rp++) = cpu_to_le32(RISC_JUMP); | ||
212 | *(rp++) = cpu_to_le32(risc->dma); | ||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | void | ||
217 | cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf) | ||
218 | { | ||
219 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | ||
220 | |||
221 | BUG_ON(in_interrupt()); | ||
222 | videobuf_waiton(q, &buf->vb, 0, 0); | ||
223 | videobuf_dma_unmap(q->dev, dma); | ||
224 | videobuf_dma_free(dma); | ||
225 | btcx_riscmem_free(to_pci_dev(q->dev), &buf->risc); | ||
226 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
227 | } | ||
228 | |||
229 | /* ------------------------------------------------------------------ */ | 205 | /* ------------------------------------------------------------------ */ |
230 | /* our SRAM memory layout */ | 206 | /* our SRAM memory layout */ |
231 | 207 | ||
@@ -539,33 +515,12 @@ void cx88_wakeup(struct cx88_core *core, | |||
539 | struct cx88_dmaqueue *q, u32 count) | 515 | struct cx88_dmaqueue *q, u32 count) |
540 | { | 516 | { |
541 | struct cx88_buffer *buf; | 517 | struct cx88_buffer *buf; |
542 | int bc; | 518 | |
543 | 519 | buf = list_entry(q->active.next, | |
544 | for (bc = 0;; bc++) { | 520 | struct cx88_buffer, list); |
545 | if (list_empty(&q->active)) | 521 | v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); |
546 | break; | 522 | list_del(&buf->list); |
547 | buf = list_entry(q->active.next, | 523 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); |
548 | struct cx88_buffer, vb.queue); | ||
549 | /* count comes from the hw and is is 16bit wide -- | ||
550 | * this trick handles wrap-arounds correctly for | ||
551 | * up to 32767 buffers in flight... */ | ||
552 | if ((s16) (count - buf->count) < 0) | ||
553 | break; | ||
554 | v4l2_get_timestamp(&buf->vb.ts); | ||
555 | dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i, | ||
556 | count, buf->count); | ||
557 | buf->vb.state = VIDEOBUF_DONE; | ||
558 | list_del(&buf->vb.queue); | ||
559 | wake_up(&buf->vb.done); | ||
560 | } | ||
561 | if (list_empty(&q->active)) { | ||
562 | del_timer(&q->timeout); | ||
563 | } else { | ||
564 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
565 | } | ||
566 | if (bc != 1) | ||
567 | dprintk(2, "%s: %d buffers handled (should be 1)\n", | ||
568 | __func__, bc); | ||
569 | } | 524 | } |
570 | 525 | ||
571 | void cx88_shutdown(struct cx88_core *core) | 526 | void cx88_shutdown(struct cx88_core *core) |
@@ -909,6 +864,13 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) | |||
909 | u32 bdelay,agcdelay,htotal; | 864 | u32 bdelay,agcdelay,htotal; |
910 | u32 cxiformat, cxoformat; | 865 | u32 cxiformat, cxoformat; |
911 | 866 | ||
867 | if (norm == core->tvnorm) | ||
868 | return 0; | ||
869 | if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || | ||
870 | vb2_is_busy(&core->v4ldev->vb2_vbiq))) | ||
871 | return -EBUSY; | ||
872 | if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) | ||
873 | return -EBUSY; | ||
912 | core->tvnorm = norm; | 874 | core->tvnorm = norm; |
913 | fsc8 = norm_fsc8(norm); | 875 | fsc8 = norm_fsc8(norm); |
914 | adc_clock = xtal; | 876 | adc_clock = xtal; |
@@ -1043,6 +1005,7 @@ struct video_device *cx88_vdev_init(struct cx88_core *core, | |||
1043 | vfd->v4l2_dev = &core->v4l2_dev; | 1005 | vfd->v4l2_dev = &core->v4l2_dev; |
1044 | vfd->dev_parent = &pci->dev; | 1006 | vfd->dev_parent = &pci->dev; |
1045 | vfd->release = video_device_release; | 1007 | vfd->release = video_device_release; |
1008 | vfd->lock = &core->lock; | ||
1046 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", | 1009 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", |
1047 | core->name, type, core->board.name); | 1010 | core->name, type, core->board.name); |
1048 | return vfd; | 1011 | return vfd; |
@@ -1114,8 +1077,6 @@ EXPORT_SYMBOL(cx88_shutdown); | |||
1114 | 1077 | ||
1115 | EXPORT_SYMBOL(cx88_risc_buffer); | 1078 | EXPORT_SYMBOL(cx88_risc_buffer); |
1116 | EXPORT_SYMBOL(cx88_risc_databuffer); | 1079 | EXPORT_SYMBOL(cx88_risc_databuffer); |
1117 | EXPORT_SYMBOL(cx88_risc_stopper); | ||
1118 | EXPORT_SYMBOL(cx88_free_buffer); | ||
1119 | 1080 | ||
1120 | EXPORT_SYMBOL(cx88_sram_channels); | 1081 | EXPORT_SYMBOL(cx88_sram_channels); |
1121 | EXPORT_SYMBOL(cx88_sram_channel_setup); | 1082 | EXPORT_SYMBOL(cx88_sram_channel_setup); |
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c index 053ed1ba1d85..c344bfd0b896 100644 --- a/drivers/media/pci/cx88/cx88-dvb.c +++ b/drivers/media/pci/cx88/cx88-dvb.c | |||
@@ -82,43 +82,89 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | |||
82 | 82 | ||
83 | /* ------------------------------------------------------------------ */ | 83 | /* ------------------------------------------------------------------ */ |
84 | 84 | ||
85 | static int dvb_buf_setup(struct videobuf_queue *q, | 85 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
86 | unsigned int *count, unsigned int *size) | 86 | unsigned int *num_buffers, unsigned int *num_planes, |
87 | unsigned int sizes[], void *alloc_ctxs[]) | ||
87 | { | 88 | { |
88 | struct cx8802_dev *dev = q->priv_data; | 89 | struct cx8802_dev *dev = q->drv_priv; |
89 | 90 | ||
91 | *num_planes = 1; | ||
90 | dev->ts_packet_size = 188 * 4; | 92 | dev->ts_packet_size = 188 * 4; |
91 | dev->ts_packet_count = dvb_buf_tscnt; | 93 | dev->ts_packet_count = dvb_buf_tscnt; |
92 | 94 | sizes[0] = dev->ts_packet_size * dev->ts_packet_count; | |
93 | *size = dev->ts_packet_size * dev->ts_packet_count; | 95 | *num_buffers = dvb_buf_tscnt; |
94 | *count = dvb_buf_tscnt; | ||
95 | return 0; | 96 | return 0; |
96 | } | 97 | } |
97 | 98 | ||
98 | static int dvb_buf_prepare(struct videobuf_queue *q, | 99 | static int buffer_prepare(struct vb2_buffer *vb) |
99 | struct videobuf_buffer *vb, enum v4l2_field field) | 100 | { |
101 | struct cx8802_dev *dev = vb->vb2_queue->drv_priv; | ||
102 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
103 | |||
104 | return cx8802_buf_prepare(vb->vb2_queue, dev, buf); | ||
105 | } | ||
106 | |||
107 | static void buffer_finish(struct vb2_buffer *vb) | ||
108 | { | ||
109 | struct cx8802_dev *dev = vb->vb2_queue->drv_priv; | ||
110 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
111 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
112 | struct cx88_riscmem *risc = &buf->risc; | ||
113 | |||
114 | if (risc->cpu) | ||
115 | pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); | ||
116 | memset(risc, 0, sizeof(*risc)); | ||
117 | |||
118 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
119 | } | ||
120 | |||
121 | static void buffer_queue(struct vb2_buffer *vb) | ||
100 | { | 122 | { |
101 | struct cx8802_dev *dev = q->priv_data; | 123 | struct cx8802_dev *dev = vb->vb2_queue->drv_priv; |
102 | return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field); | 124 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); |
125 | |||
126 | cx8802_buf_queue(dev, buf); | ||
103 | } | 127 | } |
104 | 128 | ||
105 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | 129 | static int start_streaming(struct vb2_queue *q, unsigned int count) |
106 | { | 130 | { |
107 | struct cx8802_dev *dev = q->priv_data; | 131 | struct cx8802_dev *dev = q->drv_priv; |
108 | cx8802_buf_queue(dev, (struct cx88_buffer*)vb); | 132 | struct cx88_dmaqueue *dmaq = &dev->mpegq; |
133 | struct cx88_buffer *buf; | ||
134 | |||
135 | buf = list_entry(dmaq->active.next, struct cx88_buffer, list); | ||
136 | cx8802_start_dma(dev, dmaq, buf); | ||
137 | return 0; | ||
109 | } | 138 | } |
110 | 139 | ||
111 | static void dvb_buf_release(struct videobuf_queue *q, | 140 | static void stop_streaming(struct vb2_queue *q) |
112 | struct videobuf_buffer *vb) | ||
113 | { | 141 | { |
114 | cx88_free_buffer(q, (struct cx88_buffer*)vb); | 142 | struct cx8802_dev *dev = q->drv_priv; |
143 | struct cx88_dmaqueue *dmaq = &dev->mpegq; | ||
144 | unsigned long flags; | ||
145 | |||
146 | cx8802_cancel_buffers(dev); | ||
147 | |||
148 | spin_lock_irqsave(&dev->slock, flags); | ||
149 | while (!list_empty(&dmaq->active)) { | ||
150 | struct cx88_buffer *buf = list_entry(dmaq->active.next, | ||
151 | struct cx88_buffer, list); | ||
152 | |||
153 | list_del(&buf->list); | ||
154 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
155 | } | ||
156 | spin_unlock_irqrestore(&dev->slock, flags); | ||
115 | } | 157 | } |
116 | 158 | ||
117 | static const struct videobuf_queue_ops dvb_qops = { | 159 | static struct vb2_ops dvb_qops = { |
118 | .buf_setup = dvb_buf_setup, | 160 | .queue_setup = queue_setup, |
119 | .buf_prepare = dvb_buf_prepare, | 161 | .buf_prepare = buffer_prepare, |
120 | .buf_queue = dvb_buf_queue, | 162 | .buf_finish = buffer_finish, |
121 | .buf_release = dvb_buf_release, | 163 | .buf_queue = buffer_queue, |
164 | .wait_prepare = vb2_ops_wait_prepare, | ||
165 | .wait_finish = vb2_ops_wait_finish, | ||
166 | .start_streaming = start_streaming, | ||
167 | .stop_streaming = stop_streaming, | ||
122 | }; | 168 | }; |
123 | 169 | ||
124 | /* ------------------------------------------------------------------ */ | 170 | /* ------------------------------------------------------------------ */ |
@@ -130,7 +176,7 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) | |||
130 | int ret = 0; | 176 | int ret = 0; |
131 | int fe_id; | 177 | int fe_id; |
132 | 178 | ||
133 | fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe); | 179 | fe_id = vb2_dvb_find_frontend(&dev->frontends, fe); |
134 | if (!fe_id) { | 180 | if (!fe_id) { |
135 | printk(KERN_ERR "%s() No frontend found\n", __func__); | 181 | printk(KERN_ERR "%s() No frontend found\n", __func__); |
136 | return -EINVAL; | 182 | return -EINVAL; |
@@ -154,8 +200,8 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) | |||
154 | 200 | ||
155 | static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open) | 201 | static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open) |
156 | { | 202 | { |
157 | struct videobuf_dvb_frontends *f; | 203 | struct vb2_dvb_frontends *f; |
158 | struct videobuf_dvb_frontend *fe; | 204 | struct vb2_dvb_frontend *fe; |
159 | 205 | ||
160 | if (!core->dvbdev) | 206 | if (!core->dvbdev) |
161 | return; | 207 | return; |
@@ -166,9 +212,9 @@ static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open) | |||
166 | return; | 212 | return; |
167 | 213 | ||
168 | if (f->gate <= 1) /* undefined or fe0 */ | 214 | if (f->gate <= 1) /* undefined or fe0 */ |
169 | fe = videobuf_dvb_get_frontend(f, 1); | 215 | fe = vb2_dvb_get_frontend(f, 1); |
170 | else | 216 | else |
171 | fe = videobuf_dvb_get_frontend(f, f->gate); | 217 | fe = vb2_dvb_get_frontend(f, f->gate); |
172 | 218 | ||
173 | if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) | 219 | if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) |
174 | fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open); | 220 | fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open); |
@@ -565,7 +611,7 @@ static const struct xc5000_config dvico_fusionhdtv7_tuner_config = { | |||
565 | static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | 611 | static int attach_xc3028(u8 addr, struct cx8802_dev *dev) |
566 | { | 612 | { |
567 | struct dvb_frontend *fe; | 613 | struct dvb_frontend *fe; |
568 | struct videobuf_dvb_frontend *fe0 = NULL; | 614 | struct vb2_dvb_frontend *fe0 = NULL; |
569 | struct xc2028_ctrl ctl; | 615 | struct xc2028_ctrl ctl; |
570 | struct xc2028_config cfg = { | 616 | struct xc2028_config cfg = { |
571 | .i2c_adap = &dev->core->i2c_adap, | 617 | .i2c_adap = &dev->core->i2c_adap, |
@@ -574,7 +620,7 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | |||
574 | }; | 620 | }; |
575 | 621 | ||
576 | /* Get the first frontend */ | 622 | /* Get the first frontend */ |
577 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | 623 | fe0 = vb2_dvb_get_frontend(&dev->frontends, 1); |
578 | if (!fe0) | 624 | if (!fe0) |
579 | return -EINVAL; | 625 | return -EINVAL; |
580 | 626 | ||
@@ -611,10 +657,10 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | |||
611 | static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg) | 657 | static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg) |
612 | { | 658 | { |
613 | struct dvb_frontend *fe; | 659 | struct dvb_frontend *fe; |
614 | struct videobuf_dvb_frontend *fe0 = NULL; | 660 | struct vb2_dvb_frontend *fe0 = NULL; |
615 | 661 | ||
616 | /* Get the first frontend */ | 662 | /* Get the first frontend */ |
617 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | 663 | fe0 = vb2_dvb_get_frontend(&dev->frontends, 1); |
618 | if (!fe0) | 664 | if (!fe0) |
619 | return -EINVAL; | 665 | return -EINVAL; |
620 | 666 | ||
@@ -745,7 +791,7 @@ static const struct stv0288_config tevii_tuner_earda_config = { | |||
745 | static int cx8802_alloc_frontends(struct cx8802_dev *dev) | 791 | static int cx8802_alloc_frontends(struct cx8802_dev *dev) |
746 | { | 792 | { |
747 | struct cx88_core *core = dev->core; | 793 | struct cx88_core *core = dev->core; |
748 | struct videobuf_dvb_frontend *fe = NULL; | 794 | struct vb2_dvb_frontend *fe = NULL; |
749 | int i; | 795 | int i; |
750 | 796 | ||
751 | mutex_init(&dev->frontends.lock); | 797 | mutex_init(&dev->frontends.lock); |
@@ -757,10 +803,10 @@ static int cx8802_alloc_frontends(struct cx8802_dev *dev) | |||
757 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, | 803 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, |
758 | core->board.num_frontends); | 804 | core->board.num_frontends); |
759 | for (i = 1; i <= core->board.num_frontends; i++) { | 805 | for (i = 1; i <= core->board.num_frontends; i++) { |
760 | fe = videobuf_dvb_alloc_frontend(&dev->frontends, i); | 806 | fe = vb2_dvb_alloc_frontend(&dev->frontends, i); |
761 | if (!fe) { | 807 | if (!fe) { |
762 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | 808 | printk(KERN_ERR "%s() failed to alloc\n", __func__); |
763 | videobuf_dvb_dealloc_frontends(&dev->frontends); | 809 | vb2_dvb_dealloc_frontends(&dev->frontends); |
764 | return -ENOMEM; | 810 | return -ENOMEM; |
765 | } | 811 | } |
766 | } | 812 | } |
@@ -958,7 +1004,7 @@ static const struct stv0299_config samsung_stv0299_config = { | |||
958 | static int dvb_register(struct cx8802_dev *dev) | 1004 | static int dvb_register(struct cx8802_dev *dev) |
959 | { | 1005 | { |
960 | struct cx88_core *core = dev->core; | 1006 | struct cx88_core *core = dev->core; |
961 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; | 1007 | struct vb2_dvb_frontend *fe0, *fe1 = NULL; |
962 | int mfe_shared = 0; /* bus not shared by default */ | 1008 | int mfe_shared = 0; /* bus not shared by default */ |
963 | int res = -EINVAL; | 1009 | int res = -EINVAL; |
964 | 1010 | ||
@@ -968,7 +1014,7 @@ static int dvb_register(struct cx8802_dev *dev) | |||
968 | } | 1014 | } |
969 | 1015 | ||
970 | /* Get the first frontend */ | 1016 | /* Get the first frontend */ |
971 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | 1017 | fe0 = vb2_dvb_get_frontend(&dev->frontends, 1); |
972 | if (!fe0) | 1018 | if (!fe0) |
973 | goto frontend_detach; | 1019 | goto frontend_detach; |
974 | 1020 | ||
@@ -1046,7 +1092,7 @@ static int dvb_register(struct cx8802_dev *dev) | |||
1046 | goto frontend_detach; | 1092 | goto frontend_detach; |
1047 | } | 1093 | } |
1048 | /* MFE frontend 2 */ | 1094 | /* MFE frontend 2 */ |
1049 | fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); | 1095 | fe1 = vb2_dvb_get_frontend(&dev->frontends, 2); |
1050 | if (!fe1) | 1096 | if (!fe1) |
1051 | goto frontend_detach; | 1097 | goto frontend_detach; |
1052 | /* DVB-T init */ | 1098 | /* DVB-T init */ |
@@ -1415,7 +1461,7 @@ static int dvb_register(struct cx8802_dev *dev) | |||
1415 | goto frontend_detach; | 1461 | goto frontend_detach; |
1416 | } | 1462 | } |
1417 | /* MFE frontend 2 */ | 1463 | /* MFE frontend 2 */ |
1418 | fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); | 1464 | fe1 = vb2_dvb_get_frontend(&dev->frontends, 2); |
1419 | if (!fe1) | 1465 | if (!fe1) |
1420 | goto frontend_detach; | 1466 | goto frontend_detach; |
1421 | /* DVB-T Init */ | 1467 | /* DVB-T Init */ |
@@ -1594,7 +1640,7 @@ static int dvb_register(struct cx8802_dev *dev) | |||
1594 | call_all(core, core, s_power, 0); | 1640 | call_all(core, core, s_power, 0); |
1595 | 1641 | ||
1596 | /* register everything */ | 1642 | /* register everything */ |
1597 | res = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, | 1643 | res = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, |
1598 | &dev->pci->dev, adapter_nr, mfe_shared); | 1644 | &dev->pci->dev, adapter_nr, mfe_shared); |
1599 | if (res) | 1645 | if (res) |
1600 | goto frontend_detach; | 1646 | goto frontend_detach; |
@@ -1602,7 +1648,7 @@ static int dvb_register(struct cx8802_dev *dev) | |||
1602 | 1648 | ||
1603 | frontend_detach: | 1649 | frontend_detach: |
1604 | core->gate_ctrl = NULL; | 1650 | core->gate_ctrl = NULL; |
1605 | videobuf_dvb_dealloc_frontends(&dev->frontends); | 1651 | vb2_dvb_dealloc_frontends(&dev->frontends); |
1606 | return res; | 1652 | return res; |
1607 | } | 1653 | } |
1608 | 1654 | ||
@@ -1697,7 +1743,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1697 | struct cx88_core *core = drv->core; | 1743 | struct cx88_core *core = drv->core; |
1698 | struct cx8802_dev *dev = drv->core->dvbdev; | 1744 | struct cx8802_dev *dev = drv->core->dvbdev; |
1699 | int err; | 1745 | int err; |
1700 | struct videobuf_dvb_frontend *fe; | 1746 | struct vb2_dvb_frontend *fe; |
1701 | int i; | 1747 | int i; |
1702 | 1748 | ||
1703 | dprintk( 1, "%s\n", __func__); | 1749 | dprintk( 1, "%s\n", __func__); |
@@ -1726,19 +1772,31 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1726 | 1772 | ||
1727 | err = -ENODEV; | 1773 | err = -ENODEV; |
1728 | for (i = 1; i <= core->board.num_frontends; i++) { | 1774 | for (i = 1; i <= core->board.num_frontends; i++) { |
1729 | fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); | 1775 | struct vb2_queue *q; |
1776 | |||
1777 | fe = vb2_dvb_get_frontend(&core->dvbdev->frontends, i); | ||
1730 | if (fe == NULL) { | 1778 | if (fe == NULL) { |
1731 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", | 1779 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", |
1732 | __func__, i); | 1780 | __func__, i); |
1733 | goto fail_probe; | 1781 | goto fail_probe; |
1734 | } | 1782 | } |
1735 | videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, | 1783 | q = &fe->dvb.dvbq; |
1736 | &dev->pci->dev, &dev->slock, | 1784 | q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1737 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1785 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; |
1738 | V4L2_FIELD_TOP, | 1786 | q->gfp_flags = GFP_DMA32; |
1739 | sizeof(struct cx88_buffer), | 1787 | q->min_buffers_needed = 2; |
1740 | dev, NULL); | 1788 | q->drv_priv = dev; |
1741 | /* init struct videobuf_dvb */ | 1789 | q->buf_struct_size = sizeof(struct cx88_buffer); |
1790 | q->ops = &dvb_qops; | ||
1791 | q->mem_ops = &vb2_dma_sg_memops; | ||
1792 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1793 | q->lock = &core->lock; | ||
1794 | |||
1795 | err = vb2_queue_init(q); | ||
1796 | if (err < 0) | ||
1797 | goto fail_probe; | ||
1798 | |||
1799 | /* init struct vb2_dvb */ | ||
1742 | fe->dvb.name = dev->core->name; | 1800 | fe->dvb.name = dev->core->name; |
1743 | } | 1801 | } |
1744 | 1802 | ||
@@ -1749,7 +1807,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1749 | core->name, err); | 1807 | core->name, err); |
1750 | return err; | 1808 | return err; |
1751 | fail_probe: | 1809 | fail_probe: |
1752 | videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends); | 1810 | vb2_dvb_dealloc_frontends(&core->dvbdev->frontends); |
1753 | fail_core: | 1811 | fail_core: |
1754 | return err; | 1812 | return err; |
1755 | } | 1813 | } |
@@ -1761,7 +1819,7 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv) | |||
1761 | 1819 | ||
1762 | dprintk( 1, "%s\n", __func__); | 1820 | dprintk( 1, "%s\n", __func__); |
1763 | 1821 | ||
1764 | videobuf_dvb_unregister_bus(&dev->frontends); | 1822 | vb2_dvb_unregister_bus(&dev->frontends); |
1765 | 1823 | ||
1766 | vp3054_i2c_remove(dev); | 1824 | vp3054_i2c_remove(dev); |
1767 | 1825 | ||
diff --git a/drivers/media/pci/cx88/cx88-mpeg.c b/drivers/media/pci/cx88/cx88-mpeg.c index 74b7b8614c23..f181a3a10389 100644 --- a/drivers/media/pci/cx88/cx88-mpeg.c +++ b/drivers/media/pci/cx88/cx88-mpeg.c | |||
@@ -86,21 +86,21 @@ static LIST_HEAD(cx8802_devlist); | |||
86 | static DEFINE_MUTEX(cx8802_mutex); | 86 | static DEFINE_MUTEX(cx8802_mutex); |
87 | /* ------------------------------------------------------------------ */ | 87 | /* ------------------------------------------------------------------ */ |
88 | 88 | ||
89 | static int cx8802_start_dma(struct cx8802_dev *dev, | 89 | int cx8802_start_dma(struct cx8802_dev *dev, |
90 | struct cx88_dmaqueue *q, | 90 | struct cx88_dmaqueue *q, |
91 | struct cx88_buffer *buf) | 91 | struct cx88_buffer *buf) |
92 | { | 92 | { |
93 | struct cx88_core *core = dev->core; | 93 | struct cx88_core *core = dev->core; |
94 | 94 | ||
95 | dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", | 95 | dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", |
96 | buf->vb.width, buf->vb.height, buf->vb.field); | 96 | core->width, core->height, core->field); |
97 | 97 | ||
98 | /* setup fifo + format */ | 98 | /* setup fifo + format */ |
99 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], | 99 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], |
100 | dev->ts_packet_size, buf->risc.dma); | 100 | dev->ts_packet_size, buf->risc.dma); |
101 | 101 | ||
102 | /* write TS length to chip */ | 102 | /* write TS length to chip */ |
103 | cx_write(MO_TS_LNGTH, buf->vb.width); | 103 | cx_write(MO_TS_LNGTH, dev->ts_packet_size); |
104 | 104 | ||
105 | /* FIXME: this needs a review. | 105 | /* FIXME: this needs a review. |
106 | * also: move to cx88-blackbird + cx88-dvb source files? */ | 106 | * also: move to cx88-blackbird + cx88-dvb source files? */ |
@@ -210,83 +210,44 @@ static int cx8802_restart_queue(struct cx8802_dev *dev, | |||
210 | 210 | ||
211 | dprintk( 1, "cx8802_restart_queue\n" ); | 211 | dprintk( 1, "cx8802_restart_queue\n" ); |
212 | if (list_empty(&q->active)) | 212 | if (list_empty(&q->active)) |
213 | { | ||
214 | struct cx88_buffer *prev; | ||
215 | prev = NULL; | ||
216 | |||
217 | dprintk(1, "cx8802_restart_queue: queue is empty\n" ); | ||
218 | |||
219 | for (;;) { | ||
220 | if (list_empty(&q->queued)) | ||
221 | return 0; | ||
222 | buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue); | ||
223 | if (NULL == prev) { | ||
224 | list_move_tail(&buf->vb.queue, &q->active); | ||
225 | cx8802_start_dma(dev, q, buf); | ||
226 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
227 | buf->count = q->count++; | ||
228 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
229 | dprintk(1,"[%p/%d] restart_queue - first active\n", | ||
230 | buf,buf->vb.i); | ||
231 | |||
232 | } else if (prev->vb.width == buf->vb.width && | ||
233 | prev->vb.height == buf->vb.height && | ||
234 | prev->fmt == buf->fmt) { | ||
235 | list_move_tail(&buf->vb.queue, &q->active); | ||
236 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
237 | buf->count = q->count++; | ||
238 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | ||
239 | dprintk(1,"[%p/%d] restart_queue - move to active\n", | ||
240 | buf,buf->vb.i); | ||
241 | } else { | ||
242 | return 0; | ||
243 | } | ||
244 | prev = buf; | ||
245 | } | ||
246 | return 0; | 213 | return 0; |
247 | } | ||
248 | 214 | ||
249 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); | 215 | buf = list_entry(q->active.next, struct cx88_buffer, list); |
250 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", | 216 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", |
251 | buf, buf->vb.i); | 217 | buf, buf->vb.v4l2_buf.index); |
252 | cx8802_start_dma(dev, q, buf); | 218 | cx8802_start_dma(dev, q, buf); |
253 | list_for_each_entry(buf, &q->active, vb.queue) | 219 | list_for_each_entry(buf, &q->active, list) |
254 | buf->count = q->count++; | 220 | buf->count = q->count++; |
255 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
256 | return 0; | 221 | return 0; |
257 | } | 222 | } |
258 | 223 | ||
259 | /* ------------------------------------------------------------------ */ | 224 | /* ------------------------------------------------------------------ */ |
260 | 225 | ||
261 | int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev, | 226 | int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, |
262 | struct cx88_buffer *buf, enum v4l2_field field) | 227 | struct cx88_buffer *buf) |
263 | { | 228 | { |
264 | int size = dev->ts_packet_size * dev->ts_packet_count; | 229 | int size = dev->ts_packet_size * dev->ts_packet_count; |
265 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | 230 | struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb, 0); |
231 | struct cx88_riscmem *risc = &buf->risc; | ||
266 | int rc; | 232 | int rc; |
267 | 233 | ||
268 | dprintk(1, "%s: %p\n", __func__, buf); | 234 | if (vb2_plane_size(&buf->vb, 0) < size) |
269 | if (0 != buf->vb.baddr && buf->vb.bsize < size) | ||
270 | return -EINVAL; | 235 | return -EINVAL; |
236 | vb2_set_plane_payload(&buf->vb, 0, size); | ||
271 | 237 | ||
272 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 238 | rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); |
273 | buf->vb.width = dev->ts_packet_size; | 239 | if (!rc) |
274 | buf->vb.height = dev->ts_packet_count; | 240 | return -EIO; |
275 | buf->vb.size = size; | 241 | |
276 | buf->vb.field = field /*V4L2_FIELD_TOP*/; | 242 | rc = cx88_risc_databuffer(dev->pci, risc, sgt->sgl, |
277 | 243 | dev->ts_packet_size, dev->ts_packet_count, 0); | |
278 | if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL))) | 244 | if (rc) { |
279 | goto fail; | 245 | if (risc->cpu) |
280 | cx88_risc_databuffer(dev->pci, &buf->risc, | 246 | pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); |
281 | dma->sglist, | 247 | memset(risc, 0, sizeof(*risc)); |
282 | buf->vb.width, buf->vb.height, 0); | 248 | return rc; |
283 | } | 249 | } |
284 | buf->vb.state = VIDEOBUF_PREPARED; | ||
285 | return 0; | 250 | return 0; |
286 | |||
287 | fail: | ||
288 | cx88_free_buffer(q,buf); | ||
289 | return rc; | ||
290 | } | 251 | } |
291 | 252 | ||
292 | void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) | 253 | void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) |
@@ -295,35 +256,33 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) | |||
295 | struct cx88_dmaqueue *cx88q = &dev->mpegq; | 256 | struct cx88_dmaqueue *cx88q = &dev->mpegq; |
296 | 257 | ||
297 | dprintk( 1, "cx8802_buf_queue\n" ); | 258 | dprintk( 1, "cx8802_buf_queue\n" ); |
298 | /* add jump to stopper */ | 259 | /* add jump to start */ |
299 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); | 260 | buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 8); |
300 | buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma); | 261 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); |
262 | buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 8); | ||
301 | 263 | ||
302 | if (list_empty(&cx88q->active)) { | 264 | if (list_empty(&cx88q->active)) { |
303 | dprintk( 1, "queue is empty - first active\n" ); | 265 | dprintk( 1, "queue is empty - first active\n" ); |
304 | list_add_tail(&buf->vb.queue,&cx88q->active); | 266 | list_add_tail(&buf->list, &cx88q->active); |
305 | cx8802_start_dma(dev, cx88q, buf); | ||
306 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
307 | buf->count = cx88q->count++; | 267 | buf->count = cx88q->count++; |
308 | mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT); | ||
309 | dprintk(1,"[%p/%d] %s - first active\n", | 268 | dprintk(1,"[%p/%d] %s - first active\n", |
310 | buf, buf->vb.i, __func__); | 269 | buf, buf->vb.v4l2_buf.index, __func__); |
311 | 270 | ||
312 | } else { | 271 | } else { |
272 | buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); | ||
313 | dprintk( 1, "queue is not empty - append to active\n" ); | 273 | dprintk( 1, "queue is not empty - append to active\n" ); |
314 | prev = list_entry(cx88q->active.prev, struct cx88_buffer, vb.queue); | 274 | prev = list_entry(cx88q->active.prev, struct cx88_buffer, list); |
315 | list_add_tail(&buf->vb.queue,&cx88q->active); | 275 | list_add_tail(&buf->list, &cx88q->active); |
316 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
317 | buf->count = cx88q->count++; | 276 | buf->count = cx88q->count++; |
318 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 277 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
319 | dprintk( 1, "[%p/%d] %s - append to active\n", | 278 | dprintk( 1, "[%p/%d] %s - append to active\n", |
320 | buf, buf->vb.i, __func__); | 279 | buf, buf->vb.v4l2_buf.index, __func__); |
321 | } | 280 | } |
322 | } | 281 | } |
323 | 282 | ||
324 | /* ----------------------------------------------------------- */ | 283 | /* ----------------------------------------------------------- */ |
325 | 284 | ||
326 | static void do_cancel_buffers(struct cx8802_dev *dev, const char *reason, int restart) | 285 | static void do_cancel_buffers(struct cx8802_dev *dev) |
327 | { | 286 | { |
328 | struct cx88_dmaqueue *q = &dev->mpegq; | 287 | struct cx88_dmaqueue *q = &dev->mpegq; |
329 | struct cx88_buffer *buf; | 288 | struct cx88_buffer *buf; |
@@ -331,41 +290,18 @@ static void do_cancel_buffers(struct cx8802_dev *dev, const char *reason, int re | |||
331 | 290 | ||
332 | spin_lock_irqsave(&dev->slock,flags); | 291 | spin_lock_irqsave(&dev->slock,flags); |
333 | while (!list_empty(&q->active)) { | 292 | while (!list_empty(&q->active)) { |
334 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); | 293 | buf = list_entry(q->active.next, struct cx88_buffer, list); |
335 | list_del(&buf->vb.queue); | 294 | list_del(&buf->list); |
336 | buf->vb.state = VIDEOBUF_ERROR; | 295 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); |
337 | wake_up(&buf->vb.done); | ||
338 | dprintk(1,"[%p/%d] %s - dma=0x%08lx\n", | ||
339 | buf, buf->vb.i, reason, (unsigned long)buf->risc.dma); | ||
340 | } | ||
341 | if (restart) | ||
342 | { | ||
343 | dprintk(1, "restarting queue\n" ); | ||
344 | cx8802_restart_queue(dev,q); | ||
345 | } | 296 | } |
346 | spin_unlock_irqrestore(&dev->slock,flags); | 297 | spin_unlock_irqrestore(&dev->slock,flags); |
347 | } | 298 | } |
348 | 299 | ||
349 | void cx8802_cancel_buffers(struct cx8802_dev *dev) | 300 | void cx8802_cancel_buffers(struct cx8802_dev *dev) |
350 | { | 301 | { |
351 | struct cx88_dmaqueue *q = &dev->mpegq; | ||
352 | |||
353 | dprintk( 1, "cx8802_cancel_buffers" ); | 302 | dprintk( 1, "cx8802_cancel_buffers" ); |
354 | del_timer_sync(&q->timeout); | ||
355 | cx8802_stop_dma(dev); | 303 | cx8802_stop_dma(dev); |
356 | do_cancel_buffers(dev,"cancel",0); | 304 | do_cancel_buffers(dev); |
357 | } | ||
358 | |||
359 | static void cx8802_timeout(unsigned long data) | ||
360 | { | ||
361 | struct cx8802_dev *dev = (struct cx8802_dev*)data; | ||
362 | |||
363 | dprintk(1, "%s\n",__func__); | ||
364 | |||
365 | if (debug) | ||
366 | cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]); | ||
367 | cx8802_stop_dma(dev); | ||
368 | do_cancel_buffers(dev,"timeout",1); | ||
369 | } | 305 | } |
370 | 306 | ||
371 | static const char * cx88_mpeg_irqs[32] = { | 307 | static const char * cx88_mpeg_irqs[32] = { |
@@ -411,19 +347,11 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev) | |||
411 | spin_unlock(&dev->slock); | 347 | spin_unlock(&dev->slock); |
412 | } | 348 | } |
413 | 349 | ||
414 | /* risc2 y */ | ||
415 | if (status & 0x10) { | ||
416 | spin_lock(&dev->slock); | ||
417 | cx8802_restart_queue(dev,&dev->mpegq); | ||
418 | spin_unlock(&dev->slock); | ||
419 | } | ||
420 | |||
421 | /* other general errors */ | 350 | /* other general errors */ |
422 | if (status & 0x1f0100) { | 351 | if (status & 0x1f0100) { |
423 | dprintk( 0, "general errors: 0x%08x\n", status & 0x1f0100 ); | 352 | dprintk( 0, "general errors: 0x%08x\n", status & 0x1f0100 ); |
424 | spin_lock(&dev->slock); | 353 | spin_lock(&dev->slock); |
425 | cx8802_stop_dma(dev); | 354 | cx8802_stop_dma(dev); |
426 | cx8802_restart_queue(dev,&dev->mpegq); | ||
427 | spin_unlock(&dev->slock); | 355 | spin_unlock(&dev->slock); |
428 | } | 356 | } |
429 | } | 357 | } |
@@ -490,12 +418,6 @@ static int cx8802_init_common(struct cx8802_dev *dev) | |||
490 | 418 | ||
491 | /* init dma queue */ | 419 | /* init dma queue */ |
492 | INIT_LIST_HEAD(&dev->mpegq.active); | 420 | INIT_LIST_HEAD(&dev->mpegq.active); |
493 | INIT_LIST_HEAD(&dev->mpegq.queued); | ||
494 | dev->mpegq.timeout.function = cx8802_timeout; | ||
495 | dev->mpegq.timeout.data = (unsigned long)dev; | ||
496 | init_timer(&dev->mpegq.timeout); | ||
497 | cx88_risc_stopper(dev->pci,&dev->mpegq.stopper, | ||
498 | MO_TS_DMACNTRL,0x11,0x00); | ||
499 | 421 | ||
500 | /* get irq */ | 422 | /* get irq */ |
501 | err = request_irq(dev->pci->irq, cx8802_irq, | 423 | err = request_irq(dev->pci->irq, cx8802_irq, |
@@ -520,9 +442,6 @@ static void cx8802_fini_common(struct cx8802_dev *dev) | |||
520 | 442 | ||
521 | /* unregister stuff */ | 443 | /* unregister stuff */ |
522 | free_irq(dev->pci->irq, dev); | 444 | free_irq(dev->pci->irq, dev); |
523 | |||
524 | /* free memory */ | ||
525 | btcx_riscmem_free(dev->pci,&dev->mpegq.stopper); | ||
526 | } | 445 | } |
527 | 446 | ||
528 | /* ----------------------------------------------------------- */ | 447 | /* ----------------------------------------------------------- */ |
@@ -539,7 +458,6 @@ static int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state) | |||
539 | dprintk( 2, "suspend\n" ); | 458 | dprintk( 2, "suspend\n" ); |
540 | printk("%s: suspend mpeg\n", core->name); | 459 | printk("%s: suspend mpeg\n", core->name); |
541 | cx8802_stop_dma(dev); | 460 | cx8802_stop_dma(dev); |
542 | del_timer(&dev->mpegq.timeout); | ||
543 | } | 461 | } |
544 | spin_unlock_irqrestore(&dev->slock, flags); | 462 | spin_unlock_irqrestore(&dev->slock, flags); |
545 | 463 | ||
@@ -907,6 +825,7 @@ module_pci_driver(cx8802_pci_driver); | |||
907 | EXPORT_SYMBOL(cx8802_buf_prepare); | 825 | EXPORT_SYMBOL(cx8802_buf_prepare); |
908 | EXPORT_SYMBOL(cx8802_buf_queue); | 826 | EXPORT_SYMBOL(cx8802_buf_queue); |
909 | EXPORT_SYMBOL(cx8802_cancel_buffers); | 827 | EXPORT_SYMBOL(cx8802_cancel_buffers); |
828 | EXPORT_SYMBOL(cx8802_start_dma); | ||
910 | 829 | ||
911 | EXPORT_SYMBOL(cx8802_register_driver); | 830 | EXPORT_SYMBOL(cx8802_register_driver); |
912 | EXPORT_SYMBOL(cx8802_unregister_driver); | 831 | EXPORT_SYMBOL(cx8802_unregister_driver); |
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c index f8f8389c0362..6ab6e27648f6 100644 --- a/drivers/media/pci/cx88/cx88-vbi.c +++ b/drivers/media/pci/cx88/cx88-vbi.c | |||
@@ -6,10 +6,6 @@ | |||
6 | 6 | ||
7 | #include "cx88.h" | 7 | #include "cx88.h" |
8 | 8 | ||
9 | static unsigned int vbibufs = 4; | ||
10 | module_param(vbibufs,int,0644); | ||
11 | MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32"); | ||
12 | |||
13 | static unsigned int vbi_debug; | 9 | static unsigned int vbi_debug; |
14 | module_param(vbi_debug,int,0644); | 10 | module_param(vbi_debug,int,0644); |
15 | MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); | 11 | MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); |
@@ -22,26 +18,27 @@ MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); | |||
22 | int cx8800_vbi_fmt (struct file *file, void *priv, | 18 | int cx8800_vbi_fmt (struct file *file, void *priv, |
23 | struct v4l2_format *f) | 19 | struct v4l2_format *f) |
24 | { | 20 | { |
25 | struct cx8800_fh *fh = priv; | 21 | struct cx8800_dev *dev = video_drvdata(file); |
26 | struct cx8800_dev *dev = fh->dev; | ||
27 | 22 | ||
28 | f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; | 23 | f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; |
29 | f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | 24 | f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; |
30 | f->fmt.vbi.offset = 244; | 25 | f->fmt.vbi.offset = 244; |
31 | f->fmt.vbi.count[0] = VBI_LINE_COUNT; | ||
32 | f->fmt.vbi.count[1] = VBI_LINE_COUNT; | ||
33 | 26 | ||
34 | if (dev->core->tvnorm & V4L2_STD_525_60) { | 27 | if (dev->core->tvnorm & V4L2_STD_525_60) { |
35 | /* ntsc */ | 28 | /* ntsc */ |
36 | f->fmt.vbi.sampling_rate = 28636363; | 29 | f->fmt.vbi.sampling_rate = 28636363; |
37 | f->fmt.vbi.start[0] = 10; | 30 | f->fmt.vbi.start[0] = 10; |
38 | f->fmt.vbi.start[1] = 273; | 31 | f->fmt.vbi.start[1] = 273; |
32 | f->fmt.vbi.count[0] = VBI_LINE_NTSC_COUNT; | ||
33 | f->fmt.vbi.count[1] = VBI_LINE_NTSC_COUNT; | ||
39 | 34 | ||
40 | } else if (dev->core->tvnorm & V4L2_STD_625_50) { | 35 | } else if (dev->core->tvnorm & V4L2_STD_625_50) { |
41 | /* pal */ | 36 | /* pal */ |
42 | f->fmt.vbi.sampling_rate = 35468950; | 37 | f->fmt.vbi.sampling_rate = 35468950; |
43 | f->fmt.vbi.start[0] = 7 -1; | 38 | f->fmt.vbi.start[0] = V4L2_VBI_ITU_625_F1_START + 5; |
44 | f->fmt.vbi.start[1] = 319 -1; | 39 | f->fmt.vbi.start[1] = V4L2_VBI_ITU_625_F2_START + 5; |
40 | f->fmt.vbi.count[0] = VBI_LINE_PAL_COUNT; | ||
41 | f->fmt.vbi.count[1] = VBI_LINE_PAL_COUNT; | ||
45 | } | 42 | } |
46 | return 0; | 43 | return 0; |
47 | } | 44 | } |
@@ -54,7 +51,7 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev, | |||
54 | 51 | ||
55 | /* setup fifo + format */ | 52 | /* setup fifo + format */ |
56 | cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24], | 53 | cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH24], |
57 | buf->vb.width, buf->risc.dma); | 54 | VBI_LINE_LENGTH, buf->risc.dma); |
58 | 55 | ||
59 | cx_write(MO_VBOS_CONTROL, ( (1 << 18) | // comb filter delay fixup | 56 | cx_write(MO_VBOS_CONTROL, ( (1 << 18) | // comb filter delay fixup |
60 | (1 << 15) | // enable vbi capture | 57 | (1 << 15) | // enable vbi capture |
@@ -78,7 +75,7 @@ static int cx8800_start_vbi_dma(struct cx8800_dev *dev, | |||
78 | return 0; | 75 | return 0; |
79 | } | 76 | } |
80 | 77 | ||
81 | int cx8800_stop_vbi_dma(struct cx8800_dev *dev) | 78 | void cx8800_stop_vbi_dma(struct cx8800_dev *dev) |
82 | { | 79 | { |
83 | struct cx88_core *core = dev->core; | 80 | struct cx88_core *core = dev->core; |
84 | 81 | ||
@@ -91,7 +88,6 @@ int cx8800_stop_vbi_dma(struct cx8800_dev *dev) | |||
91 | /* disable irqs */ | 88 | /* disable irqs */ |
92 | cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); | 89 | cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); |
93 | cx_clear(MO_VID_INTMSK, 0x0f0088); | 90 | cx_clear(MO_VID_INTMSK, 0x0f0088); |
94 | return 0; | ||
95 | } | 91 | } |
96 | 92 | ||
97 | int cx8800_restart_vbi_queue(struct cx8800_dev *dev, | 93 | int cx8800_restart_vbi_queue(struct cx8800_dev *dev, |
@@ -102,144 +98,144 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev, | |||
102 | if (list_empty(&q->active)) | 98 | if (list_empty(&q->active)) |
103 | return 0; | 99 | return 0; |
104 | 100 | ||
105 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); | 101 | buf = list_entry(q->active.next, struct cx88_buffer, list); |
106 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", | 102 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", |
107 | buf, buf->vb.i); | 103 | buf, buf->vb.v4l2_buf.index); |
108 | cx8800_start_vbi_dma(dev, q, buf); | 104 | cx8800_start_vbi_dma(dev, q, buf); |
109 | list_for_each_entry(buf, &q->active, vb.queue) | 105 | list_for_each_entry(buf, &q->active, list) |
110 | buf->count = q->count++; | 106 | buf->count = q->count++; |
111 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
112 | return 0; | 107 | return 0; |
113 | } | 108 | } |
114 | 109 | ||
115 | void cx8800_vbi_timeout(unsigned long data) | ||
116 | { | ||
117 | struct cx8800_dev *dev = (struct cx8800_dev*)data; | ||
118 | struct cx88_core *core = dev->core; | ||
119 | struct cx88_dmaqueue *q = &dev->vbiq; | ||
120 | struct cx88_buffer *buf; | ||
121 | unsigned long flags; | ||
122 | |||
123 | cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH24]); | ||
124 | |||
125 | cx_clear(MO_VID_DMACNTRL, 0x88); | ||
126 | cx_clear(VID_CAPTURE_CONTROL, 0x18); | ||
127 | |||
128 | spin_lock_irqsave(&dev->slock,flags); | ||
129 | while (!list_empty(&q->active)) { | ||
130 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); | ||
131 | list_del(&buf->vb.queue); | ||
132 | buf->vb.state = VIDEOBUF_ERROR; | ||
133 | wake_up(&buf->vb.done); | ||
134 | printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", dev->core->name, | ||
135 | buf, buf->vb.i, (unsigned long)buf->risc.dma); | ||
136 | } | ||
137 | cx8800_restart_vbi_queue(dev,q); | ||
138 | spin_unlock_irqrestore(&dev->slock,flags); | ||
139 | } | ||
140 | |||
141 | /* ------------------------------------------------------------------ */ | 110 | /* ------------------------------------------------------------------ */ |
142 | 111 | ||
143 | static int | 112 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
144 | vbi_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | 113 | unsigned int *num_buffers, unsigned int *num_planes, |
114 | unsigned int sizes[], void *alloc_ctxs[]) | ||
145 | { | 115 | { |
146 | *size = VBI_LINE_COUNT * VBI_LINE_LENGTH * 2; | 116 | struct cx8800_dev *dev = q->drv_priv; |
147 | if (0 == *count) | 117 | |
148 | *count = vbibufs; | 118 | *num_planes = 1; |
149 | if (*count < 2) | 119 | if (dev->core->tvnorm & V4L2_STD_525_60) |
150 | *count = 2; | 120 | sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2; |
151 | if (*count > 32) | 121 | else |
152 | *count = 32; | 122 | sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2; |
153 | return 0; | 123 | return 0; |
154 | } | 124 | } |
155 | 125 | ||
156 | static int | 126 | |
157 | vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | 127 | static int buffer_prepare(struct vb2_buffer *vb) |
158 | enum v4l2_field field) | ||
159 | { | 128 | { |
160 | struct cx8800_fh *fh = q->priv_data; | 129 | struct cx8800_dev *dev = vb->vb2_queue->drv_priv; |
161 | struct cx8800_dev *dev = fh->dev; | 130 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); |
162 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); | 131 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); |
132 | unsigned int lines; | ||
163 | unsigned int size; | 133 | unsigned int size; |
164 | int rc; | 134 | int rc; |
165 | 135 | ||
166 | size = VBI_LINE_COUNT * VBI_LINE_LENGTH * 2; | 136 | if (dev->core->tvnorm & V4L2_STD_525_60) |
167 | if (0 != buf->vb.baddr && buf->vb.bsize < size) | 137 | lines = VBI_LINE_NTSC_COUNT; |
138 | else | ||
139 | lines = VBI_LINE_PAL_COUNT; | ||
140 | size = lines * VBI_LINE_LENGTH * 2; | ||
141 | if (vb2_plane_size(vb, 0) < size) | ||
168 | return -EINVAL; | 142 | return -EINVAL; |
143 | vb2_set_plane_payload(vb, 0, size); | ||
169 | 144 | ||
170 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 145 | rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); |
171 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | 146 | if (!rc) |
172 | buf->vb.width = VBI_LINE_LENGTH; | 147 | return -EIO; |
173 | buf->vb.height = VBI_LINE_COUNT; | 148 | |
174 | buf->vb.size = size; | 149 | cx88_risc_buffer(dev->pci, &buf->risc, sgt->sgl, |
175 | buf->vb.field = V4L2_FIELD_SEQ_TB; | 150 | 0, VBI_LINE_LENGTH * lines, |
176 | 151 | VBI_LINE_LENGTH, 0, | |
177 | if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL))) | 152 | lines); |
178 | goto fail; | ||
179 | cx88_risc_buffer(dev->pci, &buf->risc, | ||
180 | dma->sglist, | ||
181 | 0, buf->vb.width * buf->vb.height, | ||
182 | buf->vb.width, 0, | ||
183 | buf->vb.height); | ||
184 | } | ||
185 | buf->vb.state = VIDEOBUF_PREPARED; | ||
186 | return 0; | 153 | return 0; |
154 | } | ||
187 | 155 | ||
188 | fail: | 156 | static void buffer_finish(struct vb2_buffer *vb) |
189 | cx88_free_buffer(q,buf); | 157 | { |
190 | return rc; | 158 | struct cx8800_dev *dev = vb->vb2_queue->drv_priv; |
159 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
160 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
161 | struct cx88_riscmem *risc = &buf->risc; | ||
162 | |||
163 | if (risc->cpu) | ||
164 | pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); | ||
165 | memset(risc, 0, sizeof(*risc)); | ||
166 | |||
167 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); | ||
191 | } | 168 | } |
192 | 169 | ||
193 | static void | 170 | static void buffer_queue(struct vb2_buffer *vb) |
194 | vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
195 | { | 171 | { |
196 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); | 172 | struct cx8800_dev *dev = vb->vb2_queue->drv_priv; |
173 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
197 | struct cx88_buffer *prev; | 174 | struct cx88_buffer *prev; |
198 | struct cx8800_fh *fh = vq->priv_data; | ||
199 | struct cx8800_dev *dev = fh->dev; | ||
200 | struct cx88_dmaqueue *q = &dev->vbiq; | 175 | struct cx88_dmaqueue *q = &dev->vbiq; |
201 | 176 | ||
202 | /* add jump to stopper */ | 177 | /* add jump to start */ |
203 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); | 178 | buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 8); |
204 | buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); | 179 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); |
180 | buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 8); | ||
205 | 181 | ||
206 | if (list_empty(&q->active)) { | 182 | if (list_empty(&q->active)) { |
207 | list_add_tail(&buf->vb.queue,&q->active); | 183 | list_add_tail(&buf->list, &q->active); |
208 | cx8800_start_vbi_dma(dev, q, buf); | 184 | cx8800_start_vbi_dma(dev, q, buf); |
209 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
210 | buf->count = q->count++; | 185 | buf->count = q->count++; |
211 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
212 | dprintk(2,"[%p/%d] vbi_queue - first active\n", | 186 | dprintk(2,"[%p/%d] vbi_queue - first active\n", |
213 | buf, buf->vb.i); | 187 | buf, buf->vb.v4l2_buf.index); |
214 | 188 | ||
215 | } else { | 189 | } else { |
216 | prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue); | 190 | buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); |
217 | list_add_tail(&buf->vb.queue,&q->active); | 191 | prev = list_entry(q->active.prev, struct cx88_buffer, list); |
218 | buf->vb.state = VIDEOBUF_ACTIVE; | 192 | list_add_tail(&buf->list, &q->active); |
219 | buf->count = q->count++; | 193 | buf->count = q->count++; |
220 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 194 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
221 | dprintk(2,"[%p/%d] buffer_queue - append to active\n", | 195 | dprintk(2,"[%p/%d] buffer_queue - append to active\n", |
222 | buf, buf->vb.i); | 196 | buf, buf->vb.v4l2_buf.index); |
223 | } | 197 | } |
224 | } | 198 | } |
225 | 199 | ||
226 | static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | 200 | static int start_streaming(struct vb2_queue *q, unsigned int count) |
227 | { | 201 | { |
228 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); | 202 | struct cx8800_dev *dev = q->drv_priv; |
203 | struct cx88_dmaqueue *dmaq = &dev->vbiq; | ||
204 | struct cx88_buffer *buf = list_entry(dmaq->active.next, | ||
205 | struct cx88_buffer, list); | ||
229 | 206 | ||
230 | cx88_free_buffer(q,buf); | 207 | cx8800_start_vbi_dma(dev, dmaq, buf); |
208 | return 0; | ||
231 | } | 209 | } |
232 | 210 | ||
233 | const struct videobuf_queue_ops cx8800_vbi_qops = { | 211 | static void stop_streaming(struct vb2_queue *q) |
234 | .buf_setup = vbi_setup, | 212 | { |
235 | .buf_prepare = vbi_prepare, | 213 | struct cx8800_dev *dev = q->drv_priv; |
236 | .buf_queue = vbi_queue, | 214 | struct cx88_core *core = dev->core; |
237 | .buf_release = vbi_release, | 215 | struct cx88_dmaqueue *dmaq = &dev->vbiq; |
238 | }; | 216 | unsigned long flags; |
239 | 217 | ||
240 | /* ------------------------------------------------------------------ */ | 218 | cx_clear(MO_VID_DMACNTRL, 0x11); |
241 | /* | 219 | cx_clear(VID_CAPTURE_CONTROL, 0x06); |
242 | * Local variables: | 220 | cx8800_stop_vbi_dma(dev); |
243 | * c-basic-offset: 8 | 221 | spin_lock_irqsave(&dev->slock, flags); |
244 | * End: | 222 | while (!list_empty(&dmaq->active)) { |
245 | */ | 223 | struct cx88_buffer *buf = list_entry(dmaq->active.next, |
224 | struct cx88_buffer, list); | ||
225 | |||
226 | list_del(&buf->list); | ||
227 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
228 | } | ||
229 | spin_unlock_irqrestore(&dev->slock, flags); | ||
230 | } | ||
231 | |||
232 | const struct vb2_ops cx8800_vbi_qops = { | ||
233 | .queue_setup = queue_setup, | ||
234 | .buf_prepare = buffer_prepare, | ||
235 | .buf_finish = buffer_finish, | ||
236 | .buf_queue = buffer_queue, | ||
237 | .wait_prepare = vb2_ops_wait_prepare, | ||
238 | .wait_finish = vb2_ops_wait_finish, | ||
239 | .start_streaming = start_streaming, | ||
240 | .stop_streaming = stop_streaming, | ||
241 | }; | ||
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index ce27e6d4f16e..a64ae31ae142 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c | |||
@@ -70,10 +70,6 @@ static unsigned int irq_debug; | |||
70 | module_param(irq_debug,int,0644); | 70 | module_param(irq_debug,int,0644); |
71 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); | 71 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); |
72 | 72 | ||
73 | static unsigned int vid_limit = 16; | ||
74 | module_param(vid_limit,int,0644); | ||
75 | MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); | ||
76 | |||
77 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ | 73 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ |
78 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) | 74 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) |
79 | 75 | ||
@@ -297,56 +293,6 @@ enum { | |||
297 | CX8800_AUD_CTLS = ARRAY_SIZE(cx8800_aud_ctls), | 293 | CX8800_AUD_CTLS = ARRAY_SIZE(cx8800_aud_ctls), |
298 | }; | 294 | }; |
299 | 295 | ||
300 | /* ------------------------------------------------------------------- */ | ||
301 | /* resource management */ | ||
302 | |||
303 | static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit) | ||
304 | { | ||
305 | struct cx88_core *core = dev->core; | ||
306 | if (fh->resources & bit) | ||
307 | /* have it already allocated */ | ||
308 | return 1; | ||
309 | |||
310 | /* is it free? */ | ||
311 | mutex_lock(&core->lock); | ||
312 | if (dev->resources & bit) { | ||
313 | /* no, someone else uses it */ | ||
314 | mutex_unlock(&core->lock); | ||
315 | return 0; | ||
316 | } | ||
317 | /* it's free, grab it */ | ||
318 | fh->resources |= bit; | ||
319 | dev->resources |= bit; | ||
320 | dprintk(1,"res: get %d\n",bit); | ||
321 | mutex_unlock(&core->lock); | ||
322 | return 1; | ||
323 | } | ||
324 | |||
325 | static | ||
326 | int res_check(struct cx8800_fh *fh, unsigned int bit) | ||
327 | { | ||
328 | return (fh->resources & bit); | ||
329 | } | ||
330 | |||
331 | static | ||
332 | int res_locked(struct cx8800_dev *dev, unsigned int bit) | ||
333 | { | ||
334 | return (dev->resources & bit); | ||
335 | } | ||
336 | |||
337 | static | ||
338 | void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits) | ||
339 | { | ||
340 | struct cx88_core *core = dev->core; | ||
341 | BUG_ON((fh->resources & bits) != bits); | ||
342 | |||
343 | mutex_lock(&core->lock); | ||
344 | fh->resources &= ~bits; | ||
345 | dev->resources &= ~bits; | ||
346 | dprintk(1,"res: put %d\n",bits); | ||
347 | mutex_unlock(&core->lock); | ||
348 | } | ||
349 | |||
350 | /* ------------------------------------------------------------------ */ | 296 | /* ------------------------------------------------------------------ */ |
351 | 297 | ||
352 | int cx88_video_mux(struct cx88_core *core, unsigned int input) | 298 | int cx88_video_mux(struct cx88_core *core, unsigned int input) |
@@ -419,8 +365,8 @@ static int start_video_dma(struct cx8800_dev *dev, | |||
419 | /* setup fifo + format */ | 365 | /* setup fifo + format */ |
420 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], | 366 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], |
421 | buf->bpl, buf->risc.dma); | 367 | buf->bpl, buf->risc.dma); |
422 | cx88_set_scale(core, buf->vb.width, buf->vb.height, buf->vb.field); | 368 | cx88_set_scale(core, core->width, core->height, core->field); |
423 | cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma); | 369 | cx_write(MO_COLOR_CTRL, dev->fmt->cxformat | ColorFormatGamma); |
424 | 370 | ||
425 | /* reset counter */ | 371 | /* reset counter */ |
426 | cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET); | 372 | cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET); |
@@ -470,433 +416,211 @@ static int restart_video_queue(struct cx8800_dev *dev, | |||
470 | struct cx88_dmaqueue *q) | 416 | struct cx88_dmaqueue *q) |
471 | { | 417 | { |
472 | struct cx88_core *core = dev->core; | 418 | struct cx88_core *core = dev->core; |
473 | struct cx88_buffer *buf, *prev; | 419 | struct cx88_buffer *buf; |
474 | 420 | ||
475 | if (!list_empty(&q->active)) { | 421 | if (!list_empty(&q->active)) { |
476 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); | 422 | buf = list_entry(q->active.next, struct cx88_buffer, list); |
477 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", | 423 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", |
478 | buf, buf->vb.i); | 424 | buf, buf->vb.v4l2_buf.index); |
479 | start_video_dma(dev, q, buf); | 425 | start_video_dma(dev, q, buf); |
480 | list_for_each_entry(buf, &q->active, vb.queue) | 426 | list_for_each_entry(buf, &q->active, list) |
481 | buf->count = q->count++; | 427 | buf->count = q->count++; |
482 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | prev = NULL; | ||
487 | for (;;) { | ||
488 | if (list_empty(&q->queued)) | ||
489 | return 0; | ||
490 | buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue); | ||
491 | if (NULL == prev) { | ||
492 | list_move_tail(&buf->vb.queue, &q->active); | ||
493 | start_video_dma(dev, q, buf); | ||
494 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
495 | buf->count = q->count++; | ||
496 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
497 | dprintk(2,"[%p/%d] restart_queue - first active\n", | ||
498 | buf,buf->vb.i); | ||
499 | |||
500 | } else if (prev->vb.width == buf->vb.width && | ||
501 | prev->vb.height == buf->vb.height && | ||
502 | prev->fmt == buf->fmt) { | ||
503 | list_move_tail(&buf->vb.queue, &q->active); | ||
504 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
505 | buf->count = q->count++; | ||
506 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | ||
507 | dprintk(2,"[%p/%d] restart_queue - move to active\n", | ||
508 | buf,buf->vb.i); | ||
509 | } else { | ||
510 | return 0; | ||
511 | } | ||
512 | prev = buf; | ||
513 | } | 428 | } |
429 | return 0; | ||
514 | } | 430 | } |
515 | 431 | ||
516 | /* ------------------------------------------------------------------ */ | 432 | /* ------------------------------------------------------------------ */ |
517 | 433 | ||
518 | static int | 434 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
519 | buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | 435 | unsigned int *num_buffers, unsigned int *num_planes, |
436 | unsigned int sizes[], void *alloc_ctxs[]) | ||
520 | { | 437 | { |
521 | struct cx8800_fh *fh = q->priv_data; | 438 | struct cx8800_dev *dev = q->drv_priv; |
522 | struct cx8800_dev *dev = fh->dev; | 439 | struct cx88_core *core = dev->core; |
523 | 440 | ||
524 | *size = dev->fmt->depth * dev->width * dev->height >> 3; | 441 | *num_planes = 1; |
525 | if (0 == *count) | 442 | sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3; |
526 | *count = 32; | ||
527 | if (*size * *count > vid_limit * 1024 * 1024) | ||
528 | *count = (vid_limit * 1024 * 1024) / *size; | ||
529 | return 0; | 443 | return 0; |
530 | } | 444 | } |
531 | 445 | ||
532 | static int | 446 | static int buffer_prepare(struct vb2_buffer *vb) |
533 | buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | ||
534 | enum v4l2_field field) | ||
535 | { | 447 | { |
536 | struct cx8800_fh *fh = q->priv_data; | 448 | struct cx8800_dev *dev = vb->vb2_queue->drv_priv; |
537 | struct cx8800_dev *dev = fh->dev; | ||
538 | struct cx88_core *core = dev->core; | 449 | struct cx88_core *core = dev->core; |
539 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); | 450 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); |
540 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | 451 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); |
541 | int rc, init_buffer = 0; | 452 | int rc; |
542 | 453 | ||
543 | BUG_ON(NULL == dev->fmt); | 454 | buf->bpl = core->width * dev->fmt->depth >> 3; |
544 | if (dev->width < 48 || dev->width > norm_maxw(core->tvnorm) || | ||
545 | dev->height < 32 || dev->height > norm_maxh(core->tvnorm)) | ||
546 | return -EINVAL; | ||
547 | buf->vb.size = (dev->width * dev->height * dev->fmt->depth) >> 3; | ||
548 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
549 | return -EINVAL; | ||
550 | 455 | ||
551 | if (buf->fmt != dev->fmt || | 456 | if (vb2_plane_size(vb, 0) < core->height * buf->bpl) |
552 | buf->vb.width != dev->width || | 457 | return -EINVAL; |
553 | buf->vb.height != dev->height || | 458 | vb2_set_plane_payload(vb, 0, core->height * buf->bpl); |
554 | buf->vb.field != field) { | ||
555 | buf->fmt = dev->fmt; | ||
556 | buf->vb.width = dev->width; | ||
557 | buf->vb.height = dev->height; | ||
558 | buf->vb.field = field; | ||
559 | init_buffer = 1; | ||
560 | } | ||
561 | 459 | ||
562 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 460 | rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); |
563 | init_buffer = 1; | 461 | if (!rc) |
564 | if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL))) | 462 | return -EIO; |
565 | goto fail; | ||
566 | } | ||
567 | 463 | ||
568 | if (init_buffer) { | 464 | switch (core->field) { |
569 | buf->bpl = buf->vb.width * buf->fmt->depth >> 3; | 465 | case V4L2_FIELD_TOP: |
570 | switch (buf->vb.field) { | 466 | cx88_risc_buffer(dev->pci, &buf->risc, |
571 | case V4L2_FIELD_TOP: | 467 | sgt->sgl, 0, UNSET, |
572 | cx88_risc_buffer(dev->pci, &buf->risc, | 468 | buf->bpl, 0, core->height); |
573 | dma->sglist, 0, UNSET, | 469 | break; |
574 | buf->bpl, 0, buf->vb.height); | 470 | case V4L2_FIELD_BOTTOM: |
575 | break; | 471 | cx88_risc_buffer(dev->pci, &buf->risc, |
576 | case V4L2_FIELD_BOTTOM: | 472 | sgt->sgl, UNSET, 0, |
577 | cx88_risc_buffer(dev->pci, &buf->risc, | 473 | buf->bpl, 0, core->height); |
578 | dma->sglist, UNSET, 0, | 474 | break; |
579 | buf->bpl, 0, buf->vb.height); | 475 | case V4L2_FIELD_SEQ_TB: |
580 | break; | 476 | cx88_risc_buffer(dev->pci, &buf->risc, |
581 | case V4L2_FIELD_INTERLACED: | 477 | sgt->sgl, |
582 | cx88_risc_buffer(dev->pci, &buf->risc, | 478 | 0, buf->bpl * (core->height >> 1), |
583 | dma->sglist, 0, buf->bpl, | 479 | buf->bpl, 0, |
584 | buf->bpl, buf->bpl, | 480 | core->height >> 1); |
585 | buf->vb.height >> 1); | 481 | break; |
586 | break; | 482 | case V4L2_FIELD_SEQ_BT: |
587 | case V4L2_FIELD_SEQ_TB: | 483 | cx88_risc_buffer(dev->pci, &buf->risc, |
588 | cx88_risc_buffer(dev->pci, &buf->risc, | 484 | sgt->sgl, |
589 | dma->sglist, | 485 | buf->bpl * (core->height >> 1), 0, |
590 | 0, buf->bpl * (buf->vb.height >> 1), | 486 | buf->bpl, 0, |
591 | buf->bpl, 0, | 487 | core->height >> 1); |
592 | buf->vb.height >> 1); | 488 | break; |
593 | break; | 489 | case V4L2_FIELD_INTERLACED: |
594 | case V4L2_FIELD_SEQ_BT: | 490 | default: |
595 | cx88_risc_buffer(dev->pci, &buf->risc, | 491 | cx88_risc_buffer(dev->pci, &buf->risc, |
596 | dma->sglist, | 492 | sgt->sgl, 0, buf->bpl, |
597 | buf->bpl * (buf->vb.height >> 1), 0, | 493 | buf->bpl, buf->bpl, |
598 | buf->bpl, 0, | 494 | core->height >> 1); |
599 | buf->vb.height >> 1); | 495 | break; |
600 | break; | ||
601 | default: | ||
602 | BUG(); | ||
603 | } | ||
604 | } | 496 | } |
605 | dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", | 497 | dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", |
606 | buf, buf->vb.i, | 498 | buf, buf->vb.v4l2_buf.index, |
607 | dev->width, dev->height, dev->fmt->depth, dev->fmt->name, | 499 | core->width, core->height, dev->fmt->depth, dev->fmt->name, |
608 | (unsigned long)buf->risc.dma); | 500 | (unsigned long)buf->risc.dma); |
609 | |||
610 | buf->vb.state = VIDEOBUF_PREPARED; | ||
611 | return 0; | 501 | return 0; |
502 | } | ||
503 | |||
504 | static void buffer_finish(struct vb2_buffer *vb) | ||
505 | { | ||
506 | struct cx8800_dev *dev = vb->vb2_queue->drv_priv; | ||
507 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
508 | struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); | ||
509 | struct cx88_riscmem *risc = &buf->risc; | ||
510 | |||
511 | if (risc->cpu) | ||
512 | pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma); | ||
513 | memset(risc, 0, sizeof(*risc)); | ||
612 | 514 | ||
613 | fail: | 515 | dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE); |
614 | cx88_free_buffer(q,buf); | ||
615 | return rc; | ||
616 | } | 516 | } |
617 | 517 | ||
618 | static void | 518 | static void buffer_queue(struct vb2_buffer *vb) |
619 | buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
620 | { | 519 | { |
621 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); | 520 | struct cx8800_dev *dev = vb->vb2_queue->drv_priv; |
521 | struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); | ||
622 | struct cx88_buffer *prev; | 522 | struct cx88_buffer *prev; |
623 | struct cx8800_fh *fh = vq->priv_data; | ||
624 | struct cx8800_dev *dev = fh->dev; | ||
625 | struct cx88_core *core = dev->core; | 523 | struct cx88_core *core = dev->core; |
626 | struct cx88_dmaqueue *q = &dev->vidq; | 524 | struct cx88_dmaqueue *q = &dev->vidq; |
627 | 525 | ||
628 | /* add jump to stopper */ | 526 | /* add jump to start */ |
629 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); | 527 | buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 8); |
630 | buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); | 528 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); |
529 | buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 8); | ||
631 | 530 | ||
632 | if (!list_empty(&q->queued)) { | 531 | if (list_empty(&q->active)) { |
633 | list_add_tail(&buf->vb.queue,&q->queued); | 532 | list_add_tail(&buf->list, &q->active); |
634 | buf->vb.state = VIDEOBUF_QUEUED; | ||
635 | dprintk(2,"[%p/%d] buffer_queue - append to queued\n", | ||
636 | buf, buf->vb.i); | ||
637 | |||
638 | } else if (list_empty(&q->active)) { | ||
639 | list_add_tail(&buf->vb.queue,&q->active); | ||
640 | start_video_dma(dev, q, buf); | 533 | start_video_dma(dev, q, buf); |
641 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
642 | buf->count = q->count++; | 534 | buf->count = q->count++; |
643 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | ||
644 | dprintk(2,"[%p/%d] buffer_queue - first active\n", | 535 | dprintk(2,"[%p/%d] buffer_queue - first active\n", |
645 | buf, buf->vb.i); | 536 | buf, buf->vb.v4l2_buf.index); |
646 | 537 | ||
647 | } else { | 538 | } else { |
648 | prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue); | 539 | buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); |
649 | if (prev->vb.width == buf->vb.width && | 540 | prev = list_entry(q->active.prev, struct cx88_buffer, list); |
650 | prev->vb.height == buf->vb.height && | 541 | list_add_tail(&buf->list, &q->active); |
651 | prev->fmt == buf->fmt) { | 542 | buf->count = q->count++; |
652 | list_add_tail(&buf->vb.queue,&q->active); | 543 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
653 | buf->vb.state = VIDEOBUF_ACTIVE; | 544 | dprintk(2, "[%p/%d] buffer_queue - append to active\n", |
654 | buf->count = q->count++; | 545 | buf, buf->vb.v4l2_buf.index); |
655 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | ||
656 | dprintk(2,"[%p/%d] buffer_queue - append to active\n", | ||
657 | buf, buf->vb.i); | ||
658 | |||
659 | } else { | ||
660 | list_add_tail(&buf->vb.queue,&q->queued); | ||
661 | buf->vb.state = VIDEOBUF_QUEUED; | ||
662 | dprintk(2,"[%p/%d] buffer_queue - first queued\n", | ||
663 | buf, buf->vb.i); | ||
664 | } | ||
665 | } | 546 | } |
666 | } | 547 | } |
667 | 548 | ||
668 | static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | 549 | static int start_streaming(struct vb2_queue *q, unsigned int count) |
669 | { | 550 | { |
670 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); | 551 | struct cx8800_dev *dev = q->drv_priv; |
552 | struct cx88_dmaqueue *dmaq = &dev->vidq; | ||
553 | struct cx88_buffer *buf = list_entry(dmaq->active.next, | ||
554 | struct cx88_buffer, list); | ||
671 | 555 | ||
672 | cx88_free_buffer(q,buf); | 556 | start_video_dma(dev, dmaq, buf); |
557 | return 0; | ||
673 | } | 558 | } |
674 | 559 | ||
675 | static const struct videobuf_queue_ops cx8800_video_qops = { | 560 | static void stop_streaming(struct vb2_queue *q) |
676 | .buf_setup = buffer_setup, | ||
677 | .buf_prepare = buffer_prepare, | ||
678 | .buf_queue = buffer_queue, | ||
679 | .buf_release = buffer_release, | ||
680 | }; | ||
681 | |||
682 | /* ------------------------------------------------------------------ */ | ||
683 | |||
684 | |||
685 | /* ------------------------------------------------------------------ */ | ||
686 | |||
687 | static struct videobuf_queue *get_queue(struct file *file) | ||
688 | { | 561 | { |
689 | struct video_device *vdev = video_devdata(file); | 562 | struct cx8800_dev *dev = q->drv_priv; |
690 | struct cx8800_fh *fh = file->private_data; | 563 | struct cx88_core *core = dev->core; |
564 | struct cx88_dmaqueue *dmaq = &dev->vidq; | ||
565 | unsigned long flags; | ||
691 | 566 | ||
692 | switch (vdev->vfl_type) { | 567 | cx_clear(MO_VID_DMACNTRL, 0x11); |
693 | case VFL_TYPE_GRABBER: | 568 | cx_clear(VID_CAPTURE_CONTROL, 0x06); |
694 | return &fh->vidq; | 569 | spin_lock_irqsave(&dev->slock, flags); |
695 | case VFL_TYPE_VBI: | 570 | while (!list_empty(&dmaq->active)) { |
696 | return &fh->vbiq; | 571 | struct cx88_buffer *buf = list_entry(dmaq->active.next, |
697 | default: | 572 | struct cx88_buffer, list); |
698 | BUG(); | 573 | |
574 | list_del(&buf->list); | ||
575 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
699 | } | 576 | } |
577 | spin_unlock_irqrestore(&dev->slock, flags); | ||
700 | } | 578 | } |
701 | 579 | ||
702 | static int get_resource(struct file *file) | 580 | static struct vb2_ops cx8800_video_qops = { |
703 | { | 581 | .queue_setup = queue_setup, |
704 | struct video_device *vdev = video_devdata(file); | 582 | .buf_prepare = buffer_prepare, |
583 | .buf_finish = buffer_finish, | ||
584 | .buf_queue = buffer_queue, | ||
585 | .wait_prepare = vb2_ops_wait_prepare, | ||
586 | .wait_finish = vb2_ops_wait_finish, | ||
587 | .start_streaming = start_streaming, | ||
588 | .stop_streaming = stop_streaming, | ||
589 | }; | ||
705 | 590 | ||
706 | switch (vdev->vfl_type) { | 591 | /* ------------------------------------------------------------------ */ |
707 | case VFL_TYPE_GRABBER: | ||
708 | return RESOURCE_VIDEO; | ||
709 | case VFL_TYPE_VBI: | ||
710 | return RESOURCE_VBI; | ||
711 | default: | ||
712 | BUG(); | ||
713 | } | ||
714 | } | ||
715 | 592 | ||
716 | static int video_open(struct file *file) | 593 | static int radio_open(struct file *file) |
717 | { | 594 | { |
718 | struct video_device *vdev = video_devdata(file); | ||
719 | struct cx8800_dev *dev = video_drvdata(file); | 595 | struct cx8800_dev *dev = video_drvdata(file); |
720 | struct cx88_core *core = dev->core; | 596 | struct cx88_core *core = dev->core; |
721 | struct cx8800_fh *fh; | 597 | int ret = v4l2_fh_open(file); |
722 | enum v4l2_buf_type type = 0; | ||
723 | int radio = 0; | ||
724 | 598 | ||
725 | switch (vdev->vfl_type) { | 599 | if (ret) |
726 | case VFL_TYPE_GRABBER: | 600 | return ret; |
727 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
728 | break; | ||
729 | case VFL_TYPE_VBI: | ||
730 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
731 | break; | ||
732 | case VFL_TYPE_RADIO: | ||
733 | radio = 1; | ||
734 | break; | ||
735 | } | ||
736 | |||
737 | dprintk(1, "open dev=%s radio=%d type=%s\n", | ||
738 | video_device_node_name(vdev), radio, v4l2_type_names[type]); | ||
739 | |||
740 | /* allocate + initialize per filehandle data */ | ||
741 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); | ||
742 | if (unlikely(!fh)) | ||
743 | return -ENOMEM; | ||
744 | |||
745 | v4l2_fh_init(&fh->fh, vdev); | ||
746 | file->private_data = fh; | ||
747 | fh->dev = dev; | ||
748 | 601 | ||
749 | mutex_lock(&core->lock); | 602 | cx_write(MO_GP3_IO, core->board.radio.gpio3); |
750 | 603 | cx_write(MO_GP0_IO, core->board.radio.gpio0); | |
751 | videobuf_queue_sg_init(&fh->vidq, &cx8800_video_qops, | 604 | cx_write(MO_GP1_IO, core->board.radio.gpio1); |
752 | &dev->pci->dev, &dev->slock, | 605 | cx_write(MO_GP2_IO, core->board.radio.gpio2); |
753 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 606 | if (core->board.radio.audioroute) { |
754 | V4L2_FIELD_INTERLACED, | 607 | if (core->sd_wm8775) { |
755 | sizeof(struct cx88_buffer), | 608 | call_all(core, audio, s_routing, |
756 | fh, NULL); | ||
757 | videobuf_queue_sg_init(&fh->vbiq, &cx8800_vbi_qops, | ||
758 | &dev->pci->dev, &dev->slock, | ||
759 | V4L2_BUF_TYPE_VBI_CAPTURE, | ||
760 | V4L2_FIELD_SEQ_TB, | ||
761 | sizeof(struct cx88_buffer), | ||
762 | fh, NULL); | ||
763 | |||
764 | if (vdev->vfl_type == VFL_TYPE_RADIO) { | ||
765 | dprintk(1,"video_open: setting radio device\n"); | ||
766 | cx_write(MO_GP3_IO, core->board.radio.gpio3); | ||
767 | cx_write(MO_GP0_IO, core->board.radio.gpio0); | ||
768 | cx_write(MO_GP1_IO, core->board.radio.gpio1); | ||
769 | cx_write(MO_GP2_IO, core->board.radio.gpio2); | ||
770 | if (core->board.radio.audioroute) { | ||
771 | if (core->sd_wm8775) { | ||
772 | call_all(core, audio, s_routing, | ||
773 | core->board.radio.audioroute, 0, 0); | 609 | core->board.radio.audioroute, 0, 0); |
774 | } | ||
775 | /* "I2S ADC mode" */ | ||
776 | core->tvaudio = WW_I2SADC; | ||
777 | cx88_set_tvaudio(core); | ||
778 | } else { | ||
779 | /* FM Mode */ | ||
780 | core->tvaudio = WW_FM; | ||
781 | cx88_set_tvaudio(core); | ||
782 | cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); | ||
783 | } | 610 | } |
784 | call_all(core, tuner, s_radio); | 611 | /* "I2S ADC mode" */ |
785 | } | 612 | core->tvaudio = WW_I2SADC; |
786 | 613 | cx88_set_tvaudio(core); | |
787 | core->users++; | ||
788 | mutex_unlock(&core->lock); | ||
789 | v4l2_fh_add(&fh->fh); | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | static ssize_t | ||
795 | video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | ||
796 | { | ||
797 | struct video_device *vdev = video_devdata(file); | ||
798 | struct cx8800_fh *fh = file->private_data; | ||
799 | |||
800 | switch (vdev->vfl_type) { | ||
801 | case VFL_TYPE_GRABBER: | ||
802 | if (res_locked(fh->dev,RESOURCE_VIDEO)) | ||
803 | return -EBUSY; | ||
804 | return videobuf_read_one(&fh->vidq, data, count, ppos, | ||
805 | file->f_flags & O_NONBLOCK); | ||
806 | case VFL_TYPE_VBI: | ||
807 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) | ||
808 | return -EBUSY; | ||
809 | return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1, | ||
810 | file->f_flags & O_NONBLOCK); | ||
811 | default: | ||
812 | BUG(); | ||
813 | } | ||
814 | } | ||
815 | |||
816 | static unsigned int | ||
817 | video_poll(struct file *file, struct poll_table_struct *wait) | ||
818 | { | ||
819 | struct video_device *vdev = video_devdata(file); | ||
820 | struct cx8800_fh *fh = file->private_data; | ||
821 | struct cx88_buffer *buf; | ||
822 | unsigned int rc = v4l2_ctrl_poll(file, wait); | ||
823 | |||
824 | if (vdev->vfl_type == VFL_TYPE_VBI) { | ||
825 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) | ||
826 | return rc | POLLERR; | ||
827 | return rc | videobuf_poll_stream(file, &fh->vbiq, wait); | ||
828 | } | ||
829 | mutex_lock(&fh->vidq.vb_lock); | ||
830 | if (res_check(fh,RESOURCE_VIDEO)) { | ||
831 | /* streaming capture */ | ||
832 | if (list_empty(&fh->vidq.stream)) | ||
833 | goto done; | ||
834 | buf = list_entry(fh->vidq.stream.next,struct cx88_buffer,vb.stream); | ||
835 | } else { | 614 | } else { |
836 | /* read() capture */ | 615 | /* FM Mode */ |
837 | buf = (struct cx88_buffer*)fh->vidq.read_buf; | 616 | core->tvaudio = WW_FM; |
838 | if (NULL == buf) | 617 | cx88_set_tvaudio(core); |
839 | goto done; | 618 | cx88_set_stereo(core, V4L2_TUNER_MODE_STEREO, 1); |
840 | } | ||
841 | poll_wait(file, &buf->vb.done, wait); | ||
842 | if (buf->vb.state == VIDEOBUF_DONE || | ||
843 | buf->vb.state == VIDEOBUF_ERROR) | ||
844 | rc |= POLLIN|POLLRDNORM; | ||
845 | done: | ||
846 | mutex_unlock(&fh->vidq.vb_lock); | ||
847 | return rc; | ||
848 | } | ||
849 | |||
850 | static int video_release(struct file *file) | ||
851 | { | ||
852 | struct cx8800_fh *fh = file->private_data; | ||
853 | struct cx8800_dev *dev = fh->dev; | ||
854 | |||
855 | /* turn off overlay */ | ||
856 | if (res_check(fh, RESOURCE_OVERLAY)) { | ||
857 | /* FIXME */ | ||
858 | res_free(dev,fh,RESOURCE_OVERLAY); | ||
859 | } | ||
860 | |||
861 | /* stop video capture */ | ||
862 | if (res_check(fh, RESOURCE_VIDEO)) { | ||
863 | videobuf_queue_cancel(&fh->vidq); | ||
864 | res_free(dev,fh,RESOURCE_VIDEO); | ||
865 | } | 619 | } |
866 | if (fh->vidq.read_buf) { | 620 | call_all(core, tuner, s_radio); |
867 | buffer_release(&fh->vidq,fh->vidq.read_buf); | ||
868 | kfree(fh->vidq.read_buf); | ||
869 | } | ||
870 | |||
871 | /* stop vbi capture */ | ||
872 | if (res_check(fh, RESOURCE_VBI)) { | ||
873 | videobuf_stop(&fh->vbiq); | ||
874 | res_free(dev,fh,RESOURCE_VBI); | ||
875 | } | ||
876 | |||
877 | videobuf_mmap_free(&fh->vidq); | ||
878 | videobuf_mmap_free(&fh->vbiq); | ||
879 | |||
880 | mutex_lock(&dev->core->lock); | ||
881 | v4l2_fh_del(&fh->fh); | ||
882 | v4l2_fh_exit(&fh->fh); | ||
883 | file->private_data = NULL; | ||
884 | kfree(fh); | ||
885 | |||
886 | dev->core->users--; | ||
887 | if (!dev->core->users) | ||
888 | call_all(dev->core, core, s_power, 0); | ||
889 | mutex_unlock(&dev->core->lock); | ||
890 | |||
891 | return 0; | 621 | return 0; |
892 | } | 622 | } |
893 | 623 | ||
894 | static int | ||
895 | video_mmap(struct file *file, struct vm_area_struct * vma) | ||
896 | { | ||
897 | return videobuf_mmap_mapper(get_queue(file), vma); | ||
898 | } | ||
899 | |||
900 | /* ------------------------------------------------------------------ */ | 624 | /* ------------------------------------------------------------------ */ |
901 | /* VIDEO CTRL IOCTLS */ | 625 | /* VIDEO CTRL IOCTLS */ |
902 | 626 | ||
@@ -999,12 +723,12 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl) | |||
999 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | 723 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
1000 | struct v4l2_format *f) | 724 | struct v4l2_format *f) |
1001 | { | 725 | { |
1002 | struct cx8800_fh *fh = priv; | 726 | struct cx8800_dev *dev = video_drvdata(file); |
1003 | struct cx8800_dev *dev = fh->dev; | 727 | struct cx88_core *core = dev->core; |
1004 | 728 | ||
1005 | f->fmt.pix.width = dev->width; | 729 | f->fmt.pix.width = core->width; |
1006 | f->fmt.pix.height = dev->height; | 730 | f->fmt.pix.height = core->height; |
1007 | f->fmt.pix.field = fh->vidq.field; | 731 | f->fmt.pix.field = core->field; |
1008 | f->fmt.pix.pixelformat = dev->fmt->fourcc; | 732 | f->fmt.pix.pixelformat = dev->fmt->fourcc; |
1009 | f->fmt.pix.bytesperline = | 733 | f->fmt.pix.bytesperline = |
1010 | (f->fmt.pix.width * dev->fmt->depth) >> 3; | 734 | (f->fmt.pix.width * dev->fmt->depth) >> 3; |
@@ -1017,7 +741,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
1017 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | 741 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
1018 | struct v4l2_format *f) | 742 | struct v4l2_format *f) |
1019 | { | 743 | { |
1020 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 744 | struct cx8800_dev *dev = video_drvdata(file); |
745 | struct cx88_core *core = dev->core; | ||
1021 | const struct cx8800_fmt *fmt; | 746 | const struct cx8800_fmt *fmt; |
1022 | enum v4l2_field field; | 747 | enum v4l2_field field; |
1023 | unsigned int maxw, maxh; | 748 | unsigned int maxw, maxh; |
@@ -1026,30 +751,30 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
1026 | if (NULL == fmt) | 751 | if (NULL == fmt) |
1027 | return -EINVAL; | 752 | return -EINVAL; |
1028 | 753 | ||
1029 | field = f->fmt.pix.field; | 754 | maxw = norm_maxw(core->tvnorm); |
1030 | maxw = norm_maxw(core->tvnorm); | 755 | maxh = norm_maxh(core->tvnorm); |
1031 | maxh = norm_maxh(core->tvnorm); | ||
1032 | 756 | ||
1033 | if (V4L2_FIELD_ANY == field) { | 757 | field = f->fmt.pix.field; |
1034 | field = (f->fmt.pix.height > maxh/2) | ||
1035 | ? V4L2_FIELD_INTERLACED | ||
1036 | : V4L2_FIELD_BOTTOM; | ||
1037 | } | ||
1038 | 758 | ||
1039 | switch (field) { | 759 | switch (field) { |
1040 | case V4L2_FIELD_TOP: | 760 | case V4L2_FIELD_TOP: |
1041 | case V4L2_FIELD_BOTTOM: | 761 | case V4L2_FIELD_BOTTOM: |
1042 | maxh = maxh / 2; | ||
1043 | break; | ||
1044 | case V4L2_FIELD_INTERLACED: | 762 | case V4L2_FIELD_INTERLACED: |
763 | case V4L2_FIELD_SEQ_BT: | ||
764 | case V4L2_FIELD_SEQ_TB: | ||
1045 | break; | 765 | break; |
1046 | default: | 766 | default: |
1047 | return -EINVAL; | 767 | field = (f->fmt.pix.height > maxh / 2) |
768 | ? V4L2_FIELD_INTERLACED | ||
769 | : V4L2_FIELD_BOTTOM; | ||
770 | break; | ||
1048 | } | 771 | } |
772 | if (V4L2_FIELD_HAS_T_OR_B(field)) | ||
773 | maxh /= 2; | ||
1049 | 774 | ||
1050 | f->fmt.pix.field = field; | ||
1051 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, | 775 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, |
1052 | &f->fmt.pix.height, 32, maxh, 0, 0); | 776 | &f->fmt.pix.height, 32, maxh, 0, 0); |
777 | f->fmt.pix.field = field; | ||
1053 | f->fmt.pix.bytesperline = | 778 | f->fmt.pix.bytesperline = |
1054 | (f->fmt.pix.width * fmt->depth) >> 3; | 779 | (f->fmt.pix.width * fmt->depth) >> 3; |
1055 | f->fmt.pix.sizeimage = | 780 | f->fmt.pix.sizeimage = |
@@ -1061,16 +786,20 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
1061 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | 786 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, |
1062 | struct v4l2_format *f) | 787 | struct v4l2_format *f) |
1063 | { | 788 | { |
1064 | struct cx8800_fh *fh = priv; | 789 | struct cx8800_dev *dev = video_drvdata(file); |
1065 | struct cx8800_dev *dev = fh->dev; | 790 | struct cx88_core *core = dev->core; |
1066 | int err = vidioc_try_fmt_vid_cap (file,priv,f); | 791 | int err = vidioc_try_fmt_vid_cap (file,priv,f); |
1067 | 792 | ||
1068 | if (0 != err) | 793 | if (0 != err) |
1069 | return err; | 794 | return err; |
1070 | dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 795 | if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq)) |
1071 | dev->width = f->fmt.pix.width; | 796 | return -EBUSY; |
1072 | dev->height = f->fmt.pix.height; | 797 | if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) |
1073 | fh->vidq.field = f->fmt.pix.field; | 798 | return -EBUSY; |
799 | dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
800 | core->width = f->fmt.pix.width; | ||
801 | core->height = f->fmt.pix.height; | ||
802 | core->field = f->fmt.pix.field; | ||
1074 | return 0; | 803 | return 0; |
1075 | } | 804 | } |
1076 | 805 | ||
@@ -1104,8 +833,8 @@ EXPORT_SYMBOL(cx88_querycap); | |||
1104 | static int vidioc_querycap(struct file *file, void *priv, | 833 | static int vidioc_querycap(struct file *file, void *priv, |
1105 | struct v4l2_capability *cap) | 834 | struct v4l2_capability *cap) |
1106 | { | 835 | { |
1107 | struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev; | 836 | struct cx8800_dev *dev = video_drvdata(file); |
1108 | struct cx88_core *core = dev->core; | 837 | struct cx88_core *core = dev->core; |
1109 | 838 | ||
1110 | strcpy(cap->driver, "cx8800"); | 839 | strcpy(cap->driver, "cx8800"); |
1111 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); | 840 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); |
@@ -1125,64 +854,10 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | |||
1125 | return 0; | 854 | return 0; |
1126 | } | 855 | } |
1127 | 856 | ||
1128 | static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) | ||
1129 | { | ||
1130 | return videobuf_reqbufs(get_queue(file), p); | ||
1131 | } | ||
1132 | |||
1133 | static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) | ||
1134 | { | ||
1135 | return videobuf_querybuf(get_queue(file), p); | ||
1136 | } | ||
1137 | |||
1138 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) | ||
1139 | { | ||
1140 | return videobuf_qbuf(get_queue(file), p); | ||
1141 | } | ||
1142 | |||
1143 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) | ||
1144 | { | ||
1145 | return videobuf_dqbuf(get_queue(file), p, | ||
1146 | file->f_flags & O_NONBLOCK); | ||
1147 | } | ||
1148 | |||
1149 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1150 | { | ||
1151 | struct video_device *vdev = video_devdata(file); | ||
1152 | struct cx8800_fh *fh = priv; | ||
1153 | struct cx8800_dev *dev = fh->dev; | ||
1154 | |||
1155 | if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) || | ||
1156 | (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE)) | ||
1157 | return -EINVAL; | ||
1158 | |||
1159 | if (unlikely(!res_get(dev, fh, get_resource(file)))) | ||
1160 | return -EBUSY; | ||
1161 | return videobuf_streamon(get_queue(file)); | ||
1162 | } | ||
1163 | |||
1164 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1165 | { | ||
1166 | struct video_device *vdev = video_devdata(file); | ||
1167 | struct cx8800_fh *fh = priv; | ||
1168 | struct cx8800_dev *dev = fh->dev; | ||
1169 | int err, res; | ||
1170 | |||
1171 | if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) || | ||
1172 | (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE)) | ||
1173 | return -EINVAL; | ||
1174 | |||
1175 | res = get_resource(file); | ||
1176 | err = videobuf_streamoff(get_queue(file)); | ||
1177 | if (err < 0) | ||
1178 | return err; | ||
1179 | res_free(dev,fh,res); | ||
1180 | return 0; | ||
1181 | } | ||
1182 | |||
1183 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) | 857 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) |
1184 | { | 858 | { |
1185 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 859 | struct cx8800_dev *dev = video_drvdata(file); |
860 | struct cx88_core *core = dev->core; | ||
1186 | 861 | ||
1187 | *tvnorm = core->tvnorm; | 862 | *tvnorm = core->tvnorm; |
1188 | return 0; | 863 | return 0; |
@@ -1190,13 +865,10 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) | |||
1190 | 865 | ||
1191 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms) | 866 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms) |
1192 | { | 867 | { |
1193 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 868 | struct cx8800_dev *dev = video_drvdata(file); |
1194 | 869 | struct cx88_core *core = dev->core; | |
1195 | mutex_lock(&core->lock); | ||
1196 | cx88_set_tvnorm(core, tvnorms); | ||
1197 | mutex_unlock(&core->lock); | ||
1198 | 870 | ||
1199 | return 0; | 871 | return cx88_set_tvnorm(core, tvnorms); |
1200 | } | 872 | } |
1201 | 873 | ||
1202 | /* only one input in this sample driver */ | 874 | /* only one input in this sample driver */ |
@@ -1233,13 +905,15 @@ EXPORT_SYMBOL(cx88_enum_input); | |||
1233 | static int vidioc_enum_input (struct file *file, void *priv, | 905 | static int vidioc_enum_input (struct file *file, void *priv, |
1234 | struct v4l2_input *i) | 906 | struct v4l2_input *i) |
1235 | { | 907 | { |
1236 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 908 | struct cx8800_dev *dev = video_drvdata(file); |
909 | struct cx88_core *core = dev->core; | ||
1237 | return cx88_enum_input (core,i); | 910 | return cx88_enum_input (core,i); |
1238 | } | 911 | } |
1239 | 912 | ||
1240 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) | 913 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) |
1241 | { | 914 | { |
1242 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 915 | struct cx8800_dev *dev = video_drvdata(file); |
916 | struct cx88_core *core = dev->core; | ||
1243 | 917 | ||
1244 | *i = core->input; | 918 | *i = core->input; |
1245 | return 0; | 919 | return 0; |
@@ -1247,24 +921,24 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) | |||
1247 | 921 | ||
1248 | static int vidioc_s_input (struct file *file, void *priv, unsigned int i) | 922 | static int vidioc_s_input (struct file *file, void *priv, unsigned int i) |
1249 | { | 923 | { |
1250 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 924 | struct cx8800_dev *dev = video_drvdata(file); |
925 | struct cx88_core *core = dev->core; | ||
1251 | 926 | ||
1252 | if (i >= 4) | 927 | if (i >= 4) |
1253 | return -EINVAL; | 928 | return -EINVAL; |
1254 | if (0 == INPUT(i).type) | 929 | if (0 == INPUT(i).type) |
1255 | return -EINVAL; | 930 | return -EINVAL; |
1256 | 931 | ||
1257 | mutex_lock(&core->lock); | ||
1258 | cx88_newstation(core); | 932 | cx88_newstation(core); |
1259 | cx88_video_mux(core,i); | 933 | cx88_video_mux(core,i); |
1260 | mutex_unlock(&core->lock); | ||
1261 | return 0; | 934 | return 0; |
1262 | } | 935 | } |
1263 | 936 | ||
1264 | static int vidioc_g_tuner (struct file *file, void *priv, | 937 | static int vidioc_g_tuner (struct file *file, void *priv, |
1265 | struct v4l2_tuner *t) | 938 | struct v4l2_tuner *t) |
1266 | { | 939 | { |
1267 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 940 | struct cx8800_dev *dev = video_drvdata(file); |
941 | struct cx88_core *core = dev->core; | ||
1268 | u32 reg; | 942 | u32 reg; |
1269 | 943 | ||
1270 | if (unlikely(UNSET == core->board.tuner_type)) | 944 | if (unlikely(UNSET == core->board.tuner_type)) |
@@ -1286,7 +960,8 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
1286 | static int vidioc_s_tuner (struct file *file, void *priv, | 960 | static int vidioc_s_tuner (struct file *file, void *priv, |
1287 | const struct v4l2_tuner *t) | 961 | const struct v4l2_tuner *t) |
1288 | { | 962 | { |
1289 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 963 | struct cx8800_dev *dev = video_drvdata(file); |
964 | struct cx88_core *core = dev->core; | ||
1290 | 965 | ||
1291 | if (UNSET == core->board.tuner_type) | 966 | if (UNSET == core->board.tuner_type) |
1292 | return -EINVAL; | 967 | return -EINVAL; |
@@ -1300,8 +975,8 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
1300 | static int vidioc_g_frequency (struct file *file, void *priv, | 975 | static int vidioc_g_frequency (struct file *file, void *priv, |
1301 | struct v4l2_frequency *f) | 976 | struct v4l2_frequency *f) |
1302 | { | 977 | { |
1303 | struct cx8800_fh *fh = priv; | 978 | struct cx8800_dev *dev = video_drvdata(file); |
1304 | struct cx88_core *core = fh->dev->core; | 979 | struct cx88_core *core = dev->core; |
1305 | 980 | ||
1306 | if (unlikely(UNSET == core->board.tuner_type)) | 981 | if (unlikely(UNSET == core->board.tuner_type)) |
1307 | return -EINVAL; | 982 | return -EINVAL; |
@@ -1325,7 +1000,6 @@ int cx88_set_freq (struct cx88_core *core, | |||
1325 | if (unlikely(f->tuner != 0)) | 1000 | if (unlikely(f->tuner != 0)) |
1326 | return -EINVAL; | 1001 | return -EINVAL; |
1327 | 1002 | ||
1328 | mutex_lock(&core->lock); | ||
1329 | cx88_newstation(core); | 1003 | cx88_newstation(core); |
1330 | call_all(core, tuner, s_frequency, f); | 1004 | call_all(core, tuner, s_frequency, f); |
1331 | call_all(core, tuner, g_frequency, &new_freq); | 1005 | call_all(core, tuner, g_frequency, &new_freq); |
@@ -1335,8 +1009,6 @@ int cx88_set_freq (struct cx88_core *core, | |||
1335 | msleep (10); | 1009 | msleep (10); |
1336 | cx88_set_tvaudio(core); | 1010 | cx88_set_tvaudio(core); |
1337 | 1011 | ||
1338 | mutex_unlock(&core->lock); | ||
1339 | |||
1340 | return 0; | 1012 | return 0; |
1341 | } | 1013 | } |
1342 | EXPORT_SYMBOL(cx88_set_freq); | 1014 | EXPORT_SYMBOL(cx88_set_freq); |
@@ -1344,8 +1016,8 @@ EXPORT_SYMBOL(cx88_set_freq); | |||
1344 | static int vidioc_s_frequency (struct file *file, void *priv, | 1016 | static int vidioc_s_frequency (struct file *file, void *priv, |
1345 | const struct v4l2_frequency *f) | 1017 | const struct v4l2_frequency *f) |
1346 | { | 1018 | { |
1347 | struct cx8800_fh *fh = priv; | 1019 | struct cx8800_dev *dev = video_drvdata(file); |
1348 | struct cx88_core *core = fh->dev->core; | 1020 | struct cx88_core *core = dev->core; |
1349 | 1021 | ||
1350 | return cx88_set_freq(core, f); | 1022 | return cx88_set_freq(core, f); |
1351 | } | 1023 | } |
@@ -1354,7 +1026,8 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
1354 | static int vidioc_g_register (struct file *file, void *fh, | 1026 | static int vidioc_g_register (struct file *file, void *fh, |
1355 | struct v4l2_dbg_register *reg) | 1027 | struct v4l2_dbg_register *reg) |
1356 | { | 1028 | { |
1357 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; | 1029 | struct cx8800_dev *dev = video_drvdata(file); |
1030 | struct cx88_core *core = dev->core; | ||
1358 | 1031 | ||
1359 | /* cx2388x has a 24-bit register space */ | 1032 | /* cx2388x has a 24-bit register space */ |
1360 | reg->val = cx_read(reg->reg & 0xfffffc); | 1033 | reg->val = cx_read(reg->reg & 0xfffffc); |
@@ -1365,7 +1038,8 @@ static int vidioc_g_register (struct file *file, void *fh, | |||
1365 | static int vidioc_s_register (struct file *file, void *fh, | 1038 | static int vidioc_s_register (struct file *file, void *fh, |
1366 | const struct v4l2_dbg_register *reg) | 1039 | const struct v4l2_dbg_register *reg) |
1367 | { | 1040 | { |
1368 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; | 1041 | struct cx8800_dev *dev = video_drvdata(file); |
1042 | struct cx88_core *core = dev->core; | ||
1369 | 1043 | ||
1370 | cx_write(reg->reg & 0xfffffc, reg->val); | 1044 | cx_write(reg->reg & 0xfffffc, reg->val); |
1371 | return 0; | 1045 | return 0; |
@@ -1379,7 +1053,8 @@ static int vidioc_s_register (struct file *file, void *fh, | |||
1379 | static int radio_g_tuner (struct file *file, void *priv, | 1053 | static int radio_g_tuner (struct file *file, void *priv, |
1380 | struct v4l2_tuner *t) | 1054 | struct v4l2_tuner *t) |
1381 | { | 1055 | { |
1382 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 1056 | struct cx8800_dev *dev = video_drvdata(file); |
1057 | struct cx88_core *core = dev->core; | ||
1383 | 1058 | ||
1384 | if (unlikely(t->index > 0)) | 1059 | if (unlikely(t->index > 0)) |
1385 | return -EINVAL; | 1060 | return -EINVAL; |
@@ -1393,7 +1068,8 @@ static int radio_g_tuner (struct file *file, void *priv, | |||
1393 | static int radio_s_tuner (struct file *file, void *priv, | 1068 | static int radio_s_tuner (struct file *file, void *priv, |
1394 | const struct v4l2_tuner *t) | 1069 | const struct v4l2_tuner *t) |
1395 | { | 1070 | { |
1396 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 1071 | struct cx8800_dev *dev = video_drvdata(file); |
1072 | struct cx88_core *core = dev->core; | ||
1397 | 1073 | ||
1398 | if (0 != t->index) | 1074 | if (0 != t->index) |
1399 | return -EINVAL; | 1075 | return -EINVAL; |
@@ -1404,32 +1080,6 @@ static int radio_s_tuner (struct file *file, void *priv, | |||
1404 | 1080 | ||
1405 | /* ----------------------------------------------------------- */ | 1081 | /* ----------------------------------------------------------- */ |
1406 | 1082 | ||
1407 | static void cx8800_vid_timeout(unsigned long data) | ||
1408 | { | ||
1409 | struct cx8800_dev *dev = (struct cx8800_dev*)data; | ||
1410 | struct cx88_core *core = dev->core; | ||
1411 | struct cx88_dmaqueue *q = &dev->vidq; | ||
1412 | struct cx88_buffer *buf; | ||
1413 | unsigned long flags; | ||
1414 | |||
1415 | cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); | ||
1416 | |||
1417 | cx_clear(MO_VID_DMACNTRL, 0x11); | ||
1418 | cx_clear(VID_CAPTURE_CONTROL, 0x06); | ||
1419 | |||
1420 | spin_lock_irqsave(&dev->slock,flags); | ||
1421 | while (!list_empty(&q->active)) { | ||
1422 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); | ||
1423 | list_del(&buf->vb.queue); | ||
1424 | buf->vb.state = VIDEOBUF_ERROR; | ||
1425 | wake_up(&buf->vb.done); | ||
1426 | printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core->name, | ||
1427 | buf, buf->vb.i, (unsigned long)buf->risc.dma); | ||
1428 | } | ||
1429 | restart_video_queue(dev,q); | ||
1430 | spin_unlock_irqrestore(&dev->slock,flags); | ||
1431 | } | ||
1432 | |||
1433 | static const char *cx88_vid_irqs[32] = { | 1083 | static const char *cx88_vid_irqs[32] = { |
1434 | "y_risci1", "u_risci1", "v_risci1", "vbi_risc1", | 1084 | "y_risci1", "u_risci1", "v_risci1", "vbi_risc1", |
1435 | "y_risci2", "u_risci2", "v_risci2", "vbi_risc2", | 1085 | "y_risci2", "u_risci2", "v_risci2", "vbi_risc2", |
@@ -1476,22 +1126,6 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) | |||
1476 | cx88_wakeup(core, &dev->vbiq, count); | 1126 | cx88_wakeup(core, &dev->vbiq, count); |
1477 | spin_unlock(&dev->slock); | 1127 | spin_unlock(&dev->slock); |
1478 | } | 1128 | } |
1479 | |||
1480 | /* risc2 y */ | ||
1481 | if (status & 0x10) { | ||
1482 | dprintk(2,"stopper video\n"); | ||
1483 | spin_lock(&dev->slock); | ||
1484 | restart_video_queue(dev,&dev->vidq); | ||
1485 | spin_unlock(&dev->slock); | ||
1486 | } | ||
1487 | |||
1488 | /* risc2 vbi */ | ||
1489 | if (status & 0x80) { | ||
1490 | dprintk(2,"stopper vbi\n"); | ||
1491 | spin_lock(&dev->slock); | ||
1492 | cx8800_restart_vbi_queue(dev,&dev->vbiq); | ||
1493 | spin_unlock(&dev->slock); | ||
1494 | } | ||
1495 | } | 1129 | } |
1496 | 1130 | ||
1497 | static irqreturn_t cx8800_irq(int irq, void *dev_id) | 1131 | static irqreturn_t cx8800_irq(int irq, void *dev_id) |
@@ -1530,11 +1164,11 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id) | |||
1530 | static const struct v4l2_file_operations video_fops = | 1164 | static const struct v4l2_file_operations video_fops = |
1531 | { | 1165 | { |
1532 | .owner = THIS_MODULE, | 1166 | .owner = THIS_MODULE, |
1533 | .open = video_open, | 1167 | .open = v4l2_fh_open, |
1534 | .release = video_release, | 1168 | .release = vb2_fop_release, |
1535 | .read = video_read, | 1169 | .read = vb2_fop_read, |
1536 | .poll = video_poll, | 1170 | .poll = vb2_fop_poll, |
1537 | .mmap = video_mmap, | 1171 | .mmap = vb2_fop_mmap, |
1538 | .unlocked_ioctl = video_ioctl2, | 1172 | .unlocked_ioctl = video_ioctl2, |
1539 | }; | 1173 | }; |
1540 | 1174 | ||
@@ -1544,17 +1178,17 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1544 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | 1178 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
1545 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | 1179 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
1546 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | 1180 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
1547 | .vidioc_reqbufs = vidioc_reqbufs, | 1181 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1548 | .vidioc_querybuf = vidioc_querybuf, | 1182 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1549 | .vidioc_qbuf = vidioc_qbuf, | 1183 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1550 | .vidioc_dqbuf = vidioc_dqbuf, | 1184 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1551 | .vidioc_g_std = vidioc_g_std, | 1185 | .vidioc_g_std = vidioc_g_std, |
1552 | .vidioc_s_std = vidioc_s_std, | 1186 | .vidioc_s_std = vidioc_s_std, |
1553 | .vidioc_enum_input = vidioc_enum_input, | 1187 | .vidioc_enum_input = vidioc_enum_input, |
1554 | .vidioc_g_input = vidioc_g_input, | 1188 | .vidioc_g_input = vidioc_g_input, |
1555 | .vidioc_s_input = vidioc_s_input, | 1189 | .vidioc_s_input = vidioc_s_input, |
1556 | .vidioc_streamon = vidioc_streamon, | 1190 | .vidioc_streamon = vb2_ioctl_streamon, |
1557 | .vidioc_streamoff = vidioc_streamoff, | 1191 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1558 | .vidioc_g_tuner = vidioc_g_tuner, | 1192 | .vidioc_g_tuner = vidioc_g_tuner, |
1559 | .vidioc_s_tuner = vidioc_s_tuner, | 1193 | .vidioc_s_tuner = vidioc_s_tuner, |
1560 | .vidioc_g_frequency = vidioc_g_frequency, | 1194 | .vidioc_g_frequency = vidioc_g_frequency, |
@@ -1579,17 +1213,17 @@ static const struct v4l2_ioctl_ops vbi_ioctl_ops = { | |||
1579 | .vidioc_g_fmt_vbi_cap = cx8800_vbi_fmt, | 1213 | .vidioc_g_fmt_vbi_cap = cx8800_vbi_fmt, |
1580 | .vidioc_try_fmt_vbi_cap = cx8800_vbi_fmt, | 1214 | .vidioc_try_fmt_vbi_cap = cx8800_vbi_fmt, |
1581 | .vidioc_s_fmt_vbi_cap = cx8800_vbi_fmt, | 1215 | .vidioc_s_fmt_vbi_cap = cx8800_vbi_fmt, |
1582 | .vidioc_reqbufs = vidioc_reqbufs, | 1216 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1583 | .vidioc_querybuf = vidioc_querybuf, | 1217 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1584 | .vidioc_qbuf = vidioc_qbuf, | 1218 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1585 | .vidioc_dqbuf = vidioc_dqbuf, | 1219 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1586 | .vidioc_g_std = vidioc_g_std, | 1220 | .vidioc_g_std = vidioc_g_std, |
1587 | .vidioc_s_std = vidioc_s_std, | 1221 | .vidioc_s_std = vidioc_s_std, |
1588 | .vidioc_enum_input = vidioc_enum_input, | 1222 | .vidioc_enum_input = vidioc_enum_input, |
1589 | .vidioc_g_input = vidioc_g_input, | 1223 | .vidioc_g_input = vidioc_g_input, |
1590 | .vidioc_s_input = vidioc_s_input, | 1224 | .vidioc_s_input = vidioc_s_input, |
1591 | .vidioc_streamon = vidioc_streamon, | 1225 | .vidioc_streamon = vb2_ioctl_streamon, |
1592 | .vidioc_streamoff = vidioc_streamoff, | 1226 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1593 | .vidioc_g_tuner = vidioc_g_tuner, | 1227 | .vidioc_g_tuner = vidioc_g_tuner, |
1594 | .vidioc_s_tuner = vidioc_s_tuner, | 1228 | .vidioc_s_tuner = vidioc_s_tuner, |
1595 | .vidioc_g_frequency = vidioc_g_frequency, | 1229 | .vidioc_g_frequency = vidioc_g_frequency, |
@@ -1610,9 +1244,9 @@ static const struct video_device cx8800_vbi_template = { | |||
1610 | static const struct v4l2_file_operations radio_fops = | 1244 | static const struct v4l2_file_operations radio_fops = |
1611 | { | 1245 | { |
1612 | .owner = THIS_MODULE, | 1246 | .owner = THIS_MODULE, |
1613 | .open = video_open, | 1247 | .open = radio_open, |
1614 | .poll = v4l2_ctrl_poll, | 1248 | .poll = v4l2_ctrl_poll, |
1615 | .release = video_release, | 1249 | .release = v4l2_fh_release, |
1616 | .unlocked_ioctl = video_ioctl2, | 1250 | .unlocked_ioctl = video_ioctl2, |
1617 | }; | 1251 | }; |
1618 | 1252 | ||
@@ -1676,6 +1310,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, | |||
1676 | { | 1310 | { |
1677 | struct cx8800_dev *dev; | 1311 | struct cx8800_dev *dev; |
1678 | struct cx88_core *core; | 1312 | struct cx88_core *core; |
1313 | struct vb2_queue *q; | ||
1679 | int err; | 1314 | int err; |
1680 | int i; | 1315 | int i; |
1681 | 1316 | ||
@@ -1713,25 +1348,12 @@ static int cx8800_initdev(struct pci_dev *pci_dev, | |||
1713 | 1348 | ||
1714 | /* initialize driver struct */ | 1349 | /* initialize driver struct */ |
1715 | spin_lock_init(&dev->slock); | 1350 | spin_lock_init(&dev->slock); |
1716 | core->tvnorm = V4L2_STD_NTSC_M; | ||
1717 | 1351 | ||
1718 | /* init video dma queues */ | 1352 | /* init video dma queues */ |
1719 | INIT_LIST_HEAD(&dev->vidq.active); | 1353 | INIT_LIST_HEAD(&dev->vidq.active); |
1720 | INIT_LIST_HEAD(&dev->vidq.queued); | ||
1721 | dev->vidq.timeout.function = cx8800_vid_timeout; | ||
1722 | dev->vidq.timeout.data = (unsigned long)dev; | ||
1723 | init_timer(&dev->vidq.timeout); | ||
1724 | cx88_risc_stopper(dev->pci,&dev->vidq.stopper, | ||
1725 | MO_VID_DMACNTRL,0x11,0x00); | ||
1726 | 1354 | ||
1727 | /* init vbi dma queues */ | 1355 | /* init vbi dma queues */ |
1728 | INIT_LIST_HEAD(&dev->vbiq.active); | 1356 | INIT_LIST_HEAD(&dev->vbiq.active); |
1729 | INIT_LIST_HEAD(&dev->vbiq.queued); | ||
1730 | dev->vbiq.timeout.function = cx8800_vbi_timeout; | ||
1731 | dev->vbiq.timeout.data = (unsigned long)dev; | ||
1732 | init_timer(&dev->vbiq.timeout); | ||
1733 | cx88_risc_stopper(dev->pci,&dev->vbiq.stopper, | ||
1734 | MO_VID_DMACNTRL,0x88,0x00); | ||
1735 | 1357 | ||
1736 | /* get irq */ | 1358 | /* get irq */ |
1737 | err = request_irq(pci_dev->irq, cx8800_irq, | 1359 | err = request_irq(pci_dev->irq, cx8800_irq, |
@@ -1820,9 +1442,10 @@ static int cx8800_initdev(struct pci_dev *pci_dev, | |||
1820 | /* Sets device info at pci_dev */ | 1442 | /* Sets device info at pci_dev */ |
1821 | pci_set_drvdata(pci_dev, dev); | 1443 | pci_set_drvdata(pci_dev, dev); |
1822 | 1444 | ||
1823 | dev->width = 320; | 1445 | dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); |
1824 | dev->height = 240; | 1446 | |
1825 | dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | 1447 | /* Maintain a reference so cx88-blackbird can query the 8800 device. */ |
1448 | core->v4ldev = dev; | ||
1826 | 1449 | ||
1827 | /* initial device configuration */ | 1450 | /* initial device configuration */ |
1828 | mutex_lock(&core->lock); | 1451 | mutex_lock(&core->lock); |
@@ -1831,11 +1454,44 @@ static int cx8800_initdev(struct pci_dev *pci_dev, | |||
1831 | v4l2_ctrl_handler_setup(&core->audio_hdl); | 1454 | v4l2_ctrl_handler_setup(&core->audio_hdl); |
1832 | cx88_video_mux(core, 0); | 1455 | cx88_video_mux(core, 0); |
1833 | 1456 | ||
1457 | q = &dev->vb2_vidq; | ||
1458 | q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1459 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; | ||
1460 | q->gfp_flags = GFP_DMA32; | ||
1461 | q->min_buffers_needed = 2; | ||
1462 | q->drv_priv = dev; | ||
1463 | q->buf_struct_size = sizeof(struct cx88_buffer); | ||
1464 | q->ops = &cx8800_video_qops; | ||
1465 | q->mem_ops = &vb2_dma_sg_memops; | ||
1466 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1467 | q->lock = &core->lock; | ||
1468 | |||
1469 | err = vb2_queue_init(q); | ||
1470 | if (err < 0) | ||
1471 | goto fail_unreg; | ||
1472 | |||
1473 | q = &dev->vb2_vbiq; | ||
1474 | q->type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
1475 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; | ||
1476 | q->gfp_flags = GFP_DMA32; | ||
1477 | q->min_buffers_needed = 2; | ||
1478 | q->drv_priv = dev; | ||
1479 | q->buf_struct_size = sizeof(struct cx88_buffer); | ||
1480 | q->ops = &cx8800_vbi_qops; | ||
1481 | q->mem_ops = &vb2_dma_sg_memops; | ||
1482 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1483 | q->lock = &core->lock; | ||
1484 | |||
1485 | err = vb2_queue_init(q); | ||
1486 | if (err < 0) | ||
1487 | goto fail_unreg; | ||
1488 | |||
1834 | /* register v4l devices */ | 1489 | /* register v4l devices */ |
1835 | dev->video_dev = cx88_vdev_init(core,dev->pci, | 1490 | dev->video_dev = cx88_vdev_init(core,dev->pci, |
1836 | &cx8800_video_template,"video"); | 1491 | &cx8800_video_template,"video"); |
1837 | video_set_drvdata(dev->video_dev, dev); | 1492 | video_set_drvdata(dev->video_dev, dev); |
1838 | dev->video_dev->ctrl_handler = &core->video_hdl; | 1493 | dev->video_dev->ctrl_handler = &core->video_hdl; |
1494 | dev->video_dev->queue = &dev->vb2_vidq; | ||
1839 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, | 1495 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
1840 | video_nr[core->nr]); | 1496 | video_nr[core->nr]); |
1841 | if (err < 0) { | 1497 | if (err < 0) { |
@@ -1848,6 +1504,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, | |||
1848 | 1504 | ||
1849 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); | 1505 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); |
1850 | video_set_drvdata(dev->vbi_dev, dev); | 1506 | video_set_drvdata(dev->vbi_dev, dev); |
1507 | dev->vbi_dev->queue = &dev->vb2_vbiq; | ||
1851 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, | 1508 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
1852 | vbi_nr[core->nr]); | 1509 | vbi_nr[core->nr]); |
1853 | if (err < 0) { | 1510 | if (err < 0) { |
@@ -1875,7 +1532,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, | |||
1875 | } | 1532 | } |
1876 | 1533 | ||
1877 | /* start tvaudio thread */ | 1534 | /* start tvaudio thread */ |
1878 | if (core->board.tuner_type != TUNER_ABSENT) { | 1535 | if (core->board.tuner_type != UNSET) { |
1879 | core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); | 1536 | core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); |
1880 | if (IS_ERR(core->kthread)) { | 1537 | if (IS_ERR(core->kthread)) { |
1881 | err = PTR_ERR(core->kthread); | 1538 | err = PTR_ERR(core->kthread); |
@@ -1892,6 +1549,7 @@ fail_unreg: | |||
1892 | free_irq(pci_dev->irq, dev); | 1549 | free_irq(pci_dev->irq, dev); |
1893 | mutex_unlock(&core->lock); | 1550 | mutex_unlock(&core->lock); |
1894 | fail_core: | 1551 | fail_core: |
1552 | core->v4ldev = NULL; | ||
1895 | cx88_core_put(core,dev->pci); | 1553 | cx88_core_put(core,dev->pci); |
1896 | fail_free: | 1554 | fail_free: |
1897 | kfree(dev); | 1555 | kfree(dev); |
@@ -1913,15 +1571,16 @@ static void cx8800_finidev(struct pci_dev *pci_dev) | |||
1913 | cx88_ir_stop(core); | 1571 | cx88_ir_stop(core); |
1914 | 1572 | ||
1915 | cx88_shutdown(core); /* FIXME */ | 1573 | cx88_shutdown(core); /* FIXME */ |
1916 | pci_disable_device(pci_dev); | ||
1917 | 1574 | ||
1918 | /* unregister stuff */ | 1575 | /* unregister stuff */ |
1919 | 1576 | ||
1920 | free_irq(pci_dev->irq, dev); | 1577 | free_irq(pci_dev->irq, dev); |
1921 | cx8800_unregister_video(dev); | 1578 | cx8800_unregister_video(dev); |
1579 | pci_disable_device(pci_dev); | ||
1580 | |||
1581 | core->v4ldev = NULL; | ||
1922 | 1582 | ||
1923 | /* free memory */ | 1583 | /* free memory */ |
1924 | btcx_riscmem_free(dev->pci,&dev->vidq.stopper); | ||
1925 | cx88_core_put(core,dev->pci); | 1584 | cx88_core_put(core,dev->pci); |
1926 | kfree(dev); | 1585 | kfree(dev); |
1927 | } | 1586 | } |
@@ -1938,12 +1597,10 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) | |||
1938 | if (!list_empty(&dev->vidq.active)) { | 1597 | if (!list_empty(&dev->vidq.active)) { |
1939 | printk("%s/0: suspend video\n", core->name); | 1598 | printk("%s/0: suspend video\n", core->name); |
1940 | stop_video_dma(dev); | 1599 | stop_video_dma(dev); |
1941 | del_timer(&dev->vidq.timeout); | ||
1942 | } | 1600 | } |
1943 | if (!list_empty(&dev->vbiq.active)) { | 1601 | if (!list_empty(&dev->vbiq.active)) { |
1944 | printk("%s/0: suspend vbi\n", core->name); | 1602 | printk("%s/0: suspend vbi\n", core->name); |
1945 | cx8800_stop_vbi_dma(dev); | 1603 | cx8800_stop_vbi_dma(dev); |
1946 | del_timer(&dev->vbiq.timeout); | ||
1947 | } | 1604 | } |
1948 | spin_unlock_irqrestore(&dev->slock, flags); | 1605 | spin_unlock_irqrestore(&dev->slock, flags); |
1949 | 1606 | ||
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h index 28893a6b249e..3b0ae754f165 100644 --- a/drivers/media/pci/cx88/cx88.h +++ b/drivers/media/pci/cx88/cx88.h | |||
@@ -29,19 +29,18 @@ | |||
29 | #include <media/v4l2-fh.h> | 29 | #include <media/v4l2-fh.h> |
30 | #include <media/tuner.h> | 30 | #include <media/tuner.h> |
31 | #include <media/tveeprom.h> | 31 | #include <media/tveeprom.h> |
32 | #include <media/videobuf-dma-sg.h> | 32 | #include <media/videobuf2-dma-sg.h> |
33 | #include <media/cx2341x.h> | 33 | #include <media/cx2341x.h> |
34 | #include <media/videobuf-dvb.h> | 34 | #include <media/videobuf2-dvb.h> |
35 | #include <media/ir-kbd-i2c.h> | 35 | #include <media/ir-kbd-i2c.h> |
36 | #include <media/wm8775.h> | 36 | #include <media/wm8775.h> |
37 | 37 | ||
38 | #include "btcx-risc.h" | ||
39 | #include "cx88-reg.h" | 38 | #include "cx88-reg.h" |
40 | #include "tuner-xc2028.h" | 39 | #include "tuner-xc2028.h" |
41 | 40 | ||
42 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
43 | 42 | ||
44 | #define CX88_VERSION "0.0.9" | 43 | #define CX88_VERSION "1.0.0" |
45 | 44 | ||
46 | #define UNSET (-1U) | 45 | #define UNSET (-1U) |
47 | 46 | ||
@@ -62,7 +61,8 @@ | |||
62 | #define FORMAT_FLAGS_PACKED 0x01 | 61 | #define FORMAT_FLAGS_PACKED 0x01 |
63 | #define FORMAT_FLAGS_PLANAR 0x02 | 62 | #define FORMAT_FLAGS_PLANAR 0x02 |
64 | 63 | ||
65 | #define VBI_LINE_COUNT 17 | 64 | #define VBI_LINE_PAL_COUNT 18 |
65 | #define VBI_LINE_NTSC_COUNT 12 | ||
66 | #define VBI_LINE_LENGTH 2048 | 66 | #define VBI_LINE_LENGTH 2048 |
67 | 67 | ||
68 | #define AUD_RDS_LINES 4 | 68 | #define AUD_RDS_LINES 4 |
@@ -95,13 +95,13 @@ enum cx8802_board_access { | |||
95 | 95 | ||
96 | static inline unsigned int norm_maxw(v4l2_std_id norm) | 96 | static inline unsigned int norm_maxw(v4l2_std_id norm) |
97 | { | 97 | { |
98 | return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768; | 98 | return 720; |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | static inline unsigned int norm_maxh(v4l2_std_id norm) | 102 | static inline unsigned int norm_maxh(v4l2_std_id norm) |
103 | { | 103 | { |
104 | return (norm & V4L2_STD_625_50) ? 576 : 480; | 104 | return (norm & V4L2_STD_525_60) ? 480 : 576; |
105 | } | 105 | } |
106 | 106 | ||
107 | /* ----------------------------------------------------------- */ | 107 | /* ----------------------------------------------------------- */ |
@@ -311,26 +311,33 @@ enum cx88_tvaudio { | |||
311 | 311 | ||
312 | #define BUFFER_TIMEOUT msecs_to_jiffies(2000) | 312 | #define BUFFER_TIMEOUT msecs_to_jiffies(2000) |
313 | 313 | ||
314 | struct cx88_riscmem { | ||
315 | unsigned int size; | ||
316 | __le32 *cpu; | ||
317 | __le32 *jmp; | ||
318 | dma_addr_t dma; | ||
319 | }; | ||
320 | |||
314 | /* buffer for one video frame */ | 321 | /* buffer for one video frame */ |
315 | struct cx88_buffer { | 322 | struct cx88_buffer { |
316 | /* common v4l buffer stuff -- must be first */ | 323 | /* common v4l buffer stuff -- must be first */ |
317 | struct videobuf_buffer vb; | 324 | struct vb2_buffer vb; |
325 | struct list_head list; | ||
318 | 326 | ||
319 | /* cx88 specific */ | 327 | /* cx88 specific */ |
320 | unsigned int bpl; | 328 | unsigned int bpl; |
321 | struct btcx_riscmem risc; | 329 | struct cx88_riscmem risc; |
322 | const struct cx8800_fmt *fmt; | ||
323 | u32 count; | 330 | u32 count; |
324 | }; | 331 | }; |
325 | 332 | ||
326 | struct cx88_dmaqueue { | 333 | struct cx88_dmaqueue { |
327 | struct list_head active; | 334 | struct list_head active; |
328 | struct list_head queued; | ||
329 | struct timer_list timeout; | ||
330 | struct btcx_riscmem stopper; | ||
331 | u32 count; | 335 | u32 count; |
332 | }; | 336 | }; |
333 | 337 | ||
338 | struct cx8800_dev; | ||
339 | struct cx8802_dev; | ||
340 | |||
334 | struct cx88_core { | 341 | struct cx88_core { |
335 | struct list_head devlist; | 342 | struct list_head devlist; |
336 | atomic_t refcount; | 343 | atomic_t refcount; |
@@ -376,6 +383,8 @@ struct cx88_core { | |||
376 | /* state info */ | 383 | /* state info */ |
377 | struct task_struct *kthread; | 384 | struct task_struct *kthread; |
378 | v4l2_std_id tvnorm; | 385 | v4l2_std_id tvnorm; |
386 | unsigned width, height; | ||
387 | unsigned field; | ||
379 | enum cx88_tvaudio tvaudio; | 388 | enum cx88_tvaudio tvaudio; |
380 | u32 audiomode_manual; | 389 | u32 audiomode_manual; |
381 | u32 audiomode_current; | 390 | u32 audiomode_current; |
@@ -395,11 +404,14 @@ struct cx88_core { | |||
395 | struct mutex lock; | 404 | struct mutex lock; |
396 | /* various v4l controls */ | 405 | /* various v4l controls */ |
397 | u32 freq; | 406 | u32 freq; |
398 | int users; | ||
399 | int mpeg_users; | ||
400 | 407 | ||
401 | /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ | 408 | /* |
409 | * cx88-video needs to access cx8802 for hybrid tuner pll access and | ||
410 | * for vb2_is_busy() checks. | ||
411 | */ | ||
402 | struct cx8802_dev *dvbdev; | 412 | struct cx8802_dev *dvbdev; |
413 | /* cx88-blackbird needs to access cx8800 for vb2_is_busy() checks */ | ||
414 | struct cx8800_dev *v4ldev; | ||
403 | enum cx88_board_type active_type_id; | 415 | enum cx88_board_type active_type_id; |
404 | int active_ref; | 416 | int active_ref; |
405 | int active_fe_id; | 417 | int active_fe_id; |
@@ -453,24 +465,9 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) | |||
453 | val; \ | 465 | val; \ |
454 | }) | 466 | }) |
455 | 467 | ||
456 | struct cx8800_dev; | ||
457 | struct cx8802_dev; | ||
458 | |||
459 | /* ----------------------------------------------------------- */ | 468 | /* ----------------------------------------------------------- */ |
460 | /* function 0: video stuff */ | 469 | /* function 0: video stuff */ |
461 | 470 | ||
462 | struct cx8800_fh { | ||
463 | struct v4l2_fh fh; | ||
464 | struct cx8800_dev *dev; | ||
465 | unsigned int resources; | ||
466 | |||
467 | /* video capture */ | ||
468 | struct videobuf_queue vidq; | ||
469 | |||
470 | /* vbi capture */ | ||
471 | struct videobuf_queue vbiq; | ||
472 | }; | ||
473 | |||
474 | struct cx8800_suspend_state { | 471 | struct cx8800_suspend_state { |
475 | int disabled; | 472 | int disabled; |
476 | }; | 473 | }; |
@@ -490,11 +487,12 @@ struct cx8800_dev { | |||
490 | unsigned char pci_rev,pci_lat; | 487 | unsigned char pci_rev,pci_lat; |
491 | 488 | ||
492 | const struct cx8800_fmt *fmt; | 489 | const struct cx8800_fmt *fmt; |
493 | unsigned int width, height; | ||
494 | 490 | ||
495 | /* capture queues */ | 491 | /* capture queues */ |
496 | struct cx88_dmaqueue vidq; | 492 | struct cx88_dmaqueue vidq; |
493 | struct vb2_queue vb2_vidq; | ||
497 | struct cx88_dmaqueue vbiq; | 494 | struct cx88_dmaqueue vbiq; |
495 | struct vb2_queue vb2_vbiq; | ||
498 | 496 | ||
499 | /* various v4l controls */ | 497 | /* various v4l controls */ |
500 | 498 | ||
@@ -510,12 +508,6 @@ struct cx8800_dev { | |||
510 | /* ----------------------------------------------------------- */ | 508 | /* ----------------------------------------------------------- */ |
511 | /* function 2: mpeg stuff */ | 509 | /* function 2: mpeg stuff */ |
512 | 510 | ||
513 | struct cx8802_fh { | ||
514 | struct v4l2_fh fh; | ||
515 | struct cx8802_dev *dev; | ||
516 | struct videobuf_queue mpegq; | ||
517 | }; | ||
518 | |||
519 | struct cx8802_suspend_state { | 511 | struct cx8802_suspend_state { |
520 | int disabled; | 512 | int disabled; |
521 | }; | 513 | }; |
@@ -559,6 +551,7 @@ struct cx8802_dev { | |||
559 | 551 | ||
560 | /* dma queues */ | 552 | /* dma queues */ |
561 | struct cx88_dmaqueue mpegq; | 553 | struct cx88_dmaqueue mpegq; |
554 | struct vb2_queue vb2_mpegq; | ||
562 | u32 ts_packet_size; | 555 | u32 ts_packet_size; |
563 | u32 ts_packet_count; | 556 | u32 ts_packet_count; |
564 | 557 | ||
@@ -570,9 +563,6 @@ struct cx8802_dev { | |||
570 | #if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD) | 563 | #if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD) |
571 | struct video_device *mpeg_dev; | 564 | struct video_device *mpeg_dev; |
572 | u32 mailbox; | 565 | u32 mailbox; |
573 | int width; | ||
574 | int height; | ||
575 | unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ | ||
576 | 566 | ||
577 | /* mpeg params */ | 567 | /* mpeg params */ |
578 | struct cx2341x_handler cxhdl; | 568 | struct cx2341x_handler cxhdl; |
@@ -580,7 +570,7 @@ struct cx8802_dev { | |||
580 | 570 | ||
581 | #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) | 571 | #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) |
582 | /* for dvb only */ | 572 | /* for dvb only */ |
583 | struct videobuf_dvb_frontends frontends; | 573 | struct vb2_dvb_frontends frontends; |
584 | #endif | 574 | #endif |
585 | 575 | ||
586 | #if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) | 576 | #if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) |
@@ -634,22 +624,17 @@ extern void cx88_shutdown(struct cx88_core *core); | |||
634 | extern int cx88_reset(struct cx88_core *core); | 624 | extern int cx88_reset(struct cx88_core *core); |
635 | 625 | ||
636 | extern int | 626 | extern int |
637 | cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | 627 | cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, |
638 | struct scatterlist *sglist, | 628 | struct scatterlist *sglist, |
639 | unsigned int top_offset, unsigned int bottom_offset, | 629 | unsigned int top_offset, unsigned int bottom_offset, |
640 | unsigned int bpl, unsigned int padding, unsigned int lines); | 630 | unsigned int bpl, unsigned int padding, unsigned int lines); |
641 | extern int | 631 | extern int |
642 | cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc, | 632 | cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, |
643 | struct scatterlist *sglist, unsigned int bpl, | 633 | struct scatterlist *sglist, unsigned int bpl, |
644 | unsigned int lines, unsigned int lpi); | 634 | unsigned int lines, unsigned int lpi); |
645 | extern int | ||
646 | cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, | ||
647 | u32 reg, u32 mask, u32 value); | ||
648 | extern void | ||
649 | cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf); | ||
650 | 635 | ||
651 | extern void cx88_risc_disasm(struct cx88_core *core, | 636 | extern void cx88_risc_disasm(struct cx88_core *core, |
652 | struct btcx_riscmem *risc); | 637 | struct cx88_riscmem *risc); |
653 | extern int cx88_sram_channel_setup(struct cx88_core *core, | 638 | extern int cx88_sram_channel_setup(struct cx88_core *core, |
654 | const struct sram_channel *ch, | 639 | const struct sram_channel *ch, |
655 | unsigned int bpl, u32 risc); | 640 | unsigned int bpl, u32 risc); |
@@ -664,7 +649,7 @@ extern struct video_device *cx88_vdev_init(struct cx88_core *core, | |||
664 | struct pci_dev *pci, | 649 | struct pci_dev *pci, |
665 | const struct video_device *template_, | 650 | const struct video_device *template_, |
666 | const char *type); | 651 | const char *type); |
667 | extern struct cx88_core* cx88_core_get(struct pci_dev *pci); | 652 | extern struct cx88_core *cx88_core_get(struct pci_dev *pci); |
668 | extern void cx88_core_put(struct cx88_core *core, | 653 | extern void cx88_core_put(struct cx88_core *core, |
669 | struct pci_dev *pci); | 654 | struct pci_dev *pci); |
670 | 655 | ||
@@ -684,12 +669,10 @@ int cx8800_start_vbi_dma(struct cx8800_dev *dev, | |||
684 | struct cx88_dmaqueue *q, | 669 | struct cx88_dmaqueue *q, |
685 | struct cx88_buffer *buf); | 670 | struct cx88_buffer *buf); |
686 | */ | 671 | */ |
687 | int cx8800_stop_vbi_dma(struct cx8800_dev *dev); | 672 | void cx8800_stop_vbi_dma(struct cx8800_dev *dev); |
688 | int cx8800_restart_vbi_queue(struct cx8800_dev *dev, | 673 | int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q); |
689 | struct cx88_dmaqueue *q); | ||
690 | void cx8800_vbi_timeout(unsigned long data); | ||
691 | 674 | ||
692 | extern const struct videobuf_queue_ops cx8800_vbi_qops; | 675 | extern const struct vb2_ops cx8800_vbi_qops; |
693 | 676 | ||
694 | /* ----------------------------------------------------------- */ | 677 | /* ----------------------------------------------------------- */ |
695 | /* cx88-i2c.c */ | 678 | /* cx88-i2c.c */ |
@@ -739,14 +722,17 @@ extern void cx88_i2c_init_ir(struct cx88_core *core); | |||
739 | /* ----------------------------------------------------------- */ | 722 | /* ----------------------------------------------------------- */ |
740 | /* cx88-mpeg.c */ | 723 | /* cx88-mpeg.c */ |
741 | 724 | ||
742 | int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev, | 725 | int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, |
743 | struct cx88_buffer *buf, enum v4l2_field field); | 726 | struct cx88_buffer *buf); |
744 | void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); | 727 | void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); |
745 | void cx8802_cancel_buffers(struct cx8802_dev *dev); | 728 | void cx8802_cancel_buffers(struct cx8802_dev *dev); |
729 | int cx8802_start_dma(struct cx8802_dev *dev, | ||
730 | struct cx88_dmaqueue *q, | ||
731 | struct cx88_buffer *buf); | ||
746 | 732 | ||
747 | /* ----------------------------------------------------------- */ | 733 | /* ----------------------------------------------------------- */ |
748 | /* cx88-video.c*/ | 734 | /* cx88-video.c*/ |
749 | int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); | 735 | int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i); |
750 | int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); | 736 | int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); |
751 | int cx88_video_mux(struct cx88_core *core, unsigned int input); | 737 | int cx88_video_mux(struct cx88_core *core, unsigned int input); |
752 | void cx88_querycap(struct file *file, struct cx88_core *core, | 738 | void cx88_querycap(struct file *file, struct cx88_core *core, |
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index c82e855a0814..9e3492e20766 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c | |||
@@ -1118,8 +1118,7 @@ static void ddb_ports_detach(struct ddb *dev) | |||
1118 | dvb_input_detach(port->input[1]); | 1118 | dvb_input_detach(port->input[1]); |
1119 | break; | 1119 | break; |
1120 | case DDB_PORT_CI: | 1120 | case DDB_PORT_CI: |
1121 | if (port->output->dev) | 1121 | dvb_unregister_device(port->output->dev); |
1122 | dvb_unregister_device(port->output->dev); | ||
1123 | if (port->en) { | 1122 | if (port->en) { |
1124 | ddb_input_stop(port->input[0]); | 1123 | ddb_input_stop(port->input[0]); |
1125 | ddb_output_stop(port->output); | 1124 | ddb_output_stop(port->output); |
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c b/drivers/media/pci/ivtv/ivtv-controls.c index 2b0ab26e11e8..ccf548c255f1 100644 --- a/drivers/media/pci/ivtv/ivtv-controls.c +++ b/drivers/media/pci/ivtv/ivtv-controls.c | |||
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val) | |||
69 | /* fix videodecoder resolution */ | 69 | /* fix videodecoder resolution */ |
70 | fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); | 70 | fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); |
71 | fmt.height = cxhdl->height; | 71 | fmt.height = cxhdl->height; |
72 | fmt.code = V4L2_MBUS_FMT_FIXED; | 72 | fmt.code = MEDIA_BUS_FMT_FIXED; |
73 | v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &fmt); | 73 | v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &fmt); |
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 3e0cb77d5930..4d8ee18c3feb 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c | |||
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f | |||
595 | fmt->fmt.pix.width /= 2; | 595 | fmt->fmt.pix.width /= 2; |
596 | mbus_fmt.width = fmt->fmt.pix.width; | 596 | mbus_fmt.width = fmt->fmt.pix.width; |
597 | mbus_fmt.height = h; | 597 | mbus_fmt.height = h; |
598 | mbus_fmt.code = V4L2_MBUS_FMT_FIXED; | 598 | mbus_fmt.code = MEDIA_BUS_FMT_FIXED; |
599 | v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &mbus_fmt); | 599 | v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &mbus_fmt); |
600 | return ivtv_g_fmt_vid_cap(file, fh, fmt); | 600 | return ivtv_g_fmt_vid_cap(file, fh, fmt); |
601 | } | 601 | } |
diff --git a/drivers/media/pci/ivtv/ivtv-udma.c b/drivers/media/pci/ivtv/ivtv-udma.c index 7338cb2d0a38..bee2329e0b2e 100644 --- a/drivers/media/pci/ivtv/ivtv-udma.c +++ b/drivers/media/pci/ivtv/ivtv-udma.c | |||
@@ -76,7 +76,7 @@ void ivtv_udma_fill_sg_array (struct ivtv_user_dma *dma, u32 buffer_offset, u32 | |||
76 | int i; | 76 | int i; |
77 | struct scatterlist *sg; | 77 | struct scatterlist *sg; |
78 | 78 | ||
79 | for (i = 0, sg = dma->SGlist; i < dma->SG_length; i++, sg++) { | 79 | for (i = 0, sg = dma->SGlist; i < dma->SG_length; i++, sg = sg_next(sg)) { |
80 | dma->SGarray[i].size = cpu_to_le32(sg_dma_len(sg)); | 80 | dma->SGarray[i].size = cpu_to_le32(sg_dma_len(sg)); |
81 | dma->SGarray[i].src = cpu_to_le32(sg_dma_address(sg)); | 81 | dma->SGarray[i].src = cpu_to_le32(sg_dma_address(sg)); |
82 | dma->SGarray[i].dst = cpu_to_le32(buffer_offset); | 82 | dma->SGarray[i].dst = cpu_to_le32(buffer_offset); |
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c index aeae54708811..9d9f90cb7740 100644 --- a/drivers/media/pci/meye/meye.c +++ b/drivers/media/pci/meye/meye.c | |||
@@ -1031,9 +1031,6 @@ static int vidioc_querycap(struct file *file, void *fh, | |||
1031 | strcpy(cap->card, "meye"); | 1031 | strcpy(cap->card, "meye"); |
1032 | sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev)); | 1032 | sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev)); |
1033 | 1033 | ||
1034 | cap->version = (MEYE_DRIVER_MAJORVERSION << 8) + | ||
1035 | MEYE_DRIVER_MINORVERSION; | ||
1036 | |||
1037 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | | 1034 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | |
1038 | V4L2_CAP_STREAMING; | 1035 | V4L2_CAP_STREAMING; |
1039 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | 1036 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index db887b0c37b1..acc35b42e53c 100644 --- a/drivers/media/pci/pt1/pt1.c +++ b/drivers/media/pci/pt1/pt1.c | |||
@@ -109,9 +109,6 @@ struct pt1_adapter { | |||
109 | int sleep; | 109 | int sleep; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | #define pt1_printk(level, pt1, format, arg...) \ | ||
113 | dev_printk(level, &(pt1)->pdev->dev, format, ##arg) | ||
114 | |||
115 | static void pt1_write_reg(struct pt1 *pt1, int reg, u32 data) | 112 | static void pt1_write_reg(struct pt1 *pt1, int reg, u32 data) |
116 | { | 113 | { |
117 | writel(data, pt1->regs + reg * 4); | 114 | writel(data, pt1->regs + reg * 4); |
@@ -154,7 +151,7 @@ static int pt1_sync(struct pt1 *pt1) | |||
154 | return 0; | 151 | return 0; |
155 | pt1_write_reg(pt1, 0, 0x00000008); | 152 | pt1_write_reg(pt1, 0, 0x00000008); |
156 | } | 153 | } |
157 | pt1_printk(KERN_ERR, pt1, "could not sync\n"); | 154 | dev_err(&pt1->pdev->dev, "could not sync\n"); |
158 | return -EIO; | 155 | return -EIO; |
159 | } | 156 | } |
160 | 157 | ||
@@ -179,7 +176,7 @@ static int pt1_unlock(struct pt1 *pt1) | |||
179 | return 0; | 176 | return 0; |
180 | schedule_timeout_uninterruptible((HZ + 999) / 1000); | 177 | schedule_timeout_uninterruptible((HZ + 999) / 1000); |
181 | } | 178 | } |
182 | pt1_printk(KERN_ERR, pt1, "could not unlock\n"); | 179 | dev_err(&pt1->pdev->dev, "could not unlock\n"); |
183 | return -EIO; | 180 | return -EIO; |
184 | } | 181 | } |
185 | 182 | ||
@@ -193,7 +190,7 @@ static int pt1_reset_pci(struct pt1 *pt1) | |||
193 | return 0; | 190 | return 0; |
194 | schedule_timeout_uninterruptible((HZ + 999) / 1000); | 191 | schedule_timeout_uninterruptible((HZ + 999) / 1000); |
195 | } | 192 | } |
196 | pt1_printk(KERN_ERR, pt1, "could not reset PCI\n"); | 193 | dev_err(&pt1->pdev->dev, "could not reset PCI\n"); |
197 | return -EIO; | 194 | return -EIO; |
198 | } | 195 | } |
199 | 196 | ||
@@ -207,7 +204,7 @@ static int pt1_reset_ram(struct pt1 *pt1) | |||
207 | return 0; | 204 | return 0; |
208 | schedule_timeout_uninterruptible((HZ + 999) / 1000); | 205 | schedule_timeout_uninterruptible((HZ + 999) / 1000); |
209 | } | 206 | } |
210 | pt1_printk(KERN_ERR, pt1, "could not reset RAM\n"); | 207 | dev_err(&pt1->pdev->dev, "could not reset RAM\n"); |
211 | return -EIO; | 208 | return -EIO; |
212 | } | 209 | } |
213 | 210 | ||
@@ -224,7 +221,7 @@ static int pt1_do_enable_ram(struct pt1 *pt1) | |||
224 | } | 221 | } |
225 | schedule_timeout_uninterruptible((HZ + 999) / 1000); | 222 | schedule_timeout_uninterruptible((HZ + 999) / 1000); |
226 | } | 223 | } |
227 | pt1_printk(KERN_ERR, pt1, "could not enable RAM\n"); | 224 | dev_err(&pt1->pdev->dev, "could not enable RAM\n"); |
228 | return -EIO; | 225 | return -EIO; |
229 | } | 226 | } |
230 | 227 | ||
diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c index 1fdeac11501a..7a37e8fe2ee2 100644 --- a/drivers/media/pci/pt3/pt3.c +++ b/drivers/media/pci/pt3/pt3.c | |||
@@ -255,7 +255,7 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
255 | pt3_i2c_reset(pt3); | 255 | pt3_i2c_reset(pt3); |
256 | ret = pt3_init_all_demods(pt3); | 256 | ret = pt3_init_all_demods(pt3); |
257 | if (ret < 0) { | 257 | if (ret < 0) { |
258 | dev_warn(&pt3->pdev->dev, "Failed to init demod chips."); | 258 | dev_warn(&pt3->pdev->dev, "Failed to init demod chips\n"); |
259 | return ret; | 259 | return ret; |
260 | } | 260 | } |
261 | 261 | ||
@@ -271,7 +271,7 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
271 | init0_ter, ARRAY_SIZE(init0_ter)); | 271 | init0_ter, ARRAY_SIZE(init0_ter)); |
272 | if (ret < 0) { | 272 | if (ret < 0) { |
273 | dev_warn(&pt3->pdev->dev, | 273 | dev_warn(&pt3->pdev->dev, |
274 | "demod[%d] faild in init sequence0.", i); | 274 | "demod[%d] failed in init sequence0\n", i); |
275 | return ret; | 275 | return ret; |
276 | } | 276 | } |
277 | ret = fe->ops.init(fe); | 277 | ret = fe->ops.init(fe); |
@@ -282,7 +282,7 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
282 | usleep_range(2000, 4000); | 282 | usleep_range(2000, 4000); |
283 | ret = pt3_set_tuner_power(pt3, true, false); | 283 | ret = pt3_set_tuner_power(pt3, true, false); |
284 | if (ret < 0) { | 284 | if (ret < 0) { |
285 | dev_warn(&pt3->pdev->dev, "Failed to control tuner module."); | 285 | dev_warn(&pt3->pdev->dev, "Failed to control tuner module\n"); |
286 | return ret; | 286 | return ret; |
287 | } | 287 | } |
288 | 288 | ||
@@ -297,7 +297,7 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
297 | cfg_ter, ARRAY_SIZE(cfg_ter)); | 297 | cfg_ter, ARRAY_SIZE(cfg_ter)); |
298 | if (ret < 0) { | 298 | if (ret < 0) { |
299 | dev_warn(&pt3->pdev->dev, | 299 | dev_warn(&pt3->pdev->dev, |
300 | "demod[%d] faild in init sequence1.", i); | 300 | "demod[%d] failed in init sequence1\n", i); |
301 | return ret; | 301 | return ret; |
302 | } | 302 | } |
303 | } | 303 | } |
@@ -311,19 +311,19 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
311 | ret = fe->ops.tuner_ops.init(fe); | 311 | ret = fe->ops.tuner_ops.init(fe); |
312 | if (ret < 0) { | 312 | if (ret < 0) { |
313 | dev_warn(&pt3->pdev->dev, | 313 | dev_warn(&pt3->pdev->dev, |
314 | "Failed to init SAT-tuner[%d].", i); | 314 | "Failed to init SAT-tuner[%d]\n", i); |
315 | return ret; | 315 | return ret; |
316 | } | 316 | } |
317 | } | 317 | } |
318 | ret = pt3_init_all_mxl301rf(pt3); | 318 | ret = pt3_init_all_mxl301rf(pt3); |
319 | if (ret < 0) { | 319 | if (ret < 0) { |
320 | dev_warn(&pt3->pdev->dev, "Failed to init TERR-tuners."); | 320 | dev_warn(&pt3->pdev->dev, "Failed to init TERR-tuners\n"); |
321 | return ret; | 321 | return ret; |
322 | } | 322 | } |
323 | 323 | ||
324 | ret = pt3_set_tuner_power(pt3, true, true); | 324 | ret = pt3_set_tuner_power(pt3, true, true); |
325 | if (ret < 0) { | 325 | if (ret < 0) { |
326 | dev_warn(&pt3->pdev->dev, "Failed to control tuner module."); | 326 | dev_warn(&pt3->pdev->dev, "Failed to control tuner module\n"); |
327 | return ret; | 327 | return ret; |
328 | } | 328 | } |
329 | 329 | ||
@@ -344,7 +344,7 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
344 | } | 344 | } |
345 | if (ret < 0) { | 345 | if (ret < 0) { |
346 | dev_warn(&pt3->pdev->dev, | 346 | dev_warn(&pt3->pdev->dev, |
347 | "Failed in initial tuning of tuner[%d].", i); | 347 | "Failed in initial tuning of tuner[%d]\n", i); |
348 | return ret; | 348 | return ret; |
349 | } | 349 | } |
350 | } | 350 | } |
@@ -366,7 +366,7 @@ static int pt3_fe_init(struct pt3_board *pt3) | |||
366 | fe->ops.set_lna = &pt3_set_lna; | 366 | fe->ops.set_lna = &pt3_set_lna; |
367 | } | 367 | } |
368 | if (i < PT3_NUM_FE) { | 368 | if (i < PT3_NUM_FE) { |
369 | dev_warn(&pt3->pdev->dev, "FE[%d] failed to standby.", i); | 369 | dev_warn(&pt3->pdev->dev, "FE[%d] failed to standby\n", i); |
370 | return ret; | 370 | return ret; |
371 | } | 371 | } |
372 | return 0; | 372 | return 0; |
@@ -453,8 +453,8 @@ static int pt3_fetch_thread(void *data) | |||
453 | pt3_init_dmabuf(adap); | 453 | pt3_init_dmabuf(adap); |
454 | adap->num_discard = PT3_INITIAL_BUF_DROPS; | 454 | adap->num_discard = PT3_INITIAL_BUF_DROPS; |
455 | 455 | ||
456 | dev_dbg(adap->dvb_adap.device, | 456 | dev_dbg(adap->dvb_adap.device, "PT3: [%s] started\n", |
457 | "PT3: [%s] started.\n", adap->thread->comm); | 457 | adap->thread->comm); |
458 | set_freezable(); | 458 | set_freezable(); |
459 | while (!kthread_freezable_should_stop(&was_frozen)) { | 459 | while (!kthread_freezable_should_stop(&was_frozen)) { |
460 | if (was_frozen) | 460 | if (was_frozen) |
@@ -468,8 +468,8 @@ static int pt3_fetch_thread(void *data) | |||
468 | PT3_FETCH_DELAY_DELTA * NSEC_PER_MSEC, | 468 | PT3_FETCH_DELAY_DELTA * NSEC_PER_MSEC, |
469 | HRTIMER_MODE_REL); | 469 | HRTIMER_MODE_REL); |
470 | } | 470 | } |
471 | dev_dbg(adap->dvb_adap.device, | 471 | dev_dbg(adap->dvb_adap.device, "PT3: [%s] exited\n", |
472 | "PT3: [%s] exited.\n", adap->thread->comm); | 472 | adap->thread->comm); |
473 | adap->thread = NULL; | 473 | adap->thread = NULL; |
474 | return 0; | 474 | return 0; |
475 | } | 475 | } |
@@ -485,8 +485,8 @@ static int pt3_start_streaming(struct pt3_adapter *adap) | |||
485 | int ret = PTR_ERR(thread); | 485 | int ret = PTR_ERR(thread); |
486 | 486 | ||
487 | dev_warn(adap->dvb_adap.device, | 487 | dev_warn(adap->dvb_adap.device, |
488 | "PT3 (adap:%d, dmx:%d): failed to start kthread.\n", | 488 | "PT3 (adap:%d, dmx:%d): failed to start kthread\n", |
489 | adap->dvb_adap.num, adap->dmxdev.dvbdev->id); | 489 | adap->dvb_adap.num, adap->dmxdev.dvbdev->id); |
490 | return ret; | 490 | return ret; |
491 | } | 491 | } |
492 | adap->thread = thread; | 492 | adap->thread = thread; |
@@ -501,8 +501,8 @@ static int pt3_stop_streaming(struct pt3_adapter *adap) | |||
501 | ret = pt3_stop_dma(adap); | 501 | ret = pt3_stop_dma(adap); |
502 | if (ret) | 502 | if (ret) |
503 | dev_warn(adap->dvb_adap.device, | 503 | dev_warn(adap->dvb_adap.device, |
504 | "PT3: failed to stop streaming of adap:%d/FE:%d\n", | 504 | "PT3: failed to stop streaming of adap:%d/FE:%d\n", |
505 | adap->dvb_adap.num, adap->fe->id); | 505 | adap->dvb_adap.num, adap->fe->id); |
506 | 506 | ||
507 | /* kill the fetching thread */ | 507 | /* kill the fetching thread */ |
508 | ret = kthread_stop(adap->thread); | 508 | ret = kthread_stop(adap->thread); |
@@ -522,8 +522,8 @@ static int pt3_start_feed(struct dvb_demux_feed *feed) | |||
522 | return 0; | 522 | return 0; |
523 | if (adap->num_feeds != 1) { | 523 | if (adap->num_feeds != 1) { |
524 | dev_warn(adap->dvb_adap.device, | 524 | dev_warn(adap->dvb_adap.device, |
525 | "%s: unmatched start/stop_feed in adap:%i/dmx:%i.\n", | 525 | "%s: unmatched start/stop_feed in adap:%i/dmx:%i\n", |
526 | __func__, adap->dvb_adap.num, adap->dmxdev.dvbdev->id); | 526 | __func__, adap->dvb_adap.num, adap->dmxdev.dvbdev->id); |
527 | adap->num_feeds = 1; | 527 | adap->num_feeds = 1; |
528 | } | 528 | } |
529 | 529 | ||
@@ -553,10 +553,9 @@ static int pt3_alloc_adapter(struct pt3_board *pt3, int index) | |||
553 | struct dvb_adapter *da; | 553 | struct dvb_adapter *da; |
554 | 554 | ||
555 | adap = kzalloc(sizeof(*adap), GFP_KERNEL); | 555 | adap = kzalloc(sizeof(*adap), GFP_KERNEL); |
556 | if (!adap) { | 556 | if (!adap) |
557 | dev_err(&pt3->pdev->dev, "failed to alloc mem for adapter.\n"); | ||
558 | return -ENOMEM; | 557 | return -ENOMEM; |
559 | } | 558 | |
560 | pt3->adaps[index] = adap; | 559 | pt3->adaps[index] = adap; |
561 | adap->adap_idx = index; | 560 | adap->adap_idx = index; |
562 | 561 | ||
@@ -565,7 +564,7 @@ static int pt3_alloc_adapter(struct pt3_board *pt3, int index) | |||
565 | THIS_MODULE, &pt3->pdev->dev, adapter_nr); | 564 | THIS_MODULE, &pt3->pdev->dev, adapter_nr); |
566 | if (ret < 0) { | 565 | if (ret < 0) { |
567 | dev_err(&pt3->pdev->dev, | 566 | dev_err(&pt3->pdev->dev, |
568 | "failed to register adapter dev.\n"); | 567 | "failed to register adapter dev\n"); |
569 | goto err_mem; | 568 | goto err_mem; |
570 | } | 569 | } |
571 | da = &adap->dvb_adap; | 570 | da = &adap->dvb_adap; |
@@ -581,7 +580,7 @@ static int pt3_alloc_adapter(struct pt3_board *pt3, int index) | |||
581 | adap->demux.stop_feed = pt3_stop_feed; | 580 | adap->demux.stop_feed = pt3_stop_feed; |
582 | ret = dvb_dmx_init(&adap->demux); | 581 | ret = dvb_dmx_init(&adap->demux); |
583 | if (ret < 0) { | 582 | if (ret < 0) { |
584 | dev_err(&pt3->pdev->dev, "failed to init dmx dev.\n"); | 583 | dev_err(&pt3->pdev->dev, "failed to init dmx dev\n"); |
585 | goto err_adap; | 584 | goto err_adap; |
586 | } | 585 | } |
587 | 586 | ||
@@ -589,13 +588,13 @@ static int pt3_alloc_adapter(struct pt3_board *pt3, int index) | |||
589 | adap->dmxdev.demux = &adap->demux.dmx; | 588 | adap->dmxdev.demux = &adap->demux.dmx; |
590 | ret = dvb_dmxdev_init(&adap->dmxdev, da); | 589 | ret = dvb_dmxdev_init(&adap->dmxdev, da); |
591 | if (ret < 0) { | 590 | if (ret < 0) { |
592 | dev_err(&pt3->pdev->dev, "failed to init dmxdev.\n"); | 591 | dev_err(&pt3->pdev->dev, "failed to init dmxdev\n"); |
593 | goto err_demux; | 592 | goto err_demux; |
594 | } | 593 | } |
595 | 594 | ||
596 | ret = pt3_alloc_dmabuf(adap); | 595 | ret = pt3_alloc_dmabuf(adap); |
597 | if (ret) { | 596 | if (ret) { |
598 | dev_err(&pt3->pdev->dev, "failed to alloc DMA buffers.\n"); | 597 | dev_err(&pt3->pdev->dev, "failed to alloc DMA buffers\n"); |
599 | goto err_dmabuf; | 598 | goto err_dmabuf; |
600 | } | 599 | } |
601 | 600 | ||
@@ -695,7 +694,7 @@ static int pt3_resume(struct device *dev) | |||
695 | dvb_frontend_resume(adap->fe); | 694 | dvb_frontend_resume(adap->fe); |
696 | ret = pt3_alloc_dmabuf(adap); | 695 | ret = pt3_alloc_dmabuf(adap); |
697 | if (ret) { | 696 | if (ret) { |
698 | dev_err(&pt3->pdev->dev, "failed to alloc DMA bufs.\n"); | 697 | dev_err(&pt3->pdev->dev, "failed to alloc DMA bufs\n"); |
699 | continue; | 698 | continue; |
700 | } | 699 | } |
701 | if (adap->num_feeds > 0) | 700 | if (adap->num_feeds > 0) |
@@ -753,15 +752,14 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
753 | if (ret == 0) | 752 | if (ret == 0) |
754 | dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); | 753 | dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); |
755 | else { | 754 | else { |
756 | dev_err(&pdev->dev, "Failed to set DMA mask.\n"); | 755 | dev_err(&pdev->dev, "Failed to set DMA mask\n"); |
757 | goto err_release_regions; | 756 | goto err_release_regions; |
758 | } | 757 | } |
759 | dev_info(&pdev->dev, "Use 32bit DMA.\n"); | 758 | dev_info(&pdev->dev, "Use 32bit DMA\n"); |
760 | } | 759 | } |
761 | 760 | ||
762 | pt3 = kzalloc(sizeof(*pt3), GFP_KERNEL); | 761 | pt3 = kzalloc(sizeof(*pt3), GFP_KERNEL); |
763 | if (!pt3) { | 762 | if (!pt3) { |
764 | dev_err(&pdev->dev, "Failed to alloc mem for this dev.\n"); | ||
765 | ret = -ENOMEM; | 763 | ret = -ENOMEM; |
766 | goto err_release_regions; | 764 | goto err_release_regions; |
767 | } | 765 | } |
@@ -771,15 +769,15 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
771 | pt3->regs[0] = pci_ioremap_bar(pdev, 0); | 769 | pt3->regs[0] = pci_ioremap_bar(pdev, 0); |
772 | pt3->regs[1] = pci_ioremap_bar(pdev, 2); | 770 | pt3->regs[1] = pci_ioremap_bar(pdev, 2); |
773 | if (pt3->regs[0] == NULL || pt3->regs[1] == NULL) { | 771 | if (pt3->regs[0] == NULL || pt3->regs[1] == NULL) { |
774 | dev_err(&pdev->dev, "Failed to ioremap.\n"); | 772 | dev_err(&pdev->dev, "Failed to ioremap\n"); |
775 | ret = -ENOMEM; | 773 | ret = -ENOMEM; |
776 | goto err_kfree; | 774 | goto err_kfree; |
777 | } | 775 | } |
778 | 776 | ||
779 | ver = ioread32(pt3->regs[0] + REG_VERSION); | 777 | ver = ioread32(pt3->regs[0] + REG_VERSION); |
780 | if ((ver >> 16) != 0x0301) { | 778 | if ((ver >> 16) != 0x0301) { |
781 | dev_warn(&pdev->dev, "PT%d, I/F-ver.:%d not supported", | 779 | dev_warn(&pdev->dev, "PT%d, I/F-ver.:%d not supported\n", |
782 | ver >> 24, (ver & 0x00ff0000) >> 16); | 780 | ver >> 24, (ver & 0x00ff0000) >> 16); |
783 | ret = -ENODEV; | 781 | ret = -ENODEV; |
784 | goto err_iounmap; | 782 | goto err_iounmap; |
785 | } | 783 | } |
@@ -788,7 +786,6 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
788 | 786 | ||
789 | pt3->i2c_buf = kmalloc(sizeof(*pt3->i2c_buf), GFP_KERNEL); | 787 | pt3->i2c_buf = kmalloc(sizeof(*pt3->i2c_buf), GFP_KERNEL); |
790 | if (pt3->i2c_buf == NULL) { | 788 | if (pt3->i2c_buf == NULL) { |
791 | dev_err(&pdev->dev, "Failed to alloc mem for i2c.\n"); | ||
792 | ret = -ENOMEM; | 789 | ret = -ENOMEM; |
793 | goto err_iounmap; | 790 | goto err_iounmap; |
794 | } | 791 | } |
@@ -801,7 +798,7 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
801 | i2c_set_adapdata(i2c, pt3); | 798 | i2c_set_adapdata(i2c, pt3); |
802 | ret = i2c_add_adapter(i2c); | 799 | ret = i2c_add_adapter(i2c); |
803 | if (ret < 0) { | 800 | if (ret < 0) { |
804 | dev_err(&pdev->dev, "Failed to add i2c adapter.\n"); | 801 | dev_err(&pdev->dev, "Failed to add i2c adapter\n"); |
805 | goto err_i2cbuf; | 802 | goto err_i2cbuf; |
806 | } | 803 | } |
807 | 804 | ||
@@ -815,20 +812,20 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
815 | break; | 812 | break; |
816 | } | 813 | } |
817 | if (i < PT3_NUM_FE) { | 814 | if (i < PT3_NUM_FE) { |
818 | dev_err(&pdev->dev, "Failed to create FE%d.\n", i); | 815 | dev_err(&pdev->dev, "Failed to create FE%d\n", i); |
819 | goto err_cleanup_adapters; | 816 | goto err_cleanup_adapters; |
820 | } | 817 | } |
821 | 818 | ||
822 | ret = pt3_fe_init(pt3); | 819 | ret = pt3_fe_init(pt3); |
823 | if (ret < 0) { | 820 | if (ret < 0) { |
824 | dev_err(&pdev->dev, "Failed to init frontends.\n"); | 821 | dev_err(&pdev->dev, "Failed to init frontends\n"); |
825 | i = PT3_NUM_FE - 1; | 822 | i = PT3_NUM_FE - 1; |
826 | goto err_cleanup_adapters; | 823 | goto err_cleanup_adapters; |
827 | } | 824 | } |
828 | 825 | ||
829 | dev_info(&pdev->dev, | 826 | dev_info(&pdev->dev, |
830 | "successfully init'ed PT%d (fw:0x%02x, I/F:0x%02x).\n", | 827 | "successfully init'ed PT%d (fw:0x%02x, I/F:0x%02x)\n", |
831 | ver >> 24, (ver >> 8) & 0xff, (ver >> 16) & 0xff); | 828 | ver >> 24, (ver >> 8) & 0xff, (ver >> 16) & 0xff); |
832 | return 0; | 829 | return 0; |
833 | 830 | ||
834 | err_cleanup_adapters: | 831 | err_cleanup_adapters: |
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index 236ed725f933..a349e964e0bc 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c | |||
@@ -1001,13 +1001,18 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1001 | saa7134_board_init1(dev); | 1001 | saa7134_board_init1(dev); |
1002 | saa7134_hwinit1(dev); | 1002 | saa7134_hwinit1(dev); |
1003 | 1003 | ||
1004 | dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev); | ||
1005 | if (IS_ERR(dev->alloc_ctx)) { | ||
1006 | err = PTR_ERR(dev->alloc_ctx); | ||
1007 | goto fail3; | ||
1008 | } | ||
1004 | /* get irq */ | 1009 | /* get irq */ |
1005 | err = request_irq(pci_dev->irq, saa7134_irq, | 1010 | err = request_irq(pci_dev->irq, saa7134_irq, |
1006 | IRQF_SHARED, dev->name, dev); | 1011 | IRQF_SHARED, dev->name, dev); |
1007 | if (err < 0) { | 1012 | if (err < 0) { |
1008 | printk(KERN_ERR "%s: can't get IRQ %d\n", | 1013 | printk(KERN_ERR "%s: can't get IRQ %d\n", |
1009 | dev->name,pci_dev->irq); | 1014 | dev->name,pci_dev->irq); |
1010 | goto fail3; | 1015 | goto fail4; |
1011 | } | 1016 | } |
1012 | 1017 | ||
1013 | /* wait a bit, register i2c bus */ | 1018 | /* wait a bit, register i2c bus */ |
@@ -1065,7 +1070,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1065 | if (err < 0) { | 1070 | if (err < 0) { |
1066 | printk(KERN_INFO "%s: can't register video device\n", | 1071 | printk(KERN_INFO "%s: can't register video device\n", |
1067 | dev->name); | 1072 | dev->name); |
1068 | goto fail4; | 1073 | goto fail5; |
1069 | } | 1074 | } |
1070 | printk(KERN_INFO "%s: registered device %s [v4l2]\n", | 1075 | printk(KERN_INFO "%s: registered device %s [v4l2]\n", |
1071 | dev->name, video_device_node_name(dev->video_dev)); | 1076 | dev->name, video_device_node_name(dev->video_dev)); |
@@ -1078,7 +1083,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1078 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, | 1083 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
1079 | vbi_nr[dev->nr]); | 1084 | vbi_nr[dev->nr]); |
1080 | if (err < 0) | 1085 | if (err < 0) |
1081 | goto fail4; | 1086 | goto fail5; |
1082 | printk(KERN_INFO "%s: registered device %s\n", | 1087 | printk(KERN_INFO "%s: registered device %s\n", |
1083 | dev->name, video_device_node_name(dev->vbi_dev)); | 1088 | dev->name, video_device_node_name(dev->vbi_dev)); |
1084 | 1089 | ||
@@ -1089,7 +1094,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1089 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, | 1094 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
1090 | radio_nr[dev->nr]); | 1095 | radio_nr[dev->nr]); |
1091 | if (err < 0) | 1096 | if (err < 0) |
1092 | goto fail4; | 1097 | goto fail5; |
1093 | printk(KERN_INFO "%s: registered device %s\n", | 1098 | printk(KERN_INFO "%s: registered device %s\n", |
1094 | dev->name, video_device_node_name(dev->radio_dev)); | 1099 | dev->name, video_device_node_name(dev->radio_dev)); |
1095 | } | 1100 | } |
@@ -1103,10 +1108,12 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1103 | request_submodules(dev); | 1108 | request_submodules(dev); |
1104 | return 0; | 1109 | return 0; |
1105 | 1110 | ||
1106 | fail4: | 1111 | fail5: |
1107 | saa7134_unregister_video(dev); | 1112 | saa7134_unregister_video(dev); |
1108 | saa7134_i2c_unregister(dev); | 1113 | saa7134_i2c_unregister(dev); |
1109 | free_irq(pci_dev->irq, dev); | 1114 | free_irq(pci_dev->irq, dev); |
1115 | fail4: | ||
1116 | vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); | ||
1110 | fail3: | 1117 | fail3: |
1111 | saa7134_hwfini(dev); | 1118 | saa7134_hwfini(dev); |
1112 | iounmap(dev->lmmio); | 1119 | iounmap(dev->lmmio); |
@@ -1173,6 +1180,7 @@ static void saa7134_finidev(struct pci_dev *pci_dev) | |||
1173 | 1180 | ||
1174 | /* release resources */ | 1181 | /* release resources */ |
1175 | free_irq(pci_dev->irq, dev); | 1182 | free_irq(pci_dev->irq, dev); |
1183 | vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); | ||
1176 | iounmap(dev->lmmio); | 1184 | iounmap(dev->lmmio); |
1177 | release_mem_region(pci_resource_start(pci_dev,0), | 1185 | release_mem_region(pci_resource_start(pci_dev,0), |
1178 | pci_resource_len(pci_dev,0)); | 1186 | pci_resource_len(pci_dev,0)); |
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index e4ea85fd1b23..594dc3ad4750 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c | |||
@@ -96,7 +96,6 @@ static struct vb2_ops saa7134_empress_qops = { | |||
96 | .queue_setup = saa7134_ts_queue_setup, | 96 | .queue_setup = saa7134_ts_queue_setup, |
97 | .buf_init = saa7134_ts_buffer_init, | 97 | .buf_init = saa7134_ts_buffer_init, |
98 | .buf_prepare = saa7134_ts_buffer_prepare, | 98 | .buf_prepare = saa7134_ts_buffer_prepare, |
99 | .buf_finish = saa7134_ts_buffer_finish, | ||
100 | .buf_queue = saa7134_vb2_buffer_queue, | 99 | .buf_queue = saa7134_vb2_buffer_queue, |
101 | .wait_prepare = vb2_ops_wait_prepare, | 100 | .wait_prepare = vb2_ops_wait_prepare, |
102 | .wait_finish = vb2_ops_wait_finish, | 101 | .wait_finish = vb2_ops_wait_finish, |
@@ -140,7 +139,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv, | |||
140 | struct saa7134_dev *dev = video_drvdata(file); | 139 | struct saa7134_dev *dev = video_drvdata(file); |
141 | struct v4l2_mbus_framefmt mbus_fmt; | 140 | struct v4l2_mbus_framefmt mbus_fmt; |
142 | 141 | ||
143 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); | 142 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); |
144 | saa_call_all(dev, video, s_mbus_fmt, &mbus_fmt); | 143 | saa_call_all(dev, video, s_mbus_fmt, &mbus_fmt); |
145 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); | 144 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); |
146 | 145 | ||
@@ -157,7 +156,7 @@ static int empress_try_fmt_vid_cap(struct file *file, void *priv, | |||
157 | struct saa7134_dev *dev = video_drvdata(file); | 156 | struct saa7134_dev *dev = video_drvdata(file); |
158 | struct v4l2_mbus_framefmt mbus_fmt; | 157 | struct v4l2_mbus_framefmt mbus_fmt; |
159 | 158 | ||
160 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); | 159 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); |
161 | saa_call_all(dev, video, try_mbus_fmt, &mbus_fmt); | 160 | saa_call_all(dev, video, try_mbus_fmt, &mbus_fmt); |
162 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); | 161 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); |
163 | 162 | ||
diff --git a/drivers/media/pci/saa7134/saa7134-ts.c b/drivers/media/pci/saa7134/saa7134-ts.c index bd25323bd947..2709b83d57b1 100644 --- a/drivers/media/pci/saa7134/saa7134-ts.c +++ b/drivers/media/pci/saa7134/saa7134-ts.c | |||
@@ -94,7 +94,6 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2) | |||
94 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); | 94 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); |
95 | struct sg_table *dma = vb2_dma_sg_plane_desc(vb2, 0); | 95 | struct sg_table *dma = vb2_dma_sg_plane_desc(vb2, 0); |
96 | unsigned int lines, llength, size; | 96 | unsigned int lines, llength, size; |
97 | int ret; | ||
98 | 97 | ||
99 | dprintk("buffer_prepare [%p]\n", buf); | 98 | dprintk("buffer_prepare [%p]\n", buf); |
100 | 99 | ||
@@ -108,25 +107,11 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2) | |||
108 | vb2_set_plane_payload(vb2, 0, size); | 107 | vb2_set_plane_payload(vb2, 0, size); |
109 | vb2->v4l2_buf.field = dev->field; | 108 | vb2->v4l2_buf.field = dev->field; |
110 | 109 | ||
111 | ret = dma_map_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
112 | if (!ret) | ||
113 | return -EIO; | ||
114 | return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents, | 110 | return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents, |
115 | saa7134_buffer_startpage(buf)); | 111 | saa7134_buffer_startpage(buf)); |
116 | } | 112 | } |
117 | EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare); | 113 | EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare); |
118 | 114 | ||
119 | void saa7134_ts_buffer_finish(struct vb2_buffer *vb2) | ||
120 | { | ||
121 | struct saa7134_dmaqueue *dmaq = vb2->vb2_queue->drv_priv; | ||
122 | struct saa7134_dev *dev = dmaq->dev; | ||
123 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); | ||
124 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); | ||
125 | |||
126 | dma_unmap_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
127 | } | ||
128 | EXPORT_SYMBOL_GPL(saa7134_ts_buffer_finish); | ||
129 | |||
130 | int saa7134_ts_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | 115 | int saa7134_ts_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
131 | unsigned int *nbuffers, unsigned int *nplanes, | 116 | unsigned int *nbuffers, unsigned int *nplanes, |
132 | unsigned int sizes[], void *alloc_ctxs[]) | 117 | unsigned int sizes[], void *alloc_ctxs[]) |
@@ -142,6 +127,7 @@ int saa7134_ts_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
142 | *nbuffers = 3; | 127 | *nbuffers = 3; |
143 | *nplanes = 1; | 128 | *nplanes = 1; |
144 | sizes[0] = size; | 129 | sizes[0] = size; |
130 | alloc_ctxs[0] = dev->alloc_ctx; | ||
145 | return 0; | 131 | return 0; |
146 | } | 132 | } |
147 | EXPORT_SYMBOL_GPL(saa7134_ts_queue_setup); | 133 | EXPORT_SYMBOL_GPL(saa7134_ts_queue_setup); |
@@ -187,7 +173,6 @@ struct vb2_ops saa7134_ts_qops = { | |||
187 | .queue_setup = saa7134_ts_queue_setup, | 173 | .queue_setup = saa7134_ts_queue_setup, |
188 | .buf_init = saa7134_ts_buffer_init, | 174 | .buf_init = saa7134_ts_buffer_init, |
189 | .buf_prepare = saa7134_ts_buffer_prepare, | 175 | .buf_prepare = saa7134_ts_buffer_prepare, |
190 | .buf_finish = saa7134_ts_buffer_finish, | ||
191 | .buf_queue = saa7134_vb2_buffer_queue, | 176 | .buf_queue = saa7134_vb2_buffer_queue, |
192 | .wait_prepare = vb2_ops_wait_prepare, | 177 | .wait_prepare = vb2_ops_wait_prepare, |
193 | .wait_finish = vb2_ops_wait_finish, | 178 | .wait_finish = vb2_ops_wait_finish, |
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c b/drivers/media/pci/saa7134/saa7134-vbi.c index 4f0b1012e4f3..5306e549e526 100644 --- a/drivers/media/pci/saa7134/saa7134-vbi.c +++ b/drivers/media/pci/saa7134/saa7134-vbi.c | |||
@@ -120,7 +120,6 @@ static int buffer_prepare(struct vb2_buffer *vb2) | |||
120 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); | 120 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); |
121 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); | 121 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); |
122 | unsigned int size; | 122 | unsigned int size; |
123 | int ret; | ||
124 | 123 | ||
125 | if (dma->sgl->offset) { | 124 | if (dma->sgl->offset) { |
126 | pr_err("The buffer is not page-aligned\n"); | 125 | pr_err("The buffer is not page-aligned\n"); |
@@ -132,9 +131,6 @@ static int buffer_prepare(struct vb2_buffer *vb2) | |||
132 | 131 | ||
133 | vb2_set_plane_payload(vb2, 0, size); | 132 | vb2_set_plane_payload(vb2, 0, size); |
134 | 133 | ||
135 | ret = dma_map_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
136 | if (!ret) | ||
137 | return -EIO; | ||
138 | return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents, | 134 | return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents, |
139 | saa7134_buffer_startpage(buf)); | 135 | saa7134_buffer_startpage(buf)); |
140 | } | 136 | } |
@@ -156,6 +152,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
156 | *nbuffers = saa7134_buffer_count(size, *nbuffers); | 152 | *nbuffers = saa7134_buffer_count(size, *nbuffers); |
157 | *nplanes = 1; | 153 | *nplanes = 1; |
158 | sizes[0] = size; | 154 | sizes[0] = size; |
155 | alloc_ctxs[0] = dev->alloc_ctx; | ||
159 | return 0; | 156 | return 0; |
160 | } | 157 | } |
161 | 158 | ||
@@ -169,21 +166,10 @@ static int buffer_init(struct vb2_buffer *vb2) | |||
169 | return 0; | 166 | return 0; |
170 | } | 167 | } |
171 | 168 | ||
172 | static void buffer_finish(struct vb2_buffer *vb2) | ||
173 | { | ||
174 | struct saa7134_dmaqueue *dmaq = vb2->vb2_queue->drv_priv; | ||
175 | struct saa7134_dev *dev = dmaq->dev; | ||
176 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); | ||
177 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); | ||
178 | |||
179 | dma_unmap_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
180 | } | ||
181 | |||
182 | struct vb2_ops saa7134_vbi_qops = { | 169 | struct vb2_ops saa7134_vbi_qops = { |
183 | .queue_setup = queue_setup, | 170 | .queue_setup = queue_setup, |
184 | .buf_init = buffer_init, | 171 | .buf_init = buffer_init, |
185 | .buf_prepare = buffer_prepare, | 172 | .buf_prepare = buffer_prepare, |
186 | .buf_finish = buffer_finish, | ||
187 | .buf_queue = saa7134_vb2_buffer_queue, | 173 | .buf_queue = saa7134_vb2_buffer_queue, |
188 | .wait_prepare = vb2_ops_wait_prepare, | 174 | .wait_prepare = vb2_ops_wait_prepare, |
189 | .wait_finish = vb2_ops_wait_finish, | 175 | .wait_finish = vb2_ops_wait_finish, |
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index fc4a427cb51f..701b52f34689 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c | |||
@@ -883,7 +883,6 @@ static int buffer_prepare(struct vb2_buffer *vb2) | |||
883 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); | 883 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); |
884 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); | 884 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); |
885 | unsigned int size; | 885 | unsigned int size; |
886 | int ret; | ||
887 | 886 | ||
888 | if (dma->sgl->offset) { | 887 | if (dma->sgl->offset) { |
889 | pr_err("The buffer is not page-aligned\n"); | 888 | pr_err("The buffer is not page-aligned\n"); |
@@ -896,23 +895,10 @@ static int buffer_prepare(struct vb2_buffer *vb2) | |||
896 | vb2_set_plane_payload(vb2, 0, size); | 895 | vb2_set_plane_payload(vb2, 0, size); |
897 | vb2->v4l2_buf.field = dev->field; | 896 | vb2->v4l2_buf.field = dev->field; |
898 | 897 | ||
899 | ret = dma_map_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
900 | if (!ret) | ||
901 | return -EIO; | ||
902 | return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents, | 898 | return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents, |
903 | saa7134_buffer_startpage(buf)); | 899 | saa7134_buffer_startpage(buf)); |
904 | } | 900 | } |
905 | 901 | ||
906 | static void buffer_finish(struct vb2_buffer *vb2) | ||
907 | { | ||
908 | struct saa7134_dmaqueue *dmaq = vb2->vb2_queue->drv_priv; | ||
909 | struct saa7134_dev *dev = dmaq->dev; | ||
910 | struct saa7134_buf *buf = container_of(vb2, struct saa7134_buf, vb2); | ||
911 | struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0); | ||
912 | |||
913 | dma_unmap_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
914 | } | ||
915 | |||
916 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | 902 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
917 | unsigned int *nbuffers, unsigned int *nplanes, | 903 | unsigned int *nbuffers, unsigned int *nplanes, |
918 | unsigned int sizes[], void *alloc_ctxs[]) | 904 | unsigned int sizes[], void *alloc_ctxs[]) |
@@ -932,6 +918,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
932 | *nbuffers = saa7134_buffer_count(size, *nbuffers); | 918 | *nbuffers = saa7134_buffer_count(size, *nbuffers); |
933 | *nplanes = 1; | 919 | *nplanes = 1; |
934 | sizes[0] = size; | 920 | sizes[0] = size; |
921 | alloc_ctxs[0] = dev->alloc_ctx; | ||
935 | return 0; | 922 | return 0; |
936 | } | 923 | } |
937 | 924 | ||
@@ -1004,7 +991,6 @@ static struct vb2_ops vb2_qops = { | |||
1004 | .queue_setup = queue_setup, | 991 | .queue_setup = queue_setup, |
1005 | .buf_init = buffer_init, | 992 | .buf_init = buffer_init, |
1006 | .buf_prepare = buffer_prepare, | 993 | .buf_prepare = buffer_prepare, |
1007 | .buf_finish = buffer_finish, | ||
1008 | .buf_queue = saa7134_vb2_buffer_queue, | 994 | .buf_queue = saa7134_vb2_buffer_queue, |
1009 | .wait_prepare = vb2_ops_wait_prepare, | 995 | .wait_prepare = vb2_ops_wait_prepare, |
1010 | .wait_finish = vb2_ops_wait_finish, | 996 | .wait_finish = vb2_ops_wait_finish, |
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index 1a82dd07205b..8bf0553b8d2f 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h | |||
@@ -588,6 +588,7 @@ struct saa7134_dev { | |||
588 | 588 | ||
589 | 589 | ||
590 | /* video+ts+vbi capture */ | 590 | /* video+ts+vbi capture */ |
591 | void *alloc_ctx; | ||
591 | struct saa7134_dmaqueue video_q; | 592 | struct saa7134_dmaqueue video_q; |
592 | struct vb2_queue video_vbq; | 593 | struct vb2_queue video_vbq; |
593 | struct saa7134_dmaqueue vbi_q; | 594 | struct saa7134_dmaqueue vbi_q; |
@@ -814,7 +815,6 @@ void saa7134_video_fini(struct saa7134_dev *dev); | |||
814 | 815 | ||
815 | int saa7134_ts_buffer_init(struct vb2_buffer *vb2); | 816 | int saa7134_ts_buffer_init(struct vb2_buffer *vb2); |
816 | int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2); | 817 | int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2); |
817 | void saa7134_ts_buffer_finish(struct vb2_buffer *vb2); | ||
818 | int saa7134_ts_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | 818 | int saa7134_ts_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
819 | unsigned int *nbuffers, unsigned int *nplanes, | 819 | unsigned int *nbuffers, unsigned int *nplanes, |
820 | unsigned int sizes[], void *alloc_ctxs[]); | 820 | unsigned int sizes[], void *alloc_ctxs[]); |
diff --git a/drivers/media/pci/saa7164/saa7164-buffer.c b/drivers/media/pci/saa7164/saa7164-buffer.c index 66696fa8341d..9bd1f73f82da 100644 --- a/drivers/media/pci/saa7164/saa7164-buffer.c +++ b/drivers/media/pci/saa7164/saa7164-buffer.c | |||
@@ -130,9 +130,9 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port, | |||
130 | goto fail2; | 130 | goto fail2; |
131 | 131 | ||
132 | /* init the buffers to a known pattern, easier during debugging */ | 132 | /* init the buffers to a known pattern, easier during debugging */ |
133 | memset_io(buf->cpu, 0xff, buf->pci_size); | 133 | memset(buf->cpu, 0xff, buf->pci_size); |
134 | buf->crc = crc32(0, buf->cpu, buf->actual_size); | 134 | buf->crc = crc32(0, buf->cpu, buf->actual_size); |
135 | memset_io(buf->pt_cpu, 0xff, buf->pt_size); | 135 | memset(buf->pt_cpu, 0xff, buf->pt_size); |
136 | 136 | ||
137 | dprintk(DBGLVL_BUF, "%s() allocated buffer @ 0x%p (%d pageptrs)\n", | 137 | dprintk(DBGLVL_BUF, "%s() allocated buffer @ 0x%p (%d pageptrs)\n", |
138 | __func__, buf, params->numpagetables); | 138 | __func__, buf, params->numpagetables); |
diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c index 5f6f3094c44e..6c73f5b155f6 100644 --- a/drivers/media/pci/saa7164/saa7164-bus.c +++ b/drivers/media/pci/saa7164/saa7164-bus.c | |||
@@ -33,12 +33,12 @@ int saa7164_bus_setup(struct saa7164_dev *dev) | |||
33 | b->Type = TYPE_BUS_PCIe; | 33 | b->Type = TYPE_BUS_PCIe; |
34 | b->m_wMaxReqSize = SAA_DEVICE_MAXREQUESTSIZE; | 34 | b->m_wMaxReqSize = SAA_DEVICE_MAXREQUESTSIZE; |
35 | 35 | ||
36 | b->m_pdwSetRing = (u8 *)(dev->bmmio + | 36 | b->m_pdwSetRing = (u8 __iomem *)(dev->bmmio + |
37 | ((u32)dev->busdesc.CommandRing)); | 37 | ((u32)dev->busdesc.CommandRing)); |
38 | 38 | ||
39 | b->m_dwSizeSetRing = SAA_DEVICE_BUFFERBLOCKSIZE; | 39 | b->m_dwSizeSetRing = SAA_DEVICE_BUFFERBLOCKSIZE; |
40 | 40 | ||
41 | b->m_pdwGetRing = (u8 *)(dev->bmmio + | 41 | b->m_pdwGetRing = (u8 __iomem *)(dev->bmmio + |
42 | ((u32)dev->busdesc.ResponseRing)); | 42 | ((u32)dev->busdesc.ResponseRing)); |
43 | 43 | ||
44 | b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; | 44 | b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; |
@@ -138,6 +138,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
138 | u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; | 138 | u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; |
139 | u32 new_swp, space_rem; | 139 | u32 new_swp, space_rem; |
140 | int ret = SAA_ERR_BAD_PARAMETER; | 140 | int ret = SAA_ERR_BAD_PARAMETER; |
141 | u16 size; | ||
141 | 142 | ||
142 | if (!msg) { | 143 | if (!msg) { |
143 | printk(KERN_ERR "%s() !msg\n", __func__); | 144 | printk(KERN_ERR "%s() !msg\n", __func__); |
@@ -148,10 +149,6 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
148 | 149 | ||
149 | saa7164_bus_verify(dev); | 150 | saa7164_bus_verify(dev); |
150 | 151 | ||
151 | msg->size = cpu_to_le16(msg->size); | ||
152 | msg->command = cpu_to_le32(msg->command); | ||
153 | msg->controlselector = cpu_to_le16(msg->controlselector); | ||
154 | |||
155 | if (msg->size > dev->bus.m_wMaxReqSize) { | 152 | if (msg->size > dev->bus.m_wMaxReqSize) { |
156 | printk(KERN_ERR "%s() Exceeded dev->bus.m_wMaxReqSize\n", | 153 | printk(KERN_ERR "%s() Exceeded dev->bus.m_wMaxReqSize\n", |
157 | __func__); | 154 | __func__); |
@@ -169,8 +166,8 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
169 | bytes_to_write = sizeof(*msg) + msg->size; | 166 | bytes_to_write = sizeof(*msg) + msg->size; |
170 | free_write_space = 0; | 167 | free_write_space = 0; |
171 | timeout = SAA_BUS_TIMEOUT; | 168 | timeout = SAA_BUS_TIMEOUT; |
172 | curr_srp = le32_to_cpu(saa7164_readl(bus->m_dwSetReadPos)); | 169 | curr_srp = saa7164_readl(bus->m_dwSetReadPos); |
173 | curr_swp = le32_to_cpu(saa7164_readl(bus->m_dwSetWritePos)); | 170 | curr_swp = saa7164_readl(bus->m_dwSetWritePos); |
174 | 171 | ||
175 | /* Deal with ring wrapping issues */ | 172 | /* Deal with ring wrapping issues */ |
176 | if (curr_srp > curr_swp) | 173 | if (curr_srp > curr_swp) |
@@ -203,7 +200,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
203 | mdelay(1); | 200 | mdelay(1); |
204 | 201 | ||
205 | /* Check the space usage again */ | 202 | /* Check the space usage again */ |
206 | curr_srp = le32_to_cpu(saa7164_readl(bus->m_dwSetReadPos)); | 203 | curr_srp = saa7164_readl(bus->m_dwSetReadPos); |
207 | 204 | ||
208 | /* Deal with ring wrapping issues */ | 205 | /* Deal with ring wrapping issues */ |
209 | if (curr_srp > curr_swp) | 206 | if (curr_srp > curr_swp) |
@@ -223,6 +220,16 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
223 | dprintk(DBGLVL_BUS, "%s() bus->m_dwSizeSetRing = %x\n", __func__, | 220 | dprintk(DBGLVL_BUS, "%s() bus->m_dwSizeSetRing = %x\n", __func__, |
224 | bus->m_dwSizeSetRing); | 221 | bus->m_dwSizeSetRing); |
225 | 222 | ||
223 | /* | ||
224 | * Make a copy of msg->size before it is converted to le16 since it is | ||
225 | * used in the code below. | ||
226 | */ | ||
227 | size = msg->size; | ||
228 | /* Convert to le16/le32 */ | ||
229 | msg->size = (__force u16)cpu_to_le16(msg->size); | ||
230 | msg->command = (__force u32)cpu_to_le32(msg->command); | ||
231 | msg->controlselector = (__force u16)cpu_to_le16(msg->controlselector); | ||
232 | |||
226 | /* Mental Note: line 462 tmmhComResBusPCIe.cpp */ | 233 | /* Mental Note: line 462 tmmhComResBusPCIe.cpp */ |
227 | 234 | ||
228 | /* Check if we're going to wrap again */ | 235 | /* Check if we're going to wrap again */ |
@@ -243,28 +250,28 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
243 | dprintk(DBGLVL_BUS, "%s() tr4\n", __func__); | 250 | dprintk(DBGLVL_BUS, "%s() tr4\n", __func__); |
244 | 251 | ||
245 | /* Split the msg into pieces as the ring wraps */ | 252 | /* Split the msg into pieces as the ring wraps */ |
246 | memcpy(bus->m_pdwSetRing + curr_swp, msg, space_rem); | 253 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, space_rem); |
247 | memcpy(bus->m_pdwSetRing, (u8 *)msg + space_rem, | 254 | memcpy_toio(bus->m_pdwSetRing, (u8 *)msg + space_rem, |
248 | sizeof(*msg) - space_rem); | 255 | sizeof(*msg) - space_rem); |
249 | 256 | ||
250 | memcpy(bus->m_pdwSetRing + sizeof(*msg) - space_rem, | 257 | memcpy_toio(bus->m_pdwSetRing + sizeof(*msg) - space_rem, |
251 | buf, msg->size); | 258 | buf, size); |
252 | 259 | ||
253 | } else if (space_rem == sizeof(*msg)) { | 260 | } else if (space_rem == sizeof(*msg)) { |
254 | dprintk(DBGLVL_BUS, "%s() tr5\n", __func__); | 261 | dprintk(DBGLVL_BUS, "%s() tr5\n", __func__); |
255 | 262 | ||
256 | /* Additional data at the beginning of the ring */ | 263 | /* Additional data at the beginning of the ring */ |
257 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 264 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
258 | memcpy(bus->m_pdwSetRing, buf, msg->size); | 265 | memcpy_toio(bus->m_pdwSetRing, buf, size); |
259 | 266 | ||
260 | } else { | 267 | } else { |
261 | /* Additional data wraps around the ring */ | 268 | /* Additional data wraps around the ring */ |
262 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 269 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
263 | if (msg->size > 0) { | 270 | if (size > 0) { |
264 | memcpy(bus->m_pdwSetRing + curr_swp + | 271 | memcpy_toio(bus->m_pdwSetRing + curr_swp + |
265 | sizeof(*msg), buf, space_rem - | 272 | sizeof(*msg), buf, space_rem - |
266 | sizeof(*msg)); | 273 | sizeof(*msg)); |
267 | memcpy(bus->m_pdwSetRing, (u8 *)buf + | 274 | memcpy_toio(bus->m_pdwSetRing, (u8 *)buf + |
268 | space_rem - sizeof(*msg), | 275 | space_rem - sizeof(*msg), |
269 | bytes_to_write - space_rem); | 276 | bytes_to_write - space_rem); |
270 | } | 277 | } |
@@ -276,15 +283,20 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
276 | dprintk(DBGLVL_BUS, "%s() tr6\n", __func__); | 283 | dprintk(DBGLVL_BUS, "%s() tr6\n", __func__); |
277 | 284 | ||
278 | /* The ring buffer doesn't wrap, two simple copies */ | 285 | /* The ring buffer doesn't wrap, two simple copies */ |
279 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 286 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
280 | memcpy(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, | 287 | memcpy_toio(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, |
281 | msg->size); | 288 | size); |
282 | } | 289 | } |
283 | 290 | ||
284 | dprintk(DBGLVL_BUS, "%s() new_swp = %x\n", __func__, new_swp); | 291 | dprintk(DBGLVL_BUS, "%s() new_swp = %x\n", __func__, new_swp); |
285 | 292 | ||
286 | /* Update the bus write position */ | 293 | /* Update the bus write position */ |
287 | saa7164_writel(bus->m_dwSetWritePos, cpu_to_le32(new_swp)); | 294 | saa7164_writel(bus->m_dwSetWritePos, new_swp); |
295 | |||
296 | /* Convert back to cpu after writing the msg to the ringbuffer. */ | ||
297 | msg->size = le16_to_cpu((__force __le16)msg->size); | ||
298 | msg->command = le32_to_cpu((__force __le32)msg->command); | ||
299 | msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); | ||
288 | ret = SAA_OK; | 300 | ret = SAA_OK; |
289 | 301 | ||
290 | out: | 302 | out: |
@@ -336,8 +348,8 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
336 | /* Peek the bus to see if a msg exists, if it's not what we're expecting | 348 | /* Peek the bus to see if a msg exists, if it's not what we're expecting |
337 | * then return cleanly else read the message from the bus. | 349 | * then return cleanly else read the message from the bus. |
338 | */ | 350 | */ |
339 | curr_gwp = le32_to_cpu(saa7164_readl(bus->m_dwGetWritePos)); | 351 | curr_gwp = saa7164_readl(bus->m_dwGetWritePos); |
340 | curr_grp = le32_to_cpu(saa7164_readl(bus->m_dwGetReadPos)); | 352 | curr_grp = saa7164_readl(bus->m_dwGetReadPos); |
341 | 353 | ||
342 | if (curr_gwp == curr_grp) { | 354 | if (curr_gwp == curr_grp) { |
343 | ret = SAA_ERR_EMPTY; | 355 | ret = SAA_ERR_EMPTY; |
@@ -369,14 +381,18 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
369 | new_grp -= bus->m_dwSizeGetRing; | 381 | new_grp -= bus->m_dwSizeGetRing; |
370 | space_rem = bus->m_dwSizeGetRing - curr_grp; | 382 | space_rem = bus->m_dwSizeGetRing - curr_grp; |
371 | 383 | ||
372 | memcpy(&msg_tmp, bus->m_pdwGetRing + curr_grp, space_rem); | 384 | memcpy_fromio(&msg_tmp, bus->m_pdwGetRing + curr_grp, space_rem); |
373 | memcpy((u8 *)&msg_tmp + space_rem, bus->m_pdwGetRing, | 385 | memcpy_fromio((u8 *)&msg_tmp + space_rem, bus->m_pdwGetRing, |
374 | bytes_to_read - space_rem); | 386 | bytes_to_read - space_rem); |
375 | 387 | ||
376 | } else { | 388 | } else { |
377 | /* No wrapping */ | 389 | /* No wrapping */ |
378 | memcpy(&msg_tmp, bus->m_pdwGetRing + curr_grp, bytes_to_read); | 390 | memcpy_fromio(&msg_tmp, bus->m_pdwGetRing + curr_grp, bytes_to_read); |
379 | } | 391 | } |
392 | /* Convert from little endian to CPU */ | ||
393 | msg_tmp.size = le16_to_cpu((__force __le16)msg_tmp.size); | ||
394 | msg_tmp.command = le32_to_cpu((__force __le32)msg_tmp.command); | ||
395 | msg_tmp.controlselector = le16_to_cpu((__force __le16)msg_tmp.controlselector); | ||
380 | 396 | ||
381 | /* No need to update the read positions, because this was a peek */ | 397 | /* No need to update the read positions, because this was a peek */ |
382 | /* If the caller specifically want to peek, return */ | 398 | /* If the caller specifically want to peek, return */ |
@@ -427,24 +443,24 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
427 | 443 | ||
428 | if (space_rem < sizeof(*msg)) { | 444 | if (space_rem < sizeof(*msg)) { |
429 | /* msg wraps around the ring */ | 445 | /* msg wraps around the ring */ |
430 | memcpy(msg, bus->m_pdwGetRing + curr_grp, space_rem); | 446 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, space_rem); |
431 | memcpy((u8 *)msg + space_rem, bus->m_pdwGetRing, | 447 | memcpy_fromio((u8 *)msg + space_rem, bus->m_pdwGetRing, |
432 | sizeof(*msg) - space_rem); | 448 | sizeof(*msg) - space_rem); |
433 | if (buf) | 449 | if (buf) |
434 | memcpy(buf, bus->m_pdwGetRing + sizeof(*msg) - | 450 | memcpy_fromio(buf, bus->m_pdwGetRing + sizeof(*msg) - |
435 | space_rem, buf_size); | 451 | space_rem, buf_size); |
436 | 452 | ||
437 | } else if (space_rem == sizeof(*msg)) { | 453 | } else if (space_rem == sizeof(*msg)) { |
438 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 454 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
439 | if (buf) | 455 | if (buf) |
440 | memcpy(buf, bus->m_pdwGetRing, buf_size); | 456 | memcpy_fromio(buf, bus->m_pdwGetRing, buf_size); |
441 | } else { | 457 | } else { |
442 | /* Additional data wraps around the ring */ | 458 | /* Additional data wraps around the ring */ |
443 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 459 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
444 | if (buf) { | 460 | if (buf) { |
445 | memcpy(buf, bus->m_pdwGetRing + curr_grp + | 461 | memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + |
446 | sizeof(*msg), space_rem - sizeof(*msg)); | 462 | sizeof(*msg), space_rem - sizeof(*msg)); |
447 | memcpy(buf + space_rem - sizeof(*msg), | 463 | memcpy_fromio(buf + space_rem - sizeof(*msg), |
448 | bus->m_pdwGetRing, bytes_to_read - | 464 | bus->m_pdwGetRing, bytes_to_read - |
449 | space_rem); | 465 | space_rem); |
450 | } | 466 | } |
@@ -453,19 +469,20 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
453 | 469 | ||
454 | } else { | 470 | } else { |
455 | /* No wrapping */ | 471 | /* No wrapping */ |
456 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 472 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
457 | if (buf) | 473 | if (buf) |
458 | memcpy(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), | 474 | memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), |
459 | buf_size); | 475 | buf_size); |
460 | } | 476 | } |
477 | /* Convert from little endian to CPU */ | ||
478 | msg->size = le16_to_cpu((__force __le16)msg->size); | ||
479 | msg->command = le32_to_cpu((__force __le32)msg->command); | ||
480 | msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); | ||
461 | 481 | ||
462 | /* Update the read positions, adjusting the ring */ | 482 | /* Update the read positions, adjusting the ring */ |
463 | saa7164_writel(bus->m_dwGetReadPos, cpu_to_le32(new_grp)); | 483 | saa7164_writel(bus->m_dwGetReadPos, new_grp); |
464 | 484 | ||
465 | peekout: | 485 | peekout: |
466 | msg->size = le16_to_cpu(msg->size); | ||
467 | msg->command = le32_to_cpu(msg->command); | ||
468 | msg->controlselector = le16_to_cpu(msg->controlselector); | ||
469 | ret = SAA_OK; | 486 | ret = SAA_OK; |
470 | out: | 487 | out: |
471 | mutex_unlock(&bus->lock); | 488 | mutex_unlock(&bus->lock); |
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index cc1be8a7a451..4b0bec3766ed 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c | |||
@@ -119,7 +119,7 @@ static void saa7164_ts_verifier(struct saa7164_buffer *buf) | |||
119 | u32 i; | 119 | u32 i; |
120 | u8 cc, a; | 120 | u8 cc, a; |
121 | u16 pid; | 121 | u16 pid; |
122 | u8 __iomem *bufcpu = (u8 *)buf->cpu; | 122 | u8 *bufcpu = (u8 *)buf->cpu; |
123 | 123 | ||
124 | port->sync_errors = 0; | 124 | port->sync_errors = 0; |
125 | port->v_cc_errors = 0; | 125 | port->v_cc_errors = 0; |
@@ -260,7 +260,7 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr) | |||
260 | struct saa7164_user_buffer *ubuf = NULL; | 260 | struct saa7164_user_buffer *ubuf = NULL; |
261 | struct list_head *c, *n; | 261 | struct list_head *c, *n; |
262 | int i = 0; | 262 | int i = 0; |
263 | u8 __iomem *p; | 263 | u8 *p; |
264 | 264 | ||
265 | mutex_lock(&port->dmaqueue_lock); | 265 | mutex_lock(&port->dmaqueue_lock); |
266 | list_for_each_safe(c, n, &port->dmaqueue.list) { | 266 | list_for_each_safe(c, n, &port->dmaqueue.list) { |
@@ -318,8 +318,7 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr) | |||
318 | 318 | ||
319 | if (buf->actual_size <= ubuf->actual_size) { | 319 | if (buf->actual_size <= ubuf->actual_size) { |
320 | 320 | ||
321 | memcpy_fromio(ubuf->data, buf->cpu, | 321 | memcpy(ubuf->data, buf->cpu, ubuf->actual_size); |
322 | ubuf->actual_size); | ||
323 | 322 | ||
324 | if (crc_checking) { | 323 | if (crc_checking) { |
325 | /* Throw a new checksum on the read buffer */ | 324 | /* Throw a new checksum on the read buffer */ |
@@ -346,7 +345,7 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr) | |||
346 | * with known bad data. We check for this data at a later point | 345 | * with known bad data. We check for this data at a later point |
347 | * in time. */ | 346 | * in time. */ |
348 | saa7164_buffer_zero_offsets(port, bufnr); | 347 | saa7164_buffer_zero_offsets(port, bufnr); |
349 | memset_io(buf->cpu, 0xff, buf->pci_size); | 348 | memset(buf->cpu, 0xff, buf->pci_size); |
350 | if (crc_checking) { | 349 | if (crc_checking) { |
351 | /* Throw yet aanother new checksum on the dma buffer */ | 350 | /* Throw yet aanother new checksum on the dma buffer */ |
352 | buf->crc = crc32(0, buf->cpu, buf->actual_size); | 351 | buf->crc = crc32(0, buf->cpu, buf->actual_size); |
@@ -1096,7 +1095,7 @@ static int saa7164_proc_show(struct seq_file *m, void *v) | |||
1096 | if (c == 0) | 1095 | if (c == 0) |
1097 | seq_printf(m, " %04x:", i); | 1096 | seq_printf(m, " %04x:", i); |
1098 | 1097 | ||
1099 | seq_printf(m, " %02x", *(b->m_pdwSetRing + i)); | 1098 | seq_printf(m, " %02x", readb(b->m_pdwSetRing + i)); |
1100 | 1099 | ||
1101 | if (++c == 16) { | 1100 | if (++c == 16) { |
1102 | seq_printf(m, "\n"); | 1101 | seq_printf(m, "\n"); |
@@ -1111,7 +1110,7 @@ static int saa7164_proc_show(struct seq_file *m, void *v) | |||
1111 | if (c == 0) | 1110 | if (c == 0) |
1112 | seq_printf(m, " %04x:", i); | 1111 | seq_printf(m, " %04x:", i); |
1113 | 1112 | ||
1114 | seq_printf(m, " %02x", *(b->m_pdwGetRing + i)); | 1113 | seq_printf(m, " %02x", readb(b->m_pdwGetRing + i)); |
1115 | 1114 | ||
1116 | if (++c == 16) { | 1115 | if (++c == 16) { |
1117 | seq_printf(m, "\n"); | 1116 | seq_printf(m, "\n"); |
diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c index 86763203d61d..add06ab5124d 100644 --- a/drivers/media/pci/saa7164/saa7164-fw.c +++ b/drivers/media/pci/saa7164/saa7164-fw.c | |||
@@ -72,7 +72,7 @@ static int saa7164_dl_wait_clr(struct saa7164_dev *dev, u32 reg) | |||
72 | /* TODO: move dlflags into dev-> and change to write/readl/b */ | 72 | /* TODO: move dlflags into dev-> and change to write/readl/b */ |
73 | /* TODO: Excessive levels of debug */ | 73 | /* TODO: Excessive levels of debug */ |
74 | static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, | 74 | static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, |
75 | u32 dlflags, u8 *dst, u32 dstsize) | 75 | u32 dlflags, u8 __iomem *dst, u32 dstsize) |
76 | { | 76 | { |
77 | u32 reg, timeout, offset; | 77 | u32 reg, timeout, offset; |
78 | u8 *srcbuf = NULL; | 78 | u8 *srcbuf = NULL; |
@@ -136,7 +136,7 @@ static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, | |||
136 | srcsize -= dstsize, offset += dstsize) { | 136 | srcsize -= dstsize, offset += dstsize) { |
137 | 137 | ||
138 | dprintk(DBGLVL_FW, "%s() memcpy %d\n", __func__, dstsize); | 138 | dprintk(DBGLVL_FW, "%s() memcpy %d\n", __func__, dstsize); |
139 | memcpy(dst, srcbuf + offset, dstsize); | 139 | memcpy_toio(dst, srcbuf + offset, dstsize); |
140 | 140 | ||
141 | /* Flag the data as ready */ | 141 | /* Flag the data as ready */ |
142 | saa7164_writel(drflag, 1); | 142 | saa7164_writel(drflag, 1); |
@@ -154,7 +154,7 @@ static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, | |||
154 | 154 | ||
155 | dprintk(DBGLVL_FW, "%s() memcpy(l) %d\n", __func__, dstsize); | 155 | dprintk(DBGLVL_FW, "%s() memcpy(l) %d\n", __func__, dstsize); |
156 | /* Write last block to the device */ | 156 | /* Write last block to the device */ |
157 | memcpy(dst, srcbuf+offset, srcsize); | 157 | memcpy_toio(dst, srcbuf+offset, srcsize); |
158 | 158 | ||
159 | /* Flag the data as ready */ | 159 | /* Flag the data as ready */ |
160 | saa7164_writel(drflag, 1); | 160 | saa7164_writel(drflag, 1); |
diff --git a/drivers/media/pci/saa7164/saa7164-types.h b/drivers/media/pci/saa7164/saa7164-types.h index 1d2140a3eb38..f48ba978f835 100644 --- a/drivers/media/pci/saa7164/saa7164-types.h +++ b/drivers/media/pci/saa7164/saa7164-types.h | |||
@@ -78,9 +78,9 @@ enum tmBusType { | |||
78 | struct tmComResBusInfo { | 78 | struct tmComResBusInfo { |
79 | enum tmBusType Type; | 79 | enum tmBusType Type; |
80 | u16 m_wMaxReqSize; | 80 | u16 m_wMaxReqSize; |
81 | u8 *m_pdwSetRing; | 81 | u8 __iomem *m_pdwSetRing; |
82 | u32 m_dwSizeSetRing; | 82 | u32 m_dwSizeSetRing; |
83 | u8 *m_pdwGetRing; | 83 | u8 __iomem *m_pdwGetRing; |
84 | u32 m_dwSizeGetRing; | 84 | u32 m_dwSizeGetRing; |
85 | u32 m_dwSetWritePos; | 85 | u32 m_dwSetWritePos; |
86 | u32 m_dwSetReadPos; | 86 | u32 m_dwSetReadPos; |
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h index 8b29e8990301..cd1a07ce27cb 100644 --- a/drivers/media/pci/saa7164/saa7164.h +++ b/drivers/media/pci/saa7164/saa7164.h | |||
@@ -313,13 +313,13 @@ struct saa7164_buffer { | |||
313 | 313 | ||
314 | /* A block of page align PCI memory */ | 314 | /* A block of page align PCI memory */ |
315 | u32 pci_size; /* PCI allocation size in bytes */ | 315 | u32 pci_size; /* PCI allocation size in bytes */ |
316 | u64 __iomem *cpu; /* Virtual address */ | 316 | u64 *cpu; /* Virtual address */ |
317 | dma_addr_t dma; /* Physical address */ | 317 | dma_addr_t dma; /* Physical address */ |
318 | u32 crc; /* Checksum for the entire buffer data */ | 318 | u32 crc; /* Checksum for the entire buffer data */ |
319 | 319 | ||
320 | /* A page table that splits the block into a number of entries */ | 320 | /* A page table that splits the block into a number of entries */ |
321 | u32 pt_size; /* PCI allocation size in bytes */ | 321 | u32 pt_size; /* PCI allocation size in bytes */ |
322 | u64 __iomem *pt_cpu; /* Virtual address */ | 322 | u64 *pt_cpu; /* Virtual address */ |
323 | dma_addr_t pt_dma; /* Physical address */ | 323 | dma_addr_t pt_dma; /* Physical address */ |
324 | 324 | ||
325 | /* Encoder fops */ | 325 | /* Encoder fops */ |
diff --git a/drivers/media/pci/smipcie/Kconfig b/drivers/media/pci/smipcie/Kconfig new file mode 100644 index 000000000000..c8de53f5ea28 --- /dev/null +++ b/drivers/media/pci/smipcie/Kconfig | |||
@@ -0,0 +1,17 @@ | |||
1 | config DVB_SMIPCIE | ||
2 | tristate "SMI PCIe DVBSky cards" | ||
3 | depends on DVB_CORE && PCI && I2C | ||
4 | select I2C_ALGOBIT | ||
5 | select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT | ||
6 | select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT | ||
7 | select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT | ||
8 | select MEDIA_TUNER_M88RS6000T if MEDIA_SUBDRV_AUTOSELECT | ||
9 | select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT | ||
10 | help | ||
11 | Support for cards with SMI PCIe bridge: | ||
12 | - DVBSky S950 V3 | ||
13 | - DVBSky S952 V3 | ||
14 | - DVBSky T9580 V3 | ||
15 | |||
16 | Say Y or M if you own such a device and want to use it. | ||
17 | If unsure say N. | ||
diff --git a/drivers/media/pci/smipcie/Makefile b/drivers/media/pci/smipcie/Makefile new file mode 100644 index 000000000000..be55481a6e95 --- /dev/null +++ b/drivers/media/pci/smipcie/Makefile | |||
@@ -0,0 +1,6 @@ | |||
1 | obj-$(CONFIG_DVB_SMIPCIE) += smipcie.o | ||
2 | |||
3 | ccflags-y += -Idrivers/media/tuners | ||
4 | ccflags-y += -Idrivers/media/dvb-core | ||
5 | ccflags-y += -Idrivers/media/dvb-frontends | ||
6 | |||
diff --git a/drivers/media/pci/smipcie/smipcie.c b/drivers/media/pci/smipcie/smipcie.c new file mode 100644 index 000000000000..f773350e67b9 --- /dev/null +++ b/drivers/media/pci/smipcie/smipcie.c | |||
@@ -0,0 +1,1099 @@ | |||
1 | /* | ||
2 | * SMI PCIe driver for DVBSky cards. | ||
3 | * | ||
4 | * Copyright (C) 2014 Max nibble <nibble.max@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #include "smipcie.h" | ||
18 | #include "m88ds3103.h" | ||
19 | #include "m88ts2022.h" | ||
20 | #include "m88rs6000t.h" | ||
21 | #include "si2168.h" | ||
22 | #include "si2157.h" | ||
23 | |||
24 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
25 | |||
26 | static int smi_hw_init(struct smi_dev *dev) | ||
27 | { | ||
28 | u32 port_mux, port_ctrl, int_stat; | ||
29 | |||
30 | /* set port mux.*/ | ||
31 | port_mux = smi_read(MUX_MODE_CTRL); | ||
32 | port_mux &= ~(rbPaMSMask); | ||
33 | port_mux |= rbPaMSDtvNoGpio; | ||
34 | port_mux &= ~(rbPbMSMask); | ||
35 | port_mux |= rbPbMSDtvNoGpio; | ||
36 | port_mux &= ~(0x0f0000); | ||
37 | port_mux |= 0x50000; | ||
38 | smi_write(MUX_MODE_CTRL, port_mux); | ||
39 | |||
40 | /* set DTV register.*/ | ||
41 | /* Port A */ | ||
42 | port_ctrl = smi_read(VIDEO_CTRL_STATUS_A); | ||
43 | port_ctrl &= ~0x01; | ||
44 | smi_write(VIDEO_CTRL_STATUS_A, port_ctrl); | ||
45 | port_ctrl = smi_read(MPEG2_CTRL_A); | ||
46 | port_ctrl &= ~0x40; | ||
47 | port_ctrl |= 0x80; | ||
48 | smi_write(MPEG2_CTRL_A, port_ctrl); | ||
49 | /* Port B */ | ||
50 | port_ctrl = smi_read(VIDEO_CTRL_STATUS_B); | ||
51 | port_ctrl &= ~0x01; | ||
52 | smi_write(VIDEO_CTRL_STATUS_B, port_ctrl); | ||
53 | port_ctrl = smi_read(MPEG2_CTRL_B); | ||
54 | port_ctrl &= ~0x40; | ||
55 | port_ctrl |= 0x80; | ||
56 | smi_write(MPEG2_CTRL_B, port_ctrl); | ||
57 | |||
58 | /* disable and clear interrupt.*/ | ||
59 | smi_write(MSI_INT_ENA_CLR, ALL_INT); | ||
60 | int_stat = smi_read(MSI_INT_STATUS); | ||
61 | smi_write(MSI_INT_STATUS_CLR, int_stat); | ||
62 | |||
63 | /* reset demod.*/ | ||
64 | smi_clear(PERIPHERAL_CTRL, 0x0303); | ||
65 | msleep(50); | ||
66 | smi_set(PERIPHERAL_CTRL, 0x0101); | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | /* i2c bit bus.*/ | ||
71 | static void smi_i2c_cfg(struct smi_dev *dev, u32 sw_ctl) | ||
72 | { | ||
73 | u32 dwCtrl; | ||
74 | |||
75 | dwCtrl = smi_read(sw_ctl); | ||
76 | dwCtrl &= ~0x18; /* disable output.*/ | ||
77 | dwCtrl |= 0x21; /* reset and software mode.*/ | ||
78 | dwCtrl &= ~0xff00; | ||
79 | dwCtrl |= 0x6400; | ||
80 | smi_write(sw_ctl, dwCtrl); | ||
81 | msleep(20); | ||
82 | dwCtrl = smi_read(sw_ctl); | ||
83 | dwCtrl &= ~0x20; | ||
84 | smi_write(sw_ctl, dwCtrl); | ||
85 | } | ||
86 | |||
87 | static void smi_i2c_setsda(struct smi_dev *dev, int state, u32 sw_ctl) | ||
88 | { | ||
89 | if (state) { | ||
90 | /* set as input.*/ | ||
91 | smi_clear(sw_ctl, SW_I2C_MSK_DAT_EN); | ||
92 | } else { | ||
93 | smi_clear(sw_ctl, SW_I2C_MSK_DAT_OUT); | ||
94 | /* set as output.*/ | ||
95 | smi_set(sw_ctl, SW_I2C_MSK_DAT_EN); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | static void smi_i2c_setscl(void *data, int state, u32 sw_ctl) | ||
100 | { | ||
101 | struct smi_dev *dev = data; | ||
102 | |||
103 | if (state) { | ||
104 | /* set as input.*/ | ||
105 | smi_clear(sw_ctl, SW_I2C_MSK_CLK_EN); | ||
106 | } else { | ||
107 | smi_clear(sw_ctl, SW_I2C_MSK_CLK_OUT); | ||
108 | /* set as output.*/ | ||
109 | smi_set(sw_ctl, SW_I2C_MSK_CLK_EN); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | static int smi_i2c_getsda(void *data, u32 sw_ctl) | ||
114 | { | ||
115 | struct smi_dev *dev = data; | ||
116 | /* set as input.*/ | ||
117 | smi_clear(sw_ctl, SW_I2C_MSK_DAT_EN); | ||
118 | udelay(1); | ||
119 | return (smi_read(sw_ctl) & SW_I2C_MSK_DAT_IN) ? 1 : 0; | ||
120 | } | ||
121 | |||
122 | static int smi_i2c_getscl(void *data, u32 sw_ctl) | ||
123 | { | ||
124 | struct smi_dev *dev = data; | ||
125 | /* set as input.*/ | ||
126 | smi_clear(sw_ctl, SW_I2C_MSK_CLK_EN); | ||
127 | udelay(1); | ||
128 | return (smi_read(sw_ctl) & SW_I2C_MSK_CLK_IN) ? 1 : 0; | ||
129 | } | ||
130 | /* i2c 0.*/ | ||
131 | static void smi_i2c0_setsda(void *data, int state) | ||
132 | { | ||
133 | struct smi_dev *dev = data; | ||
134 | |||
135 | smi_i2c_setsda(dev, state, I2C_A_SW_CTL); | ||
136 | } | ||
137 | |||
138 | static void smi_i2c0_setscl(void *data, int state) | ||
139 | { | ||
140 | struct smi_dev *dev = data; | ||
141 | |||
142 | smi_i2c_setscl(dev, state, I2C_A_SW_CTL); | ||
143 | } | ||
144 | |||
145 | static int smi_i2c0_getsda(void *data) | ||
146 | { | ||
147 | struct smi_dev *dev = data; | ||
148 | |||
149 | return smi_i2c_getsda(dev, I2C_A_SW_CTL); | ||
150 | } | ||
151 | |||
152 | static int smi_i2c0_getscl(void *data) | ||
153 | { | ||
154 | struct smi_dev *dev = data; | ||
155 | |||
156 | return smi_i2c_getscl(dev, I2C_A_SW_CTL); | ||
157 | } | ||
158 | /* i2c 1.*/ | ||
159 | static void smi_i2c1_setsda(void *data, int state) | ||
160 | { | ||
161 | struct smi_dev *dev = data; | ||
162 | |||
163 | smi_i2c_setsda(dev, state, I2C_B_SW_CTL); | ||
164 | } | ||
165 | |||
166 | static void smi_i2c1_setscl(void *data, int state) | ||
167 | { | ||
168 | struct smi_dev *dev = data; | ||
169 | |||
170 | smi_i2c_setscl(dev, state, I2C_B_SW_CTL); | ||
171 | } | ||
172 | |||
173 | static int smi_i2c1_getsda(void *data) | ||
174 | { | ||
175 | struct smi_dev *dev = data; | ||
176 | |||
177 | return smi_i2c_getsda(dev, I2C_B_SW_CTL); | ||
178 | } | ||
179 | |||
180 | static int smi_i2c1_getscl(void *data) | ||
181 | { | ||
182 | struct smi_dev *dev = data; | ||
183 | |||
184 | return smi_i2c_getscl(dev, I2C_B_SW_CTL); | ||
185 | } | ||
186 | |||
187 | static int smi_i2c_init(struct smi_dev *dev) | ||
188 | { | ||
189 | int ret; | ||
190 | |||
191 | /* i2c bus 0 */ | ||
192 | smi_i2c_cfg(dev, I2C_A_SW_CTL); | ||
193 | i2c_set_adapdata(&dev->i2c_bus[0], dev); | ||
194 | strcpy(dev->i2c_bus[0].name, "SMI-I2C0"); | ||
195 | dev->i2c_bus[0].owner = THIS_MODULE; | ||
196 | dev->i2c_bus[0].dev.parent = &dev->pci_dev->dev; | ||
197 | dev->i2c_bus[0].algo_data = &dev->i2c_bit[0]; | ||
198 | dev->i2c_bit[0].data = dev; | ||
199 | dev->i2c_bit[0].setsda = smi_i2c0_setsda; | ||
200 | dev->i2c_bit[0].setscl = smi_i2c0_setscl; | ||
201 | dev->i2c_bit[0].getsda = smi_i2c0_getsda; | ||
202 | dev->i2c_bit[0].getscl = smi_i2c0_getscl; | ||
203 | dev->i2c_bit[0].udelay = 12; | ||
204 | dev->i2c_bit[0].timeout = 10; | ||
205 | /* Raise SCL and SDA */ | ||
206 | smi_i2c0_setsda(dev, 1); | ||
207 | smi_i2c0_setscl(dev, 1); | ||
208 | |||
209 | ret = i2c_bit_add_bus(&dev->i2c_bus[0]); | ||
210 | if (ret < 0) | ||
211 | return ret; | ||
212 | |||
213 | /* i2c bus 1 */ | ||
214 | smi_i2c_cfg(dev, I2C_B_SW_CTL); | ||
215 | i2c_set_adapdata(&dev->i2c_bus[1], dev); | ||
216 | strcpy(dev->i2c_bus[1].name, "SMI-I2C1"); | ||
217 | dev->i2c_bus[1].owner = THIS_MODULE; | ||
218 | dev->i2c_bus[1].dev.parent = &dev->pci_dev->dev; | ||
219 | dev->i2c_bus[1].algo_data = &dev->i2c_bit[1]; | ||
220 | dev->i2c_bit[1].data = dev; | ||
221 | dev->i2c_bit[1].setsda = smi_i2c1_setsda; | ||
222 | dev->i2c_bit[1].setscl = smi_i2c1_setscl; | ||
223 | dev->i2c_bit[1].getsda = smi_i2c1_getsda; | ||
224 | dev->i2c_bit[1].getscl = smi_i2c1_getscl; | ||
225 | dev->i2c_bit[1].udelay = 12; | ||
226 | dev->i2c_bit[1].timeout = 10; | ||
227 | /* Raise SCL and SDA */ | ||
228 | smi_i2c1_setsda(dev, 1); | ||
229 | smi_i2c1_setscl(dev, 1); | ||
230 | |||
231 | ret = i2c_bit_add_bus(&dev->i2c_bus[1]); | ||
232 | if (ret < 0) | ||
233 | i2c_del_adapter(&dev->i2c_bus[0]); | ||
234 | |||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | static void smi_i2c_exit(struct smi_dev *dev) | ||
239 | { | ||
240 | i2c_del_adapter(&dev->i2c_bus[0]); | ||
241 | i2c_del_adapter(&dev->i2c_bus[1]); | ||
242 | } | ||
243 | |||
244 | static int smi_read_eeprom(struct i2c_adapter *i2c, u16 reg, u8 *data, u16 size) | ||
245 | { | ||
246 | int ret; | ||
247 | u8 b0[2] = { (reg >> 8) & 0xff, reg & 0xff }; | ||
248 | |||
249 | struct i2c_msg msg[] = { | ||
250 | { .addr = 0x50, .flags = 0, | ||
251 | .buf = b0, .len = 2 }, | ||
252 | { .addr = 0x50, .flags = I2C_M_RD, | ||
253 | .buf = data, .len = size } | ||
254 | }; | ||
255 | |||
256 | ret = i2c_transfer(i2c, msg, 2); | ||
257 | |||
258 | if (ret != 2) { | ||
259 | dev_err(&i2c->dev, "%s: reg=0x%x (error=%d)\n", | ||
260 | __func__, reg, ret); | ||
261 | return ret; | ||
262 | } | ||
263 | return ret; | ||
264 | } | ||
265 | |||
266 | /* ts port interrupt operations */ | ||
267 | static void smi_port_disableInterrupt(struct smi_port *port) | ||
268 | { | ||
269 | struct smi_dev *dev = port->dev; | ||
270 | |||
271 | smi_write(MSI_INT_ENA_CLR, | ||
272 | (port->_dmaInterruptCH0 | port->_dmaInterruptCH1)); | ||
273 | } | ||
274 | |||
275 | static void smi_port_enableInterrupt(struct smi_port *port) | ||
276 | { | ||
277 | struct smi_dev *dev = port->dev; | ||
278 | |||
279 | smi_write(MSI_INT_ENA_SET, | ||
280 | (port->_dmaInterruptCH0 | port->_dmaInterruptCH1)); | ||
281 | } | ||
282 | |||
283 | static void smi_port_clearInterrupt(struct smi_port *port) | ||
284 | { | ||
285 | struct smi_dev *dev = port->dev; | ||
286 | |||
287 | smi_write(MSI_INT_STATUS_CLR, | ||
288 | (port->_dmaInterruptCH0 | port->_dmaInterruptCH1)); | ||
289 | } | ||
290 | |||
291 | /* tasklet handler: DMA data to dmx.*/ | ||
292 | static void smi_dma_xfer(unsigned long data) | ||
293 | { | ||
294 | struct smi_port *port = (struct smi_port *) data; | ||
295 | struct smi_dev *dev = port->dev; | ||
296 | u32 intr_status, finishedData, dmaManagement; | ||
297 | u8 dmaChan0State, dmaChan1State; | ||
298 | |||
299 | intr_status = port->_int_status; | ||
300 | dmaManagement = smi_read(port->DMA_MANAGEMENT); | ||
301 | dmaChan0State = (u8)((dmaManagement & 0x00000030) >> 4); | ||
302 | dmaChan1State = (u8)((dmaManagement & 0x00300000) >> 20); | ||
303 | |||
304 | /* CH-0 DMA interrupt.*/ | ||
305 | if ((intr_status & port->_dmaInterruptCH0) && (dmaChan0State == 0x01)) { | ||
306 | dev_dbg(&dev->pci_dev->dev, | ||
307 | "Port[%d]-DMA CH0 engine complete successful !\n", | ||
308 | port->idx); | ||
309 | finishedData = smi_read(port->DMA_CHAN0_TRANS_STATE); | ||
310 | finishedData &= 0x003FFFFF; | ||
311 | /* value of DMA_PORT0_CHAN0_TRANS_STATE register [21:0] | ||
312 | * indicate dma total transfer length and | ||
313 | * zero of [21:0] indicate dma total transfer length | ||
314 | * equal to 0x400000 (4MB)*/ | ||
315 | if (finishedData == 0) | ||
316 | finishedData = 0x00400000; | ||
317 | if (finishedData != SMI_TS_DMA_BUF_SIZE) { | ||
318 | dev_dbg(&dev->pci_dev->dev, | ||
319 | "DMA CH0 engine complete length mismatched, finish data=%d !\n", | ||
320 | finishedData); | ||
321 | } | ||
322 | dvb_dmx_swfilter_packets(&port->demux, | ||
323 | port->cpu_addr[0], (finishedData / 188)); | ||
324 | /*dvb_dmx_swfilter(&port->demux, | ||
325 | port->cpu_addr[0], finishedData);*/ | ||
326 | } | ||
327 | /* CH-1 DMA interrupt.*/ | ||
328 | if ((intr_status & port->_dmaInterruptCH1) && (dmaChan1State == 0x01)) { | ||
329 | dev_dbg(&dev->pci_dev->dev, | ||
330 | "Port[%d]-DMA CH1 engine complete successful !\n", | ||
331 | port->idx); | ||
332 | finishedData = smi_read(port->DMA_CHAN1_TRANS_STATE); | ||
333 | finishedData &= 0x003FFFFF; | ||
334 | /* value of DMA_PORT0_CHAN0_TRANS_STATE register [21:0] | ||
335 | * indicate dma total transfer length and | ||
336 | * zero of [21:0] indicate dma total transfer length | ||
337 | * equal to 0x400000 (4MB)*/ | ||
338 | if (finishedData == 0) | ||
339 | finishedData = 0x00400000; | ||
340 | if (finishedData != SMI_TS_DMA_BUF_SIZE) { | ||
341 | dev_dbg(&dev->pci_dev->dev, | ||
342 | "DMA CH1 engine complete length mismatched, finish data=%d !\n", | ||
343 | finishedData); | ||
344 | } | ||
345 | dvb_dmx_swfilter_packets(&port->demux, | ||
346 | port->cpu_addr[1], (finishedData / 188)); | ||
347 | /*dvb_dmx_swfilter(&port->demux, | ||
348 | port->cpu_addr[1], finishedData);*/ | ||
349 | } | ||
350 | /* restart DMA.*/ | ||
351 | if (intr_status & port->_dmaInterruptCH0) | ||
352 | dmaManagement |= 0x00000002; | ||
353 | if (intr_status & port->_dmaInterruptCH1) | ||
354 | dmaManagement |= 0x00020000; | ||
355 | smi_write(port->DMA_MANAGEMENT, dmaManagement); | ||
356 | /* Re-enable interrupts */ | ||
357 | smi_port_enableInterrupt(port); | ||
358 | } | ||
359 | |||
360 | static void smi_port_dma_free(struct smi_port *port) | ||
361 | { | ||
362 | if (port->cpu_addr[0]) { | ||
363 | pci_free_consistent(port->dev->pci_dev, SMI_TS_DMA_BUF_SIZE, | ||
364 | port->cpu_addr[0], port->dma_addr[0]); | ||
365 | port->cpu_addr[0] = NULL; | ||
366 | } | ||
367 | if (port->cpu_addr[1]) { | ||
368 | pci_free_consistent(port->dev->pci_dev, SMI_TS_DMA_BUF_SIZE, | ||
369 | port->cpu_addr[1], port->dma_addr[1]); | ||
370 | port->cpu_addr[1] = NULL; | ||
371 | } | ||
372 | } | ||
373 | |||
374 | static int smi_port_init(struct smi_port *port, int dmaChanUsed) | ||
375 | { | ||
376 | dev_dbg(&port->dev->pci_dev->dev, | ||
377 | "%s, port %d, dmaused %d\n", __func__, port->idx, dmaChanUsed); | ||
378 | port->enable = 0; | ||
379 | if (port->idx == 0) { | ||
380 | /* Port A */ | ||
381 | port->_dmaInterruptCH0 = dmaChanUsed & 0x01; | ||
382 | port->_dmaInterruptCH1 = dmaChanUsed & 0x02; | ||
383 | |||
384 | port->DMA_CHAN0_ADDR_LOW = DMA_PORTA_CHAN0_ADDR_LOW; | ||
385 | port->DMA_CHAN0_ADDR_HI = DMA_PORTA_CHAN0_ADDR_HI; | ||
386 | port->DMA_CHAN0_TRANS_STATE = DMA_PORTA_CHAN0_TRANS_STATE; | ||
387 | port->DMA_CHAN0_CONTROL = DMA_PORTA_CHAN0_CONTROL; | ||
388 | port->DMA_CHAN1_ADDR_LOW = DMA_PORTA_CHAN1_ADDR_LOW; | ||
389 | port->DMA_CHAN1_ADDR_HI = DMA_PORTA_CHAN1_ADDR_HI; | ||
390 | port->DMA_CHAN1_TRANS_STATE = DMA_PORTA_CHAN1_TRANS_STATE; | ||
391 | port->DMA_CHAN1_CONTROL = DMA_PORTA_CHAN1_CONTROL; | ||
392 | port->DMA_MANAGEMENT = DMA_PORTA_MANAGEMENT; | ||
393 | } else { | ||
394 | /* Port B */ | ||
395 | port->_dmaInterruptCH0 = (dmaChanUsed << 2) & 0x04; | ||
396 | port->_dmaInterruptCH1 = (dmaChanUsed << 2) & 0x08; | ||
397 | |||
398 | port->DMA_CHAN0_ADDR_LOW = DMA_PORTB_CHAN0_ADDR_LOW; | ||
399 | port->DMA_CHAN0_ADDR_HI = DMA_PORTB_CHAN0_ADDR_HI; | ||
400 | port->DMA_CHAN0_TRANS_STATE = DMA_PORTB_CHAN0_TRANS_STATE; | ||
401 | port->DMA_CHAN0_CONTROL = DMA_PORTB_CHAN0_CONTROL; | ||
402 | port->DMA_CHAN1_ADDR_LOW = DMA_PORTB_CHAN1_ADDR_LOW; | ||
403 | port->DMA_CHAN1_ADDR_HI = DMA_PORTB_CHAN1_ADDR_HI; | ||
404 | port->DMA_CHAN1_TRANS_STATE = DMA_PORTB_CHAN1_TRANS_STATE; | ||
405 | port->DMA_CHAN1_CONTROL = DMA_PORTB_CHAN1_CONTROL; | ||
406 | port->DMA_MANAGEMENT = DMA_PORTB_MANAGEMENT; | ||
407 | } | ||
408 | |||
409 | if (port->_dmaInterruptCH0) { | ||
410 | port->cpu_addr[0] = pci_alloc_consistent(port->dev->pci_dev, | ||
411 | SMI_TS_DMA_BUF_SIZE, | ||
412 | &port->dma_addr[0]); | ||
413 | if (!port->cpu_addr[0]) { | ||
414 | dev_err(&port->dev->pci_dev->dev, | ||
415 | "Port[%d] DMA CH0 memory allocation failed!\n", | ||
416 | port->idx); | ||
417 | goto err; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | if (port->_dmaInterruptCH1) { | ||
422 | port->cpu_addr[1] = pci_alloc_consistent(port->dev->pci_dev, | ||
423 | SMI_TS_DMA_BUF_SIZE, | ||
424 | &port->dma_addr[1]); | ||
425 | if (!port->cpu_addr[1]) { | ||
426 | dev_err(&port->dev->pci_dev->dev, | ||
427 | "Port[%d] DMA CH1 memory allocation failed!\n", | ||
428 | port->idx); | ||
429 | goto err; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | smi_port_disableInterrupt(port); | ||
434 | tasklet_init(&port->tasklet, smi_dma_xfer, (unsigned long)port); | ||
435 | tasklet_disable(&port->tasklet); | ||
436 | port->enable = 1; | ||
437 | return 0; | ||
438 | err: | ||
439 | smi_port_dma_free(port); | ||
440 | return -ENOMEM; | ||
441 | } | ||
442 | |||
443 | static void smi_port_exit(struct smi_port *port) | ||
444 | { | ||
445 | smi_port_disableInterrupt(port); | ||
446 | tasklet_kill(&port->tasklet); | ||
447 | smi_port_dma_free(port); | ||
448 | port->enable = 0; | ||
449 | } | ||
450 | |||
451 | static void smi_port_irq(struct smi_port *port, u32 int_status) | ||
452 | { | ||
453 | u32 port_req_irq = port->_dmaInterruptCH0 | port->_dmaInterruptCH1; | ||
454 | |||
455 | if (int_status & port_req_irq) { | ||
456 | smi_port_disableInterrupt(port); | ||
457 | port->_int_status = int_status; | ||
458 | smi_port_clearInterrupt(port); | ||
459 | tasklet_schedule(&port->tasklet); | ||
460 | } | ||
461 | } | ||
462 | |||
463 | static irqreturn_t smi_irq_handler(int irq, void *dev_id) | ||
464 | { | ||
465 | struct smi_dev *dev = dev_id; | ||
466 | struct smi_port *port0 = &dev->ts_port[0]; | ||
467 | struct smi_port *port1 = &dev->ts_port[1]; | ||
468 | |||
469 | u32 intr_status = smi_read(MSI_INT_STATUS); | ||
470 | |||
471 | /* ts0 interrupt.*/ | ||
472 | if (dev->info->ts_0) | ||
473 | smi_port_irq(port0, intr_status); | ||
474 | |||
475 | /* ts1 interrupt.*/ | ||
476 | if (dev->info->ts_1) | ||
477 | smi_port_irq(port1, intr_status); | ||
478 | |||
479 | return IRQ_HANDLED; | ||
480 | } | ||
481 | |||
482 | static struct i2c_client *smi_add_i2c_client(struct i2c_adapter *adapter, | ||
483 | struct i2c_board_info *info) | ||
484 | { | ||
485 | struct i2c_client *client; | ||
486 | |||
487 | request_module(info->type); | ||
488 | client = i2c_new_device(adapter, info); | ||
489 | if (client == NULL || client->dev.driver == NULL) | ||
490 | goto err_add_i2c_client; | ||
491 | |||
492 | if (!try_module_get(client->dev.driver->owner)) { | ||
493 | i2c_unregister_device(client); | ||
494 | goto err_add_i2c_client; | ||
495 | } | ||
496 | return client; | ||
497 | |||
498 | err_add_i2c_client: | ||
499 | client = NULL; | ||
500 | return client; | ||
501 | } | ||
502 | |||
503 | static void smi_del_i2c_client(struct i2c_client *client) | ||
504 | { | ||
505 | module_put(client->dev.driver->owner); | ||
506 | i2c_unregister_device(client); | ||
507 | } | ||
508 | |||
509 | static const struct m88ds3103_config smi_dvbsky_m88ds3103_cfg = { | ||
510 | .i2c_addr = 0x68, | ||
511 | .clock = 27000000, | ||
512 | .i2c_wr_max = 33, | ||
513 | .clock_out = 0, | ||
514 | .ts_mode = M88DS3103_TS_PARALLEL, | ||
515 | .ts_clk = 16000, | ||
516 | .ts_clk_pol = 1, | ||
517 | .agc = 0x99, | ||
518 | .lnb_hv_pol = 0, | ||
519 | .lnb_en_pol = 1, | ||
520 | }; | ||
521 | |||
522 | static int smi_dvbsky_m88ds3103_fe_attach(struct smi_port *port) | ||
523 | { | ||
524 | int ret = 0; | ||
525 | struct smi_dev *dev = port->dev; | ||
526 | struct i2c_adapter *i2c; | ||
527 | /* tuner I2C module */ | ||
528 | struct i2c_adapter *tuner_i2c_adapter; | ||
529 | struct i2c_client *tuner_client; | ||
530 | struct i2c_board_info tuner_info; | ||
531 | struct m88ts2022_config m88ts2022_config = { | ||
532 | .clock = 27000000, | ||
533 | }; | ||
534 | memset(&tuner_info, 0, sizeof(struct i2c_board_info)); | ||
535 | i2c = (port->idx == 0) ? &dev->i2c_bus[0] : &dev->i2c_bus[1]; | ||
536 | |||
537 | /* attach demod */ | ||
538 | port->fe = dvb_attach(m88ds3103_attach, | ||
539 | &smi_dvbsky_m88ds3103_cfg, i2c, &tuner_i2c_adapter); | ||
540 | if (!port->fe) { | ||
541 | ret = -ENODEV; | ||
542 | return ret; | ||
543 | } | ||
544 | /* attach tuner */ | ||
545 | m88ts2022_config.fe = port->fe; | ||
546 | strlcpy(tuner_info.type, "m88ts2022", I2C_NAME_SIZE); | ||
547 | tuner_info.addr = 0x60; | ||
548 | tuner_info.platform_data = &m88ts2022_config; | ||
549 | tuner_client = smi_add_i2c_client(tuner_i2c_adapter, &tuner_info); | ||
550 | if (!tuner_client) { | ||
551 | ret = -ENODEV; | ||
552 | goto err_tuner_i2c_device; | ||
553 | } | ||
554 | |||
555 | /* delegate signal strength measurement to tuner */ | ||
556 | port->fe->ops.read_signal_strength = | ||
557 | port->fe->ops.tuner_ops.get_rf_strength; | ||
558 | |||
559 | port->i2c_client_tuner = tuner_client; | ||
560 | return ret; | ||
561 | |||
562 | err_tuner_i2c_device: | ||
563 | dvb_frontend_detach(port->fe); | ||
564 | return ret; | ||
565 | } | ||
566 | |||
567 | static const struct m88ds3103_config smi_dvbsky_m88rs6000_cfg = { | ||
568 | .i2c_addr = 0x69, | ||
569 | .clock = 27000000, | ||
570 | .i2c_wr_max = 33, | ||
571 | .ts_mode = M88DS3103_TS_PARALLEL, | ||
572 | .ts_clk = 16000, | ||
573 | .ts_clk_pol = 1, | ||
574 | .agc = 0x99, | ||
575 | .lnb_hv_pol = 0, | ||
576 | .lnb_en_pol = 1, | ||
577 | }; | ||
578 | |||
579 | static int smi_dvbsky_m88rs6000_fe_attach(struct smi_port *port) | ||
580 | { | ||
581 | int ret = 0; | ||
582 | struct smi_dev *dev = port->dev; | ||
583 | struct i2c_adapter *i2c; | ||
584 | /* tuner I2C module */ | ||
585 | struct i2c_adapter *tuner_i2c_adapter; | ||
586 | struct i2c_client *tuner_client; | ||
587 | struct i2c_board_info tuner_info; | ||
588 | struct m88rs6000t_config m88rs6000t_config; | ||
589 | |||
590 | memset(&tuner_info, 0, sizeof(struct i2c_board_info)); | ||
591 | i2c = (port->idx == 0) ? &dev->i2c_bus[0] : &dev->i2c_bus[1]; | ||
592 | |||
593 | /* attach demod */ | ||
594 | port->fe = dvb_attach(m88ds3103_attach, | ||
595 | &smi_dvbsky_m88rs6000_cfg, i2c, &tuner_i2c_adapter); | ||
596 | if (!port->fe) { | ||
597 | ret = -ENODEV; | ||
598 | return ret; | ||
599 | } | ||
600 | /* attach tuner */ | ||
601 | m88rs6000t_config.fe = port->fe; | ||
602 | strlcpy(tuner_info.type, "m88rs6000t", I2C_NAME_SIZE); | ||
603 | tuner_info.addr = 0x21; | ||
604 | tuner_info.platform_data = &m88rs6000t_config; | ||
605 | tuner_client = smi_add_i2c_client(tuner_i2c_adapter, &tuner_info); | ||
606 | if (!tuner_client) { | ||
607 | ret = -ENODEV; | ||
608 | goto err_tuner_i2c_device; | ||
609 | } | ||
610 | |||
611 | /* delegate signal strength measurement to tuner */ | ||
612 | port->fe->ops.read_signal_strength = | ||
613 | port->fe->ops.tuner_ops.get_rf_strength; | ||
614 | |||
615 | port->i2c_client_tuner = tuner_client; | ||
616 | return ret; | ||
617 | |||
618 | err_tuner_i2c_device: | ||
619 | dvb_frontend_detach(port->fe); | ||
620 | return ret; | ||
621 | } | ||
622 | |||
623 | static int smi_dvbsky_sit2_fe_attach(struct smi_port *port) | ||
624 | { | ||
625 | int ret = 0; | ||
626 | struct smi_dev *dev = port->dev; | ||
627 | struct i2c_adapter *i2c; | ||
628 | struct i2c_adapter *tuner_i2c_adapter; | ||
629 | struct i2c_client *client_tuner, *client_demod; | ||
630 | struct i2c_board_info client_info; | ||
631 | struct si2168_config si2168_config; | ||
632 | struct si2157_config si2157_config; | ||
633 | |||
634 | /* select i2c bus */ | ||
635 | i2c = (port->idx == 0) ? &dev->i2c_bus[0] : &dev->i2c_bus[1]; | ||
636 | |||
637 | /* attach demod */ | ||
638 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
639 | si2168_config.i2c_adapter = &tuner_i2c_adapter; | ||
640 | si2168_config.fe = &port->fe; | ||
641 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | ||
642 | |||
643 | memset(&client_info, 0, sizeof(struct i2c_board_info)); | ||
644 | strlcpy(client_info.type, "si2168", I2C_NAME_SIZE); | ||
645 | client_info.addr = 0x64; | ||
646 | client_info.platform_data = &si2168_config; | ||
647 | |||
648 | client_demod = smi_add_i2c_client(i2c, &client_info); | ||
649 | if (!client_demod) { | ||
650 | ret = -ENODEV; | ||
651 | return ret; | ||
652 | } | ||
653 | port->i2c_client_demod = client_demod; | ||
654 | |||
655 | /* attach tuner */ | ||
656 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
657 | si2157_config.fe = port->fe; | ||
658 | |||
659 | memset(&client_info, 0, sizeof(struct i2c_board_info)); | ||
660 | strlcpy(client_info.type, "si2157", I2C_NAME_SIZE); | ||
661 | client_info.addr = 0x60; | ||
662 | client_info.platform_data = &si2157_config; | ||
663 | |||
664 | client_tuner = smi_add_i2c_client(tuner_i2c_adapter, &client_info); | ||
665 | if (!client_tuner) { | ||
666 | smi_del_i2c_client(port->i2c_client_demod); | ||
667 | port->i2c_client_demod = NULL; | ||
668 | ret = -ENODEV; | ||
669 | return ret; | ||
670 | } | ||
671 | port->i2c_client_tuner = client_tuner; | ||
672 | return ret; | ||
673 | } | ||
674 | |||
675 | static int smi_fe_init(struct smi_port *port) | ||
676 | { | ||
677 | int ret = 0; | ||
678 | struct smi_dev *dev = port->dev; | ||
679 | struct dvb_adapter *adap = &port->dvb_adapter; | ||
680 | u8 mac_ee[16]; | ||
681 | |||
682 | dev_dbg(&port->dev->pci_dev->dev, | ||
683 | "%s: port %d, fe_type = %d\n", | ||
684 | __func__, port->idx, port->fe_type); | ||
685 | switch (port->fe_type) { | ||
686 | case DVBSKY_FE_M88DS3103: | ||
687 | ret = smi_dvbsky_m88ds3103_fe_attach(port); | ||
688 | break; | ||
689 | case DVBSKY_FE_M88RS6000: | ||
690 | ret = smi_dvbsky_m88rs6000_fe_attach(port); | ||
691 | break; | ||
692 | case DVBSKY_FE_SIT2: | ||
693 | ret = smi_dvbsky_sit2_fe_attach(port); | ||
694 | break; | ||
695 | } | ||
696 | if (ret < 0) | ||
697 | return ret; | ||
698 | |||
699 | /* register dvb frontend */ | ||
700 | ret = dvb_register_frontend(adap, port->fe); | ||
701 | if (ret < 0) { | ||
702 | if (port->i2c_client_tuner) | ||
703 | smi_del_i2c_client(port->i2c_client_tuner); | ||
704 | if (port->i2c_client_demod) | ||
705 | smi_del_i2c_client(port->i2c_client_demod); | ||
706 | dvb_frontend_detach(port->fe); | ||
707 | return ret; | ||
708 | } | ||
709 | /* init MAC.*/ | ||
710 | ret = smi_read_eeprom(&dev->i2c_bus[0], 0xc0, mac_ee, 16); | ||
711 | dev_info(&port->dev->pci_dev->dev, | ||
712 | "DVBSky SMI PCIe MAC= %pM\n", mac_ee + (port->idx)*8); | ||
713 | memcpy(adap->proposed_mac, mac_ee + (port->idx)*8, 6); | ||
714 | return ret; | ||
715 | } | ||
716 | |||
717 | static void smi_fe_exit(struct smi_port *port) | ||
718 | { | ||
719 | dvb_unregister_frontend(port->fe); | ||
720 | /* remove I2C demod and tuner */ | ||
721 | if (port->i2c_client_tuner) | ||
722 | smi_del_i2c_client(port->i2c_client_tuner); | ||
723 | if (port->i2c_client_demod) | ||
724 | smi_del_i2c_client(port->i2c_client_demod); | ||
725 | dvb_frontend_detach(port->fe); | ||
726 | } | ||
727 | |||
728 | static int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id, | ||
729 | int (*start_feed)(struct dvb_demux_feed *), | ||
730 | int (*stop_feed)(struct dvb_demux_feed *), | ||
731 | void *priv) | ||
732 | { | ||
733 | dvbdemux->priv = priv; | ||
734 | |||
735 | dvbdemux->filternum = 256; | ||
736 | dvbdemux->feednum = 256; | ||
737 | dvbdemux->start_feed = start_feed; | ||
738 | dvbdemux->stop_feed = stop_feed; | ||
739 | dvbdemux->write_to_decoder = NULL; | ||
740 | dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | | ||
741 | DMX_SECTION_FILTERING | | ||
742 | DMX_MEMORY_BASED_FILTERING); | ||
743 | return dvb_dmx_init(dvbdemux); | ||
744 | } | ||
745 | |||
746 | static int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev, | ||
747 | struct dvb_demux *dvbdemux, | ||
748 | struct dmx_frontend *hw_frontend, | ||
749 | struct dmx_frontend *mem_frontend, | ||
750 | struct dvb_adapter *dvb_adapter) | ||
751 | { | ||
752 | int ret; | ||
753 | |||
754 | dmxdev->filternum = 256; | ||
755 | dmxdev->demux = &dvbdemux->dmx; | ||
756 | dmxdev->capabilities = 0; | ||
757 | ret = dvb_dmxdev_init(dmxdev, dvb_adapter); | ||
758 | if (ret < 0) | ||
759 | return ret; | ||
760 | |||
761 | hw_frontend->source = DMX_FRONTEND_0; | ||
762 | dvbdemux->dmx.add_frontend(&dvbdemux->dmx, hw_frontend); | ||
763 | mem_frontend->source = DMX_MEMORY_FE; | ||
764 | dvbdemux->dmx.add_frontend(&dvbdemux->dmx, mem_frontend); | ||
765 | return dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, hw_frontend); | ||
766 | } | ||
767 | |||
768 | static u32 smi_config_DMA(struct smi_port *port) | ||
769 | { | ||
770 | struct smi_dev *dev = port->dev; | ||
771 | u32 totalLength = 0, dmaMemPtrLow, dmaMemPtrHi, dmaCtlReg; | ||
772 | u8 chanLatencyTimer = 0, dmaChanEnable = 1, dmaTransStart = 1; | ||
773 | u32 dmaManagement = 0, tlpTransUnit = DMA_TRANS_UNIT_188; | ||
774 | u8 tlpTc = 0, tlpTd = 1, tlpEp = 0, tlpAttr = 0; | ||
775 | u64 mem; | ||
776 | |||
777 | dmaManagement = smi_read(port->DMA_MANAGEMENT); | ||
778 | /* Setup Channel-0 */ | ||
779 | if (port->_dmaInterruptCH0) { | ||
780 | totalLength = SMI_TS_DMA_BUF_SIZE; | ||
781 | mem = port->dma_addr[0]; | ||
782 | dmaMemPtrLow = mem & 0xffffffff; | ||
783 | dmaMemPtrHi = mem >> 32; | ||
784 | dmaCtlReg = (totalLength) | (tlpTransUnit << 22) | (tlpTc << 25) | ||
785 | | (tlpTd << 28) | (tlpEp << 29) | (tlpAttr << 30); | ||
786 | dmaManagement |= dmaChanEnable | (dmaTransStart << 1) | ||
787 | | (chanLatencyTimer << 8); | ||
788 | /* write DMA register, start DMA engine */ | ||
789 | smi_write(port->DMA_CHAN0_ADDR_LOW, dmaMemPtrLow); | ||
790 | smi_write(port->DMA_CHAN0_ADDR_HI, dmaMemPtrHi); | ||
791 | smi_write(port->DMA_CHAN0_CONTROL, dmaCtlReg); | ||
792 | } | ||
793 | /* Setup Channel-1 */ | ||
794 | if (port->_dmaInterruptCH1) { | ||
795 | totalLength = SMI_TS_DMA_BUF_SIZE; | ||
796 | mem = port->dma_addr[1]; | ||
797 | dmaMemPtrLow = mem & 0xffffffff; | ||
798 | dmaMemPtrHi = mem >> 32; | ||
799 | dmaCtlReg = (totalLength) | (tlpTransUnit << 22) | (tlpTc << 25) | ||
800 | | (tlpTd << 28) | (tlpEp << 29) | (tlpAttr << 30); | ||
801 | dmaManagement |= (dmaChanEnable << 16) | (dmaTransStart << 17) | ||
802 | | (chanLatencyTimer << 24); | ||
803 | /* write DMA register, start DMA engine */ | ||
804 | smi_write(port->DMA_CHAN1_ADDR_LOW, dmaMemPtrLow); | ||
805 | smi_write(port->DMA_CHAN1_ADDR_HI, dmaMemPtrHi); | ||
806 | smi_write(port->DMA_CHAN1_CONTROL, dmaCtlReg); | ||
807 | } | ||
808 | return dmaManagement; | ||
809 | } | ||
810 | |||
811 | static int smi_start_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
812 | { | ||
813 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | ||
814 | struct smi_port *port = dvbdmx->priv; | ||
815 | struct smi_dev *dev = port->dev; | ||
816 | u32 dmaManagement; | ||
817 | |||
818 | if (port->users++ == 0) { | ||
819 | dmaManagement = smi_config_DMA(port); | ||
820 | smi_port_clearInterrupt(port); | ||
821 | smi_port_enableInterrupt(port); | ||
822 | smi_write(port->DMA_MANAGEMENT, dmaManagement); | ||
823 | tasklet_enable(&port->tasklet); | ||
824 | } | ||
825 | return port->users; | ||
826 | } | ||
827 | |||
828 | static int smi_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
829 | { | ||
830 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | ||
831 | struct smi_port *port = dvbdmx->priv; | ||
832 | struct smi_dev *dev = port->dev; | ||
833 | |||
834 | if (--port->users) | ||
835 | return port->users; | ||
836 | |||
837 | tasklet_disable(&port->tasklet); | ||
838 | smi_port_disableInterrupt(port); | ||
839 | smi_clear(port->DMA_MANAGEMENT, 0x30003); | ||
840 | return 0; | ||
841 | } | ||
842 | |||
843 | static int smi_dvb_init(struct smi_port *port) | ||
844 | { | ||
845 | int ret; | ||
846 | struct dvb_adapter *adap = &port->dvb_adapter; | ||
847 | struct dvb_demux *dvbdemux = &port->demux; | ||
848 | |||
849 | dev_dbg(&port->dev->pci_dev->dev, | ||
850 | "%s, port %d\n", __func__, port->idx); | ||
851 | |||
852 | ret = dvb_register_adapter(adap, "SMI_DVB", THIS_MODULE, | ||
853 | &port->dev->pci_dev->dev, | ||
854 | adapter_nr); | ||
855 | if (ret < 0) { | ||
856 | dev_err(&port->dev->pci_dev->dev, "Fail to register DVB adapter.\n"); | ||
857 | return ret; | ||
858 | } | ||
859 | ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux", | ||
860 | smi_start_feed, | ||
861 | smi_stop_feed, port); | ||
862 | if (ret < 0) | ||
863 | goto err_del_dvb_register_adapter; | ||
864 | |||
865 | ret = my_dvb_dmxdev_ts_card_init(&port->dmxdev, &port->demux, | ||
866 | &port->hw_frontend, | ||
867 | &port->mem_frontend, adap); | ||
868 | if (ret < 0) | ||
869 | goto err_del_dvb_dmx; | ||
870 | |||
871 | ret = dvb_net_init(adap, &port->dvbnet, port->dmxdev.demux); | ||
872 | if (ret < 0) | ||
873 | goto err_del_dvb_dmxdev; | ||
874 | return 0; | ||
875 | err_del_dvb_dmxdev: | ||
876 | dvbdemux->dmx.close(&dvbdemux->dmx); | ||
877 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &port->hw_frontend); | ||
878 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &port->mem_frontend); | ||
879 | dvb_dmxdev_release(&port->dmxdev); | ||
880 | err_del_dvb_dmx: | ||
881 | dvb_dmx_release(&port->demux); | ||
882 | err_del_dvb_register_adapter: | ||
883 | dvb_unregister_adapter(&port->dvb_adapter); | ||
884 | return ret; | ||
885 | } | ||
886 | |||
887 | static void smi_dvb_exit(struct smi_port *port) | ||
888 | { | ||
889 | struct dvb_demux *dvbdemux = &port->demux; | ||
890 | |||
891 | dvb_net_release(&port->dvbnet); | ||
892 | |||
893 | dvbdemux->dmx.close(&dvbdemux->dmx); | ||
894 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &port->hw_frontend); | ||
895 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &port->mem_frontend); | ||
896 | dvb_dmxdev_release(&port->dmxdev); | ||
897 | dvb_dmx_release(&port->demux); | ||
898 | |||
899 | dvb_unregister_adapter(&port->dvb_adapter); | ||
900 | } | ||
901 | |||
902 | static int smi_port_attach(struct smi_dev *dev, | ||
903 | struct smi_port *port, int index) | ||
904 | { | ||
905 | int ret, dmachs; | ||
906 | |||
907 | port->dev = dev; | ||
908 | port->idx = index; | ||
909 | port->fe_type = (index == 0) ? dev->info->fe_0 : dev->info->fe_1; | ||
910 | dmachs = (index == 0) ? dev->info->ts_0 : dev->info->ts_1; | ||
911 | /* port init.*/ | ||
912 | ret = smi_port_init(port, dmachs); | ||
913 | if (ret < 0) | ||
914 | return ret; | ||
915 | /* dvb init.*/ | ||
916 | ret = smi_dvb_init(port); | ||
917 | if (ret < 0) | ||
918 | goto err_del_port_init; | ||
919 | /* fe init.*/ | ||
920 | ret = smi_fe_init(port); | ||
921 | if (ret < 0) | ||
922 | goto err_del_dvb_init; | ||
923 | return 0; | ||
924 | err_del_dvb_init: | ||
925 | smi_dvb_exit(port); | ||
926 | err_del_port_init: | ||
927 | smi_port_exit(port); | ||
928 | return ret; | ||
929 | } | ||
930 | |||
931 | static void smi_port_detach(struct smi_port *port) | ||
932 | { | ||
933 | smi_fe_exit(port); | ||
934 | smi_dvb_exit(port); | ||
935 | smi_port_exit(port); | ||
936 | } | ||
937 | |||
938 | static int smi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | ||
939 | { | ||
940 | struct smi_dev *dev; | ||
941 | int ret = -ENOMEM; | ||
942 | |||
943 | if (pci_enable_device(pdev) < 0) | ||
944 | return -ENODEV; | ||
945 | |||
946 | dev = kzalloc(sizeof(struct smi_dev), GFP_KERNEL); | ||
947 | if (!dev) { | ||
948 | ret = -ENOMEM; | ||
949 | goto err_pci_disable_device; | ||
950 | } | ||
951 | |||
952 | dev->pci_dev = pdev; | ||
953 | pci_set_drvdata(pdev, dev); | ||
954 | dev->info = (struct smi_cfg_info *) id->driver_data; | ||
955 | dev_info(&dev->pci_dev->dev, | ||
956 | "card detected: %s\n", dev->info->name); | ||
957 | |||
958 | dev->nr = dev->info->type; | ||
959 | dev->lmmio = ioremap(pci_resource_start(dev->pci_dev, 0), | ||
960 | pci_resource_len(dev->pci_dev, 0)); | ||
961 | if (!dev->lmmio) { | ||
962 | ret = -ENOMEM; | ||
963 | goto err_kfree; | ||
964 | } | ||
965 | |||
966 | /* should we set to 32bit DMA? */ | ||
967 | ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | ||
968 | if (ret < 0) | ||
969 | goto err_pci_iounmap; | ||
970 | |||
971 | pci_set_master(pdev); | ||
972 | |||
973 | ret = smi_hw_init(dev); | ||
974 | if (ret < 0) | ||
975 | goto err_pci_iounmap; | ||
976 | |||
977 | ret = smi_i2c_init(dev); | ||
978 | if (ret < 0) | ||
979 | goto err_pci_iounmap; | ||
980 | |||
981 | if (dev->info->ts_0) { | ||
982 | ret = smi_port_attach(dev, &dev->ts_port[0], 0); | ||
983 | if (ret < 0) | ||
984 | goto err_del_i2c_adaptor; | ||
985 | } | ||
986 | |||
987 | if (dev->info->ts_1) { | ||
988 | ret = smi_port_attach(dev, &dev->ts_port[1], 1); | ||
989 | if (ret < 0) | ||
990 | goto err_del_port0_attach; | ||
991 | } | ||
992 | |||
993 | #ifdef CONFIG_PCI_MSI /* to do msi interrupt.???*/ | ||
994 | if (pci_msi_enabled()) | ||
995 | ret = pci_enable_msi(dev->pci_dev); | ||
996 | if (ret) | ||
997 | dev_info(&dev->pci_dev->dev, "MSI not available.\n"); | ||
998 | #endif | ||
999 | |||
1000 | ret = request_irq(dev->pci_dev->irq, smi_irq_handler, | ||
1001 | IRQF_SHARED, "SMI_PCIE", dev); | ||
1002 | if (ret < 0) | ||
1003 | goto err_del_port1_attach; | ||
1004 | |||
1005 | return 0; | ||
1006 | |||
1007 | err_del_port1_attach: | ||
1008 | if (dev->info->ts_1) | ||
1009 | smi_port_detach(&dev->ts_port[1]); | ||
1010 | err_del_port0_attach: | ||
1011 | if (dev->info->ts_0) | ||
1012 | smi_port_detach(&dev->ts_port[0]); | ||
1013 | err_del_i2c_adaptor: | ||
1014 | smi_i2c_exit(dev); | ||
1015 | err_pci_iounmap: | ||
1016 | iounmap(dev->lmmio); | ||
1017 | err_kfree: | ||
1018 | pci_set_drvdata(pdev, NULL); | ||
1019 | kfree(dev); | ||
1020 | err_pci_disable_device: | ||
1021 | pci_disable_device(pdev); | ||
1022 | return ret; | ||
1023 | } | ||
1024 | |||
1025 | static void smi_remove(struct pci_dev *pdev) | ||
1026 | { | ||
1027 | struct smi_dev *dev = pci_get_drvdata(pdev); | ||
1028 | |||
1029 | smi_write(MSI_INT_ENA_CLR, ALL_INT); | ||
1030 | free_irq(dev->pci_dev->irq, dev); | ||
1031 | #ifdef CONFIG_PCI_MSI | ||
1032 | pci_disable_msi(dev->pci_dev); | ||
1033 | #endif | ||
1034 | if (dev->info->ts_1) | ||
1035 | smi_port_detach(&dev->ts_port[1]); | ||
1036 | if (dev->info->ts_0) | ||
1037 | smi_port_detach(&dev->ts_port[0]); | ||
1038 | |||
1039 | smi_i2c_exit(dev); | ||
1040 | iounmap(dev->lmmio); | ||
1041 | pci_set_drvdata(pdev, NULL); | ||
1042 | pci_disable_device(pdev); | ||
1043 | kfree(dev); | ||
1044 | } | ||
1045 | |||
1046 | /* DVBSky cards */ | ||
1047 | static struct smi_cfg_info dvbsky_s950_cfg = { | ||
1048 | .type = SMI_DVBSKY_S950, | ||
1049 | .name = "DVBSky S950 V3", | ||
1050 | .ts_0 = SMI_TS_NULL, | ||
1051 | .ts_1 = SMI_TS_DMA_BOTH, | ||
1052 | .fe_0 = DVBSKY_FE_NULL, | ||
1053 | .fe_1 = DVBSKY_FE_M88DS3103, | ||
1054 | }; | ||
1055 | |||
1056 | static struct smi_cfg_info dvbsky_s952_cfg = { | ||
1057 | .type = SMI_DVBSKY_S952, | ||
1058 | .name = "DVBSky S952 V3", | ||
1059 | .ts_0 = SMI_TS_DMA_BOTH, | ||
1060 | .ts_1 = SMI_TS_DMA_BOTH, | ||
1061 | .fe_0 = DVBSKY_FE_M88RS6000, | ||
1062 | .fe_1 = DVBSKY_FE_M88RS6000, | ||
1063 | }; | ||
1064 | |||
1065 | static struct smi_cfg_info dvbsky_t9580_cfg = { | ||
1066 | .type = SMI_DVBSKY_T9580, | ||
1067 | .name = "DVBSky T9580 V3", | ||
1068 | .ts_0 = SMI_TS_DMA_BOTH, | ||
1069 | .ts_1 = SMI_TS_DMA_BOTH, | ||
1070 | .fe_0 = DVBSKY_FE_SIT2, | ||
1071 | .fe_1 = DVBSKY_FE_M88DS3103, | ||
1072 | }; | ||
1073 | |||
1074 | /* PCI IDs */ | ||
1075 | #define SMI_ID(_subvend, _subdev, _driverdata) { \ | ||
1076 | .vendor = SMI_VID, .device = SMI_PID, \ | ||
1077 | .subvendor = _subvend, .subdevice = _subdev, \ | ||
1078 | .driver_data = (unsigned long)&_driverdata } | ||
1079 | |||
1080 | static const struct pci_device_id smi_id_table[] = { | ||
1081 | SMI_ID(0x4254, 0x0550, dvbsky_s950_cfg), | ||
1082 | SMI_ID(0x4254, 0x0552, dvbsky_s952_cfg), | ||
1083 | SMI_ID(0x4254, 0x5580, dvbsky_t9580_cfg), | ||
1084 | {0} | ||
1085 | }; | ||
1086 | MODULE_DEVICE_TABLE(pci, smi_id_table); | ||
1087 | |||
1088 | static struct pci_driver smipcie_driver = { | ||
1089 | .name = "SMI PCIe driver", | ||
1090 | .id_table = smi_id_table, | ||
1091 | .probe = smi_probe, | ||
1092 | .remove = smi_remove, | ||
1093 | }; | ||
1094 | |||
1095 | module_pci_driver(smipcie_driver); | ||
1096 | |||
1097 | MODULE_AUTHOR("Max nibble <nibble.max@gmail.com>"); | ||
1098 | MODULE_DESCRIPTION("SMI PCIe driver"); | ||
1099 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/pci/smipcie/smipcie.h b/drivers/media/pci/smipcie/smipcie.h new file mode 100644 index 000000000000..10cdf20f4839 --- /dev/null +++ b/drivers/media/pci/smipcie/smipcie.h | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | * SMI PCIe driver for DVBSky cards. | ||
3 | * | ||
4 | * Copyright (C) 2014 Max nibble <nibble.max@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef _SMI_PCIE_H_ | ||
18 | #define _SMI_PCIE_H_ | ||
19 | |||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/i2c-algo-bit.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/proc_fs.h> | ||
27 | #include <linux/pci.h> | ||
28 | #include <linux/dma-mapping.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <media/rc-core.h> | ||
31 | |||
32 | #include "demux.h" | ||
33 | #include "dmxdev.h" | ||
34 | #include "dvb_demux.h" | ||
35 | #include "dvb_frontend.h" | ||
36 | #include "dvb_net.h" | ||
37 | #include "dvbdev.h" | ||
38 | |||
39 | /* -------- Register Base -------- */ | ||
40 | #define MSI_CONTROL_REG_BASE 0x0800 | ||
41 | #define SYSTEM_CONTROL_REG_BASE 0x0880 | ||
42 | #define PCIE_EP_DEBUG_REG_BASE 0x08C0 | ||
43 | #define IR_CONTROL_REG_BASE 0x0900 | ||
44 | #define I2C_A_CONTROL_REG_BASE 0x0940 | ||
45 | #define I2C_B_CONTROL_REG_BASE 0x0980 | ||
46 | #define ATV_PORTA_CONTROL_REG_BASE 0x09C0 | ||
47 | #define DTV_PORTA_CONTROL_REG_BASE 0x0A00 | ||
48 | #define AES_PORTA_CONTROL_REG_BASE 0x0A80 | ||
49 | #define DMA_PORTA_CONTROL_REG_BASE 0x0AC0 | ||
50 | #define ATV_PORTB_CONTROL_REG_BASE 0x0B00 | ||
51 | #define DTV_PORTB_CONTROL_REG_BASE 0x0B40 | ||
52 | #define AES_PORTB_CONTROL_REG_BASE 0x0BC0 | ||
53 | #define DMA_PORTB_CONTROL_REG_BASE 0x0C00 | ||
54 | #define UART_A_REGISTER_BASE 0x0C40 | ||
55 | #define UART_B_REGISTER_BASE 0x0C80 | ||
56 | #define GPS_CONTROL_REG_BASE 0x0CC0 | ||
57 | #define DMA_PORTC_CONTROL_REG_BASE 0x0D00 | ||
58 | #define DMA_PORTD_CONTROL_REG_BASE 0x0D00 | ||
59 | #define AES_RANDOM_DATA_BASE 0x0D80 | ||
60 | #define AES_KEY_IN_BASE 0x0D90 | ||
61 | #define RANDOM_DATA_LIB_BASE 0x0E00 | ||
62 | #define IR_DATA_BUFFER_BASE 0x0F00 | ||
63 | #define PORTA_TS_BUFFER_BASE 0x1000 | ||
64 | #define PORTA_I2S_BUFFER_BASE 0x1400 | ||
65 | #define PORTB_TS_BUFFER_BASE 0x1800 | ||
66 | #define PORTB_I2S_BUFFER_BASE 0x1C00 | ||
67 | |||
68 | /* -------- MSI control and state register -------- */ | ||
69 | #define MSI_DELAY_TIMER (MSI_CONTROL_REG_BASE + 0x00) | ||
70 | #define MSI_INT_STATUS (MSI_CONTROL_REG_BASE + 0x08) | ||
71 | #define MSI_INT_STATUS_CLR (MSI_CONTROL_REG_BASE + 0x0C) | ||
72 | #define MSI_INT_STATUS_SET (MSI_CONTROL_REG_BASE + 0x10) | ||
73 | #define MSI_INT_ENA (MSI_CONTROL_REG_BASE + 0x14) | ||
74 | #define MSI_INT_ENA_CLR (MSI_CONTROL_REG_BASE + 0x18) | ||
75 | #define MSI_INT_ENA_SET (MSI_CONTROL_REG_BASE + 0x1C) | ||
76 | #define MSI_SOFT_RESET (MSI_CONTROL_REG_BASE + 0x20) | ||
77 | #define MSI_CFG_SRC0 (MSI_CONTROL_REG_BASE + 0x24) | ||
78 | |||
79 | /* -------- Hybird Controller System Control register -------- */ | ||
80 | #define MUX_MODE_CTRL (SYSTEM_CONTROL_REG_BASE + 0x00) | ||
81 | #define rbPaMSMask 0x07 | ||
82 | #define rbPaMSDtvNoGpio 0x00 /*[2:0], DTV Simple mode */ | ||
83 | #define rbPaMSDtv4bitGpio 0x01 /*[2:0], DTV TS2 Serial mode)*/ | ||
84 | #define rbPaMSDtv7bitGpio 0x02 /*[2:0], DTV TS0 Serial mode*/ | ||
85 | #define rbPaMS8bitGpio 0x03 /*[2:0], GPIO mode selected;(8bit GPIO)*/ | ||
86 | #define rbPaMSAtv 0x04 /*[2:0], 3'b1xx: ATV mode select*/ | ||
87 | #define rbPbMSMask 0x38 | ||
88 | #define rbPbMSDtvNoGpio 0x00 /*[5:3], DTV Simple mode */ | ||
89 | #define rbPbMSDtv4bitGpio 0x08 /*[5:3], DTV TS2 Serial mode*/ | ||
90 | #define rbPbMSDtv7bitGpio 0x10 /*[5:3], DTV TS0 Serial mode*/ | ||
91 | #define rbPbMS8bitGpio 0x18 /*[5:3], GPIO mode selected;(8bit GPIO)*/ | ||
92 | #define rbPbMSAtv 0x20 /*[5:3], 3'b1xx: ATV mode select*/ | ||
93 | #define rbPaAESEN 0x40 /*[6], port A AES enable bit*/ | ||
94 | #define rbPbAESEN 0x80 /*[7], port B AES enable bit*/ | ||
95 | |||
96 | #define INTERNAL_RST (SYSTEM_CONTROL_REG_BASE + 0x04) | ||
97 | #define PERIPHERAL_CTRL (SYSTEM_CONTROL_REG_BASE + 0x08) | ||
98 | #define GPIO_0to7_CTRL (SYSTEM_CONTROL_REG_BASE + 0x0C) | ||
99 | #define GPIO_8to15_CTRL (SYSTEM_CONTROL_REG_BASE + 0x10) | ||
100 | #define GPIO_16to24_CTRL (SYSTEM_CONTROL_REG_BASE + 0x14) | ||
101 | #define GPIO_INT_SRC_CFG (SYSTEM_CONTROL_REG_BASE + 0x18) | ||
102 | #define SYS_BUF_STATUS (SYSTEM_CONTROL_REG_BASE + 0x1C) | ||
103 | #define PCIE_IP_REG_ACS (SYSTEM_CONTROL_REG_BASE + 0x20) | ||
104 | #define PCIE_IP_REG_ACS_ADDR (SYSTEM_CONTROL_REG_BASE + 0x24) | ||
105 | #define PCIE_IP_REG_ACS_DATA (SYSTEM_CONTROL_REG_BASE + 0x28) | ||
106 | |||
107 | /* -------- IR Control register -------- */ | ||
108 | #define IR_Init_Reg (IR_CONTROL_REG_BASE + 0x00) | ||
109 | #define IR_Idle_Cnt_Low (IR_CONTROL_REG_BASE + 0x04) | ||
110 | #define IR_Idle_Cnt_High (IR_CONTROL_REG_BASE + 0x05) | ||
111 | #define IR_Unit_Cnt_Low (IR_CONTROL_REG_BASE + 0x06) | ||
112 | #define IR_Unit_Cnt_High (IR_CONTROL_REG_BASE + 0x07) | ||
113 | #define IR_Data_Cnt (IR_CONTROL_REG_BASE + 0x08) | ||
114 | #define rbIRen 0x80 | ||
115 | #define rbIRhighidle 0x10 | ||
116 | #define rbIRlowidle 0x00 | ||
117 | #define rbIRVld 0x04 | ||
118 | |||
119 | /* -------- I2C A control and state register -------- */ | ||
120 | #define I2C_A_CTL_STATUS (I2C_A_CONTROL_REG_BASE + 0x00) | ||
121 | #define I2C_A_ADDR (I2C_A_CONTROL_REG_BASE + 0x04) | ||
122 | #define I2C_A_SW_CTL (I2C_A_CONTROL_REG_BASE + 0x08) | ||
123 | #define I2C_A_TIME_OUT_CNT (I2C_A_CONTROL_REG_BASE + 0x0C) | ||
124 | #define I2C_A_FIFO_STATUS (I2C_A_CONTROL_REG_BASE + 0x10) | ||
125 | #define I2C_A_FS_EN (I2C_A_CONTROL_REG_BASE + 0x14) | ||
126 | #define I2C_A_FIFO_DATA (I2C_A_CONTROL_REG_BASE + 0x20) | ||
127 | |||
128 | /* -------- I2C B control and state register -------- */ | ||
129 | #define I2C_B_CTL_STATUS (I2C_B_CONTROL_REG_BASE + 0x00) | ||
130 | #define I2C_B_ADDR (I2C_B_CONTROL_REG_BASE + 0x04) | ||
131 | #define I2C_B_SW_CTL (I2C_B_CONTROL_REG_BASE + 0x08) | ||
132 | #define I2C_B_TIME_OUT_CNT (I2C_B_CONTROL_REG_BASE + 0x0C) | ||
133 | #define I2C_B_FIFO_STATUS (I2C_B_CONTROL_REG_BASE + 0x10) | ||
134 | #define I2C_B_FS_EN (I2C_B_CONTROL_REG_BASE + 0x14) | ||
135 | #define I2C_B_FIFO_DATA (I2C_B_CONTROL_REG_BASE + 0x20) | ||
136 | |||
137 | #define VIDEO_CTRL_STATUS_A (ATV_PORTA_CONTROL_REG_BASE + 0x04) | ||
138 | |||
139 | /* -------- Digital TV control register, Port A -------- */ | ||
140 | #define MPEG2_CTRL_A (DTV_PORTA_CONTROL_REG_BASE + 0x00) | ||
141 | #define SERIAL_IN_ADDR_A (DTV_PORTA_CONTROL_REG_BASE + 0x4C) | ||
142 | #define VLD_CNT_ADDR_A (DTV_PORTA_CONTROL_REG_BASE + 0x60) | ||
143 | #define ERR_CNT_ADDR_A (DTV_PORTA_CONTROL_REG_BASE + 0x64) | ||
144 | #define BRD_CNT_ADDR_A (DTV_PORTA_CONTROL_REG_BASE + 0x68) | ||
145 | |||
146 | /* -------- DMA Control Register, Port A -------- */ | ||
147 | #define DMA_PORTA_CHAN0_ADDR_LOW (DMA_PORTA_CONTROL_REG_BASE + 0x00) | ||
148 | #define DMA_PORTA_CHAN0_ADDR_HI (DMA_PORTA_CONTROL_REG_BASE + 0x04) | ||
149 | #define DMA_PORTA_CHAN0_TRANS_STATE (DMA_PORTA_CONTROL_REG_BASE + 0x08) | ||
150 | #define DMA_PORTA_CHAN0_CONTROL (DMA_PORTA_CONTROL_REG_BASE + 0x0C) | ||
151 | #define DMA_PORTA_CHAN1_ADDR_LOW (DMA_PORTA_CONTROL_REG_BASE + 0x10) | ||
152 | #define DMA_PORTA_CHAN1_ADDR_HI (DMA_PORTA_CONTROL_REG_BASE + 0x14) | ||
153 | #define DMA_PORTA_CHAN1_TRANS_STATE (DMA_PORTA_CONTROL_REG_BASE + 0x18) | ||
154 | #define DMA_PORTA_CHAN1_CONTROL (DMA_PORTA_CONTROL_REG_BASE + 0x1C) | ||
155 | #define DMA_PORTA_MANAGEMENT (DMA_PORTA_CONTROL_REG_BASE + 0x20) | ||
156 | #define VIDEO_CTRL_STATUS_B (ATV_PORTB_CONTROL_REG_BASE + 0x04) | ||
157 | |||
158 | /* -------- Digital TV control register, Port B -------- */ | ||
159 | #define MPEG2_CTRL_B (DTV_PORTB_CONTROL_REG_BASE + 0x00) | ||
160 | #define SERIAL_IN_ADDR_B (DTV_PORTB_CONTROL_REG_BASE + 0x4C) | ||
161 | #define VLD_CNT_ADDR_B (DTV_PORTB_CONTROL_REG_BASE + 0x60) | ||
162 | #define ERR_CNT_ADDR_B (DTV_PORTB_CONTROL_REG_BASE + 0x64) | ||
163 | #define BRD_CNT_ADDR_B (DTV_PORTB_CONTROL_REG_BASE + 0x68) | ||
164 | |||
165 | /* -------- AES control register, Port B -------- */ | ||
166 | #define AES_CTRL_B (AES_PORTB_CONTROL_REG_BASE + 0x00) | ||
167 | #define AES_KEY_BASE_B (AES_PORTB_CONTROL_REG_BASE + 0x04) | ||
168 | |||
169 | /* -------- DMA Control Register, Port B -------- */ | ||
170 | #define DMA_PORTB_CHAN0_ADDR_LOW (DMA_PORTB_CONTROL_REG_BASE + 0x00) | ||
171 | #define DMA_PORTB_CHAN0_ADDR_HI (DMA_PORTB_CONTROL_REG_BASE + 0x04) | ||
172 | #define DMA_PORTB_CHAN0_TRANS_STATE (DMA_PORTB_CONTROL_REG_BASE + 0x08) | ||
173 | #define DMA_PORTB_CHAN0_CONTROL (DMA_PORTB_CONTROL_REG_BASE + 0x0C) | ||
174 | #define DMA_PORTB_CHAN1_ADDR_LOW (DMA_PORTB_CONTROL_REG_BASE + 0x10) | ||
175 | #define DMA_PORTB_CHAN1_ADDR_HI (DMA_PORTB_CONTROL_REG_BASE + 0x14) | ||
176 | #define DMA_PORTB_CHAN1_TRANS_STATE (DMA_PORTB_CONTROL_REG_BASE + 0x18) | ||
177 | #define DMA_PORTB_CHAN1_CONTROL (DMA_PORTB_CONTROL_REG_BASE + 0x1C) | ||
178 | #define DMA_PORTB_MANAGEMENT (DMA_PORTB_CONTROL_REG_BASE + 0x20) | ||
179 | |||
180 | #define DMA_TRANS_UNIT_188 (0x00000007) | ||
181 | |||
182 | /* -------- Macro define of 24 interrupt resource --------*/ | ||
183 | #define DMA_A_CHAN0_DONE_INT (0x00000001) | ||
184 | #define DMA_A_CHAN1_DONE_INT (0x00000002) | ||
185 | #define DMA_B_CHAN0_DONE_INT (0x00000004) | ||
186 | #define DMA_B_CHAN1_DONE_INT (0x00000008) | ||
187 | #define DMA_C_CHAN0_DONE_INT (0x00000010) | ||
188 | #define DMA_C_CHAN1_DONE_INT (0x00000020) | ||
189 | #define DMA_D_CHAN0_DONE_INT (0x00000040) | ||
190 | #define DMA_D_CHAN1_DONE_INT (0x00000080) | ||
191 | #define DATA_BUF_OVERFLOW_INT (0x00000100) | ||
192 | #define UART_0_X_INT (0x00000200) | ||
193 | #define UART_1_X_INT (0x00000400) | ||
194 | #define IR_X_INT (0x00000800) | ||
195 | #define GPIO_0_INT (0x00001000) | ||
196 | #define GPIO_1_INT (0x00002000) | ||
197 | #define GPIO_2_INT (0x00004000) | ||
198 | #define GPIO_3_INT (0x00008000) | ||
199 | #define ALL_INT (0x0000FFFF) | ||
200 | |||
201 | /* software I2C bit mask */ | ||
202 | #define SW_I2C_MSK_MODE 0x01 | ||
203 | #define SW_I2C_MSK_CLK_OUT 0x02 | ||
204 | #define SW_I2C_MSK_DAT_OUT 0x04 | ||
205 | #define SW_I2C_MSK_CLK_EN 0x08 | ||
206 | #define SW_I2C_MSK_DAT_EN 0x10 | ||
207 | #define SW_I2C_MSK_DAT_IN 0x40 | ||
208 | #define SW_I2C_MSK_CLK_IN 0x80 | ||
209 | |||
210 | #define SMI_VID 0x1ADE | ||
211 | #define SMI_PID 0x3038 | ||
212 | #define SMI_TS_DMA_BUF_SIZE (1024 * 188) | ||
213 | |||
214 | struct smi_cfg_info { | ||
215 | #define SMI_DVBSKY_S952 0 | ||
216 | #define SMI_DVBSKY_S950 1 | ||
217 | #define SMI_DVBSKY_T9580 2 | ||
218 | #define SMI_DVBSKY_T982 3 | ||
219 | int type; | ||
220 | char *name; | ||
221 | #define SMI_TS_NULL 0 | ||
222 | #define SMI_TS_DMA_SINGLE 1 | ||
223 | #define SMI_TS_DMA_BOTH 3 | ||
224 | /* SMI_TS_NULL: not use; | ||
225 | * SMI_TS_DMA_SINGLE: use DMA 0 only; | ||
226 | * SMI_TS_DMA_BOTH:use DMA 0 and 1.*/ | ||
227 | int ts_0; | ||
228 | int ts_1; | ||
229 | #define DVBSKY_FE_NULL 0 | ||
230 | #define DVBSKY_FE_M88RS6000 1 | ||
231 | #define DVBSKY_FE_M88DS3103 2 | ||
232 | #define DVBSKY_FE_SIT2 3 | ||
233 | int fe_0; | ||
234 | int fe_1; | ||
235 | }; | ||
236 | |||
237 | struct smi_port { | ||
238 | struct smi_dev *dev; | ||
239 | int idx; | ||
240 | int enable; | ||
241 | int fe_type; | ||
242 | /* regs */ | ||
243 | u32 DMA_CHAN0_ADDR_LOW; | ||
244 | u32 DMA_CHAN0_ADDR_HI; | ||
245 | u32 DMA_CHAN0_TRANS_STATE; | ||
246 | u32 DMA_CHAN0_CONTROL; | ||
247 | u32 DMA_CHAN1_ADDR_LOW; | ||
248 | u32 DMA_CHAN1_ADDR_HI; | ||
249 | u32 DMA_CHAN1_TRANS_STATE; | ||
250 | u32 DMA_CHAN1_CONTROL; | ||
251 | u32 DMA_MANAGEMENT; | ||
252 | /* dma */ | ||
253 | dma_addr_t dma_addr[2]; | ||
254 | u8 *cpu_addr[2]; | ||
255 | u32 _dmaInterruptCH0; | ||
256 | u32 _dmaInterruptCH1; | ||
257 | u32 _int_status; | ||
258 | struct tasklet_struct tasklet; | ||
259 | /* dvb */ | ||
260 | struct dmx_frontend hw_frontend; | ||
261 | struct dmx_frontend mem_frontend; | ||
262 | struct dmxdev dmxdev; | ||
263 | struct dvb_adapter dvb_adapter; | ||
264 | struct dvb_demux demux; | ||
265 | struct dvb_net dvbnet; | ||
266 | int users; | ||
267 | struct dvb_frontend *fe; | ||
268 | /* frontend i2c module */ | ||
269 | struct i2c_client *i2c_client_demod; | ||
270 | struct i2c_client *i2c_client_tuner; | ||
271 | }; | ||
272 | |||
273 | struct smi_dev { | ||
274 | int nr; | ||
275 | struct smi_cfg_info *info; | ||
276 | |||
277 | /* pcie */ | ||
278 | struct pci_dev *pci_dev; | ||
279 | u32 __iomem *lmmio; | ||
280 | |||
281 | /* ts port */ | ||
282 | struct smi_port ts_port[2]; | ||
283 | |||
284 | /* i2c */ | ||
285 | struct i2c_adapter i2c_bus[2]; | ||
286 | struct i2c_algo_bit_data i2c_bit[2]; | ||
287 | }; | ||
288 | |||
289 | #define smi_read(reg) readl(dev->lmmio + ((reg)>>2)) | ||
290 | #define smi_write(reg, value) writel((value), dev->lmmio + ((reg)>>2)) | ||
291 | |||
292 | #define smi_andor(reg, mask, value) \ | ||
293 | writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ | ||
294 | ((value) & (mask)), dev->lmmio+((reg)>>2)) | ||
295 | |||
296 | #define smi_set(reg, bit) smi_andor((reg), (bit), (bit)) | ||
297 | #define smi_clear(reg, bit) smi_andor((reg), (bit), 0) | ||
298 | |||
299 | #endif /* #ifndef _SMI_PCIE_H_ */ | ||
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c index 28023f9f1dc7..6e933d383fa2 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | |||
@@ -463,7 +463,6 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc, | |||
463 | struct solo_dev *solo_dev = solo_enc->solo_dev; | 463 | struct solo_dev *solo_dev = solo_enc->solo_dev; |
464 | struct sg_table *vbuf = vb2_dma_sg_plane_desc(vb, 0); | 464 | struct sg_table *vbuf = vb2_dma_sg_plane_desc(vb, 0); |
465 | int frame_size; | 465 | int frame_size; |
466 | int ret; | ||
467 | 466 | ||
468 | vb->v4l2_buf.flags |= V4L2_BUF_FLAG_KEYFRAME; | 467 | vb->v4l2_buf.flags |= V4L2_BUF_FLAG_KEYFRAME; |
469 | 468 | ||
@@ -473,22 +472,10 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc, | |||
473 | frame_size = ALIGN(vop_jpeg_size(vh) + solo_enc->jpeg_len, DMA_ALIGN); | 472 | frame_size = ALIGN(vop_jpeg_size(vh) + solo_enc->jpeg_len, DMA_ALIGN); |
474 | vb2_set_plane_payload(vb, 0, vop_jpeg_size(vh) + solo_enc->jpeg_len); | 473 | vb2_set_plane_payload(vb, 0, vop_jpeg_size(vh) + solo_enc->jpeg_len); |
475 | 474 | ||
476 | /* may discard all previous data in vbuf->sgl */ | 475 | return solo_send_desc(solo_enc, solo_enc->jpeg_len, vbuf, |
477 | if (!dma_map_sg(&solo_dev->pdev->dev, vbuf->sgl, vbuf->nents, | ||
478 | DMA_FROM_DEVICE)) | ||
479 | return -ENOMEM; | ||
480 | ret = solo_send_desc(solo_enc, solo_enc->jpeg_len, vbuf, | ||
481 | vop_jpeg_offset(vh) - SOLO_JPEG_EXT_ADDR(solo_dev), | 476 | vop_jpeg_offset(vh) - SOLO_JPEG_EXT_ADDR(solo_dev), |
482 | frame_size, SOLO_JPEG_EXT_ADDR(solo_dev), | 477 | frame_size, SOLO_JPEG_EXT_ADDR(solo_dev), |
483 | SOLO_JPEG_EXT_SIZE(solo_dev)); | 478 | SOLO_JPEG_EXT_SIZE(solo_dev)); |
484 | dma_unmap_sg(&solo_dev->pdev->dev, vbuf->sgl, vbuf->nents, | ||
485 | DMA_FROM_DEVICE); | ||
486 | |||
487 | /* add the header only after dma_unmap_sg() */ | ||
488 | sg_copy_from_buffer(vbuf->sgl, vbuf->nents, | ||
489 | solo_enc->jpeg_header, solo_enc->jpeg_len); | ||
490 | |||
491 | return ret; | ||
492 | } | 479 | } |
493 | 480 | ||
494 | static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, | 481 | static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, |
@@ -498,7 +485,6 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, | |||
498 | struct sg_table *vbuf = vb2_dma_sg_plane_desc(vb, 0); | 485 | struct sg_table *vbuf = vb2_dma_sg_plane_desc(vb, 0); |
499 | int frame_off, frame_size; | 486 | int frame_off, frame_size; |
500 | int skip = 0; | 487 | int skip = 0; |
501 | int ret; | ||
502 | 488 | ||
503 | if (vb2_plane_size(vb, 0) < vop_mpeg_size(vh)) | 489 | if (vb2_plane_size(vb, 0) < vop_mpeg_size(vh)) |
504 | return -EIO; | 490 | return -EIO; |
@@ -521,21 +507,9 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, | |||
521 | sizeof(*vh)) % SOLO_MP4E_EXT_SIZE(solo_dev); | 507 | sizeof(*vh)) % SOLO_MP4E_EXT_SIZE(solo_dev); |
522 | frame_size = ALIGN(vop_mpeg_size(vh) + skip, DMA_ALIGN); | 508 | frame_size = ALIGN(vop_mpeg_size(vh) + skip, DMA_ALIGN); |
523 | 509 | ||
524 | /* may discard all previous data in vbuf->sgl */ | 510 | return solo_send_desc(solo_enc, skip, vbuf, frame_off, frame_size, |
525 | if (!dma_map_sg(&solo_dev->pdev->dev, vbuf->sgl, vbuf->nents, | ||
526 | DMA_FROM_DEVICE)) | ||
527 | return -ENOMEM; | ||
528 | ret = solo_send_desc(solo_enc, skip, vbuf, frame_off, frame_size, | ||
529 | SOLO_MP4E_EXT_ADDR(solo_dev), | 511 | SOLO_MP4E_EXT_ADDR(solo_dev), |
530 | SOLO_MP4E_EXT_SIZE(solo_dev)); | 512 | SOLO_MP4E_EXT_SIZE(solo_dev)); |
531 | dma_unmap_sg(&solo_dev->pdev->dev, vbuf->sgl, vbuf->nents, | ||
532 | DMA_FROM_DEVICE); | ||
533 | |||
534 | /* add the header only after dma_unmap_sg() */ | ||
535 | if (!vop_type(vh)) | ||
536 | sg_copy_from_buffer(vbuf->sgl, vbuf->nents, | ||
537 | solo_enc->vop, solo_enc->vop_len); | ||
538 | return ret; | ||
539 | } | 513 | } |
540 | 514 | ||
541 | static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc, | 515 | static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc, |
@@ -703,9 +677,7 @@ static int solo_ring_thread(void *data) | |||
703 | 677 | ||
704 | if (timeout == -ERESTARTSYS || kthread_should_stop()) | 678 | if (timeout == -ERESTARTSYS || kthread_should_stop()) |
705 | break; | 679 | break; |
706 | solo_irq_off(solo_dev, SOLO_IRQ_ENCODER); | ||
707 | solo_handle_ring(solo_dev); | 680 | solo_handle_ring(solo_dev); |
708 | solo_irq_on(solo_dev, SOLO_IRQ_ENCODER); | ||
709 | try_to_freeze(); | 681 | try_to_freeze(); |
710 | } | 682 | } |
711 | 683 | ||
@@ -720,7 +692,10 @@ static int solo_enc_queue_setup(struct vb2_queue *q, | |||
720 | unsigned int *num_planes, unsigned int sizes[], | 692 | unsigned int *num_planes, unsigned int sizes[], |
721 | void *alloc_ctxs[]) | 693 | void *alloc_ctxs[]) |
722 | { | 694 | { |
695 | struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q); | ||
696 | |||
723 | sizes[0] = FRAME_BUF_SIZE; | 697 | sizes[0] = FRAME_BUF_SIZE; |
698 | alloc_ctxs[0] = solo_enc->alloc_ctx; | ||
724 | *num_planes = 1; | 699 | *num_planes = 1; |
725 | 700 | ||
726 | if (*num_buffers < MIN_VID_BUFFERS) | 701 | if (*num_buffers < MIN_VID_BUFFERS) |
@@ -770,26 +745,51 @@ static void solo_ring_stop(struct solo_dev *solo_dev) | |||
770 | static int solo_enc_start_streaming(struct vb2_queue *q, unsigned int count) | 745 | static int solo_enc_start_streaming(struct vb2_queue *q, unsigned int count) |
771 | { | 746 | { |
772 | struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q); | 747 | struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q); |
773 | int ret; | ||
774 | 748 | ||
775 | ret = solo_enc_on(solo_enc); | 749 | return solo_enc_on(solo_enc); |
776 | if (ret) | ||
777 | return ret; | ||
778 | return solo_ring_start(solo_enc->solo_dev); | ||
779 | } | 750 | } |
780 | 751 | ||
781 | static void solo_enc_stop_streaming(struct vb2_queue *q) | 752 | static void solo_enc_stop_streaming(struct vb2_queue *q) |
782 | { | 753 | { |
783 | struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q); | 754 | struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q); |
755 | unsigned long flags; | ||
784 | 756 | ||
757 | spin_lock_irqsave(&solo_enc->av_lock, flags); | ||
785 | solo_enc_off(solo_enc); | 758 | solo_enc_off(solo_enc); |
786 | INIT_LIST_HEAD(&solo_enc->vidq_active); | 759 | while (!list_empty(&solo_enc->vidq_active)) { |
787 | solo_ring_stop(solo_enc->solo_dev); | 760 | struct solo_vb2_buf *buf = list_entry( |
761 | solo_enc->vidq_active.next, | ||
762 | struct solo_vb2_buf, list); | ||
763 | |||
764 | list_del(&buf->list); | ||
765 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
766 | } | ||
767 | spin_unlock_irqrestore(&solo_enc->av_lock, flags); | ||
768 | } | ||
769 | |||
770 | static void solo_enc_buf_finish(struct vb2_buffer *vb) | ||
771 | { | ||
772 | struct solo_enc_dev *solo_enc = vb2_get_drv_priv(vb->vb2_queue); | ||
773 | struct sg_table *vbuf = vb2_dma_sg_plane_desc(vb, 0); | ||
774 | |||
775 | switch (solo_enc->fmt) { | ||
776 | case V4L2_PIX_FMT_MPEG4: | ||
777 | case V4L2_PIX_FMT_H264: | ||
778 | if (vb->v4l2_buf.flags & V4L2_BUF_FLAG_KEYFRAME) | ||
779 | sg_copy_from_buffer(vbuf->sgl, vbuf->nents, | ||
780 | solo_enc->vop, solo_enc->vop_len); | ||
781 | break; | ||
782 | default: /* V4L2_PIX_FMT_MJPEG */ | ||
783 | sg_copy_from_buffer(vbuf->sgl, vbuf->nents, | ||
784 | solo_enc->jpeg_header, solo_enc->jpeg_len); | ||
785 | break; | ||
786 | } | ||
788 | } | 787 | } |
789 | 788 | ||
790 | static struct vb2_ops solo_enc_video_qops = { | 789 | static struct vb2_ops solo_enc_video_qops = { |
791 | .queue_setup = solo_enc_queue_setup, | 790 | .queue_setup = solo_enc_queue_setup, |
792 | .buf_queue = solo_enc_buf_queue, | 791 | .buf_queue = solo_enc_buf_queue, |
792 | .buf_finish = solo_enc_buf_finish, | ||
793 | .start_streaming = solo_enc_start_streaming, | 793 | .start_streaming = solo_enc_start_streaming, |
794 | .stop_streaming = solo_enc_stop_streaming, | 794 | .stop_streaming = solo_enc_stop_streaming, |
795 | .wait_prepare = vb2_ops_wait_prepare, | 795 | .wait_prepare = vb2_ops_wait_prepare, |
@@ -1263,6 +1263,11 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, | |||
1263 | return ERR_PTR(-ENOMEM); | 1263 | return ERR_PTR(-ENOMEM); |
1264 | 1264 | ||
1265 | hdl = &solo_enc->hdl; | 1265 | hdl = &solo_enc->hdl; |
1266 | solo_enc->alloc_ctx = vb2_dma_sg_init_ctx(&solo_dev->pdev->dev); | ||
1267 | if (IS_ERR(solo_enc->alloc_ctx)) { | ||
1268 | ret = PTR_ERR(solo_enc->alloc_ctx); | ||
1269 | goto hdl_free; | ||
1270 | } | ||
1266 | v4l2_ctrl_handler_init(hdl, 10); | 1271 | v4l2_ctrl_handler_init(hdl, 10); |
1267 | v4l2_ctrl_new_std(hdl, &solo_ctrl_ops, | 1272 | v4l2_ctrl_new_std(hdl, &solo_ctrl_ops, |
1268 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); | 1273 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); |
@@ -1366,6 +1371,7 @@ pci_free: | |||
1366 | solo_enc->desc_items, solo_enc->desc_dma); | 1371 | solo_enc->desc_items, solo_enc->desc_dma); |
1367 | hdl_free: | 1372 | hdl_free: |
1368 | v4l2_ctrl_handler_free(hdl); | 1373 | v4l2_ctrl_handler_free(hdl); |
1374 | vb2_dma_sg_cleanup_ctx(solo_enc->alloc_ctx); | ||
1369 | kfree(solo_enc); | 1375 | kfree(solo_enc); |
1370 | return ERR_PTR(ret); | 1376 | return ERR_PTR(ret); |
1371 | } | 1377 | } |
@@ -1375,8 +1381,12 @@ static void solo_enc_free(struct solo_enc_dev *solo_enc) | |||
1375 | if (solo_enc == NULL) | 1381 | if (solo_enc == NULL) |
1376 | return; | 1382 | return; |
1377 | 1383 | ||
1384 | pci_free_consistent(solo_enc->solo_dev->pdev, | ||
1385 | sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, | ||
1386 | solo_enc->desc_items, solo_enc->desc_dma); | ||
1378 | video_unregister_device(solo_enc->vfd); | 1387 | video_unregister_device(solo_enc->vfd); |
1379 | v4l2_ctrl_handler_free(&solo_enc->hdl); | 1388 | v4l2_ctrl_handler_free(&solo_enc->hdl); |
1389 | vb2_dma_sg_cleanup_ctx(solo_enc->alloc_ctx); | ||
1380 | kfree(solo_enc); | 1390 | kfree(solo_enc); |
1381 | } | 1391 | } |
1382 | 1392 | ||
@@ -1419,13 +1429,15 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr) | |||
1419 | solo_dev->v4l2_enc[0]->vfd->num, | 1429 | solo_dev->v4l2_enc[0]->vfd->num, |
1420 | solo_dev->v4l2_enc[solo_dev->nr_chans - 1]->vfd->num); | 1430 | solo_dev->v4l2_enc[solo_dev->nr_chans - 1]->vfd->num); |
1421 | 1431 | ||
1422 | return 0; | 1432 | return solo_ring_start(solo_dev); |
1423 | } | 1433 | } |
1424 | 1434 | ||
1425 | void solo_enc_v4l2_exit(struct solo_dev *solo_dev) | 1435 | void solo_enc_v4l2_exit(struct solo_dev *solo_dev) |
1426 | { | 1436 | { |
1427 | int i; | 1437 | int i; |
1428 | 1438 | ||
1439 | solo_ring_stop(solo_dev); | ||
1440 | |||
1429 | for (i = 0; i < solo_dev->nr_chans; i++) | 1441 | for (i = 0; i < solo_dev->nr_chans; i++) |
1430 | solo_enc_free(solo_dev->v4l2_enc[i]); | 1442 | solo_enc_free(solo_dev->v4l2_enc[i]); |
1431 | 1443 | ||
diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h index 72017b7f0a75..bd8edfa319b8 100644 --- a/drivers/media/pci/solo6x10/solo6x10.h +++ b/drivers/media/pci/solo6x10/solo6x10.h | |||
@@ -180,6 +180,7 @@ struct solo_enc_dev { | |||
180 | u32 sequence; | 180 | u32 sequence; |
181 | struct vb2_queue vidq; | 181 | struct vb2_queue vidq; |
182 | struct list_head vidq_active; | 182 | struct list_head vidq_active; |
183 | void *alloc_ctx; | ||
183 | int desc_count; | 184 | int desc_count; |
184 | int desc_nelts; | 185 | int desc_nelts; |
185 | struct solo_p2m_desc *desc_items; | 186 | struct solo_p2m_desc *desc_items; |
diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c index 63f0b64057cb..c135165a8b26 100644 --- a/drivers/media/pci/tw68/tw68-core.c +++ b/drivers/media/pci/tw68/tw68-core.c | |||
@@ -304,13 +304,19 @@ static int tw68_initdev(struct pci_dev *pci_dev, | |||
304 | /* Then do any initialisation wanted before interrupts are on */ | 304 | /* Then do any initialisation wanted before interrupts are on */ |
305 | tw68_hw_init1(dev); | 305 | tw68_hw_init1(dev); |
306 | 306 | ||
307 | dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev); | ||
308 | if (IS_ERR(dev->alloc_ctx)) { | ||
309 | err = PTR_ERR(dev->alloc_ctx); | ||
310 | goto fail3; | ||
311 | } | ||
312 | |||
307 | /* get irq */ | 313 | /* get irq */ |
308 | err = devm_request_irq(&pci_dev->dev, pci_dev->irq, tw68_irq, | 314 | err = devm_request_irq(&pci_dev->dev, pci_dev->irq, tw68_irq, |
309 | IRQF_SHARED, dev->name, dev); | 315 | IRQF_SHARED, dev->name, dev); |
310 | if (err < 0) { | 316 | if (err < 0) { |
311 | pr_err("%s: can't get IRQ %d\n", | 317 | pr_err("%s: can't get IRQ %d\n", |
312 | dev->name, pci_dev->irq); | 318 | dev->name, pci_dev->irq); |
313 | goto fail3; | 319 | goto fail4; |
314 | } | 320 | } |
315 | 321 | ||
316 | /* | 322 | /* |
@@ -324,7 +330,7 @@ static int tw68_initdev(struct pci_dev *pci_dev, | |||
324 | if (err < 0) { | 330 | if (err < 0) { |
325 | pr_err("%s: can't register video device\n", | 331 | pr_err("%s: can't register video device\n", |
326 | dev->name); | 332 | dev->name); |
327 | goto fail4; | 333 | goto fail5; |
328 | } | 334 | } |
329 | tw_setl(TW68_INTMASK, dev->pci_irqmask); | 335 | tw_setl(TW68_INTMASK, dev->pci_irqmask); |
330 | 336 | ||
@@ -333,8 +339,10 @@ static int tw68_initdev(struct pci_dev *pci_dev, | |||
333 | 339 | ||
334 | return 0; | 340 | return 0; |
335 | 341 | ||
336 | fail4: | 342 | fail5: |
337 | video_unregister_device(&dev->vdev); | 343 | video_unregister_device(&dev->vdev); |
344 | fail4: | ||
345 | vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); | ||
338 | fail3: | 346 | fail3: |
339 | iounmap(dev->lmmio); | 347 | iounmap(dev->lmmio); |
340 | fail2: | 348 | fail2: |
@@ -358,6 +366,7 @@ static void tw68_finidev(struct pci_dev *pci_dev) | |||
358 | /* unregister */ | 366 | /* unregister */ |
359 | video_unregister_device(&dev->vdev); | 367 | video_unregister_device(&dev->vdev); |
360 | v4l2_ctrl_handler_free(&dev->hdl); | 368 | v4l2_ctrl_handler_free(&dev->hdl); |
369 | vb2_dma_sg_cleanup_ctx(dev->alloc_ctx); | ||
361 | 370 | ||
362 | /* release resources */ | 371 | /* release resources */ |
363 | iounmap(dev->lmmio); | 372 | iounmap(dev->lmmio); |
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 5c94ac7c88d9..8355e55b4e8e 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c | |||
@@ -384,6 +384,7 @@ static int tw68_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, | |||
384 | unsigned tot_bufs = q->num_buffers + *num_buffers; | 384 | unsigned tot_bufs = q->num_buffers + *num_buffers; |
385 | 385 | ||
386 | sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; | 386 | sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; |
387 | alloc_ctxs[0] = dev->alloc_ctx; | ||
387 | /* | 388 | /* |
388 | * We allow create_bufs, but only if the sizeimage is the same as the | 389 | * We allow create_bufs, but only if the sizeimage is the same as the |
389 | * current sizeimage. The tw68_buffer_count calculation becomes quite | 390 | * current sizeimage. The tw68_buffer_count calculation becomes quite |
@@ -461,17 +462,12 @@ static int tw68_buf_prepare(struct vb2_buffer *vb) | |||
461 | struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb); | 462 | struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb); |
462 | struct sg_table *dma = vb2_dma_sg_plane_desc(vb, 0); | 463 | struct sg_table *dma = vb2_dma_sg_plane_desc(vb, 0); |
463 | unsigned size, bpl; | 464 | unsigned size, bpl; |
464 | int rc; | ||
465 | 465 | ||
466 | size = (dev->width * dev->height * dev->fmt->depth) >> 3; | 466 | size = (dev->width * dev->height * dev->fmt->depth) >> 3; |
467 | if (vb2_plane_size(vb, 0) < size) | 467 | if (vb2_plane_size(vb, 0) < size) |
468 | return -EINVAL; | 468 | return -EINVAL; |
469 | vb2_set_plane_payload(vb, 0, size); | 469 | vb2_set_plane_payload(vb, 0, size); |
470 | 470 | ||
471 | rc = dma_map_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
472 | if (!rc) | ||
473 | return -EIO; | ||
474 | |||
475 | bpl = (dev->width * dev->fmt->depth) >> 3; | 471 | bpl = (dev->width * dev->fmt->depth) >> 3; |
476 | switch (dev->field) { | 472 | switch (dev->field) { |
477 | case V4L2_FIELD_TOP: | 473 | case V4L2_FIELD_TOP: |
@@ -505,11 +501,8 @@ static void tw68_buf_finish(struct vb2_buffer *vb) | |||
505 | { | 501 | { |
506 | struct vb2_queue *vq = vb->vb2_queue; | 502 | struct vb2_queue *vq = vb->vb2_queue; |
507 | struct tw68_dev *dev = vb2_get_drv_priv(vq); | 503 | struct tw68_dev *dev = vb2_get_drv_priv(vq); |
508 | struct sg_table *dma = vb2_dma_sg_plane_desc(vb, 0); | ||
509 | struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb); | 504 | struct tw68_buf *buf = container_of(vb, struct tw68_buf, vb); |
510 | 505 | ||
511 | dma_unmap_sg(&dev->pci->dev, dma->sgl, dma->nents, DMA_FROM_DEVICE); | ||
512 | |||
513 | pci_free_consistent(dev->pci, buf->size, buf->cpu, buf->dma); | 506 | pci_free_consistent(dev->pci, buf->size, buf->cpu, buf->dma); |
514 | } | 507 | } |
515 | 508 | ||
diff --git a/drivers/media/pci/tw68/tw68.h b/drivers/media/pci/tw68/tw68.h index 2c8abe26b13b..7a7501bd165f 100644 --- a/drivers/media/pci/tw68/tw68.h +++ b/drivers/media/pci/tw68/tw68.h | |||
@@ -181,6 +181,7 @@ struct tw68_dev { | |||
181 | unsigned field; | 181 | unsigned field; |
182 | struct vb2_queue vidq; | 182 | struct vb2_queue vidq; |
183 | struct list_head active; | 183 | struct list_head active; |
184 | void *alloc_ctx; | ||
184 | 185 | ||
185 | /* various v4l controls */ | 186 | /* various v4l controls */ |
186 | const struct tw68_tvnorm *tvnorm; /* video */ | 187 | const struct tw68_tvnorm *tvnorm; /* video */ |
diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c index 099d5fbebb7c..2b25d31c46f6 100644 --- a/drivers/media/pci/zoran/zoran_driver.c +++ b/drivers/media/pci/zoran/zoran_driver.c | |||
@@ -1528,8 +1528,9 @@ static int zoran_querycap(struct file *file, void *__fh, struct v4l2_capability | |||
1528 | strncpy(cap->driver, "zoran", sizeof(cap->driver)-1); | 1528 | strncpy(cap->driver, "zoran", sizeof(cap->driver)-1); |
1529 | snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", | 1529 | snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", |
1530 | pci_name(zr->pci_dev)); | 1530 | pci_name(zr->pci_dev)); |
1531 | cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE | | 1531 | cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE | |
1532 | V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OVERLAY; | 1532 | V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OVERLAY; |
1533 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
1533 | return 0; | 1534 | return 0; |
1534 | } | 1535 | } |
1535 | 1536 | ||
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 3aac88f1d54a..0c61155699f7 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig | |||
@@ -267,8 +267,8 @@ if V4L_TEST_DRIVERS | |||
267 | 267 | ||
268 | source "drivers/media/platform/vivid/Kconfig" | 268 | source "drivers/media/platform/vivid/Kconfig" |
269 | 269 | ||
270 | config VIDEO_MEM2MEM_TESTDEV | 270 | config VIDEO_VIM2M |
271 | tristate "Virtual test device for mem2mem framework" | 271 | tristate "Virtual Memory-to-Memory Driver" |
272 | depends on VIDEO_DEV && VIDEO_V4L2 | 272 | depends on VIDEO_DEV && VIDEO_V4L2 |
273 | select VIDEOBUF2_VMALLOC | 273 | select VIDEOBUF2_VMALLOC |
274 | select V4L2_MEM2MEM_DEV | 274 | select V4L2_MEM2MEM_DEV |
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index 579046bc276f..b818afb4d336 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile | |||
@@ -17,7 +17,7 @@ obj-$(CONFIG_VIDEO_OMAP3) += omap3isp/ | |||
17 | obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o | 17 | obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o |
18 | 18 | ||
19 | obj-$(CONFIG_VIDEO_VIVID) += vivid/ | 19 | obj-$(CONFIG_VIDEO_VIVID) += vivid/ |
20 | obj-$(CONFIG_VIDEO_MEM2MEM_TESTDEV) += mem2mem_testdev.o | 20 | obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o |
21 | 21 | ||
22 | obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/ | 22 | obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/ |
23 | 23 | ||
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c index 9b5daa65841c..3112844e4fc1 100644 --- a/drivers/media/platform/blackfin/bfin_capture.c +++ b/drivers/media/platform/blackfin/bfin_capture.c | |||
@@ -49,7 +49,7 @@ | |||
49 | struct bcap_format { | 49 | struct bcap_format { |
50 | char *desc; | 50 | char *desc; |
51 | u32 pixelformat; | 51 | u32 pixelformat; |
52 | enum v4l2_mbus_pixelcode mbus_code; | 52 | u32 mbus_code; |
53 | int bpp; /* bits per pixel */ | 53 | int bpp; /* bits per pixel */ |
54 | int dlen; /* data length for ppi in bits */ | 54 | int dlen; /* data length for ppi in bits */ |
55 | }; | 55 | }; |
@@ -116,35 +116,35 @@ static const struct bcap_format bcap_formats[] = { | |||
116 | { | 116 | { |
117 | .desc = "YCbCr 4:2:2 Interleaved UYVY", | 117 | .desc = "YCbCr 4:2:2 Interleaved UYVY", |
118 | .pixelformat = V4L2_PIX_FMT_UYVY, | 118 | .pixelformat = V4L2_PIX_FMT_UYVY, |
119 | .mbus_code = V4L2_MBUS_FMT_UYVY8_2X8, | 119 | .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, |
120 | .bpp = 16, | 120 | .bpp = 16, |
121 | .dlen = 8, | 121 | .dlen = 8, |
122 | }, | 122 | }, |
123 | { | 123 | { |
124 | .desc = "YCbCr 4:2:2 Interleaved YUYV", | 124 | .desc = "YCbCr 4:2:2 Interleaved YUYV", |
125 | .pixelformat = V4L2_PIX_FMT_YUYV, | 125 | .pixelformat = V4L2_PIX_FMT_YUYV, |
126 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 126 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
127 | .bpp = 16, | 127 | .bpp = 16, |
128 | .dlen = 8, | 128 | .dlen = 8, |
129 | }, | 129 | }, |
130 | { | 130 | { |
131 | .desc = "YCbCr 4:2:2 Interleaved UYVY", | 131 | .desc = "YCbCr 4:2:2 Interleaved UYVY", |
132 | .pixelformat = V4L2_PIX_FMT_UYVY, | 132 | .pixelformat = V4L2_PIX_FMT_UYVY, |
133 | .mbus_code = V4L2_MBUS_FMT_UYVY8_1X16, | 133 | .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, |
134 | .bpp = 16, | 134 | .bpp = 16, |
135 | .dlen = 16, | 135 | .dlen = 16, |
136 | }, | 136 | }, |
137 | { | 137 | { |
138 | .desc = "RGB 565", | 138 | .desc = "RGB 565", |
139 | .pixelformat = V4L2_PIX_FMT_RGB565, | 139 | .pixelformat = V4L2_PIX_FMT_RGB565, |
140 | .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 140 | .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
141 | .bpp = 16, | 141 | .bpp = 16, |
142 | .dlen = 8, | 142 | .dlen = 8, |
143 | }, | 143 | }, |
144 | { | 144 | { |
145 | .desc = "RGB 444", | 145 | .desc = "RGB 444", |
146 | .pixelformat = V4L2_PIX_FMT_RGB444, | 146 | .pixelformat = V4L2_PIX_FMT_RGB444, |
147 | .mbus_code = V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, | 147 | .mbus_code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, |
148 | .bpp = 16, | 148 | .bpp = 16, |
149 | .dlen = 8, | 149 | .dlen = 8, |
150 | }, | 150 | }, |
@@ -161,7 +161,7 @@ static struct bcap_buffer *to_bcap_vb(struct vb2_buffer *vb) | |||
161 | 161 | ||
162 | static int bcap_init_sensor_formats(struct bcap_device *bcap_dev) | 162 | static int bcap_init_sensor_formats(struct bcap_device *bcap_dev) |
163 | { | 163 | { |
164 | enum v4l2_mbus_pixelcode code; | 164 | u32 code; |
165 | struct bcap_format *sf; | 165 | struct bcap_format *sf; |
166 | unsigned int num_formats = 0; | 166 | unsigned int num_formats = 0; |
167 | int i, j; | 167 | int i, j; |
@@ -349,18 +349,6 @@ static void bcap_buffer_cleanup(struct vb2_buffer *vb) | |||
349 | spin_unlock_irqrestore(&bcap_dev->lock, flags); | 349 | spin_unlock_irqrestore(&bcap_dev->lock, flags); |
350 | } | 350 | } |
351 | 351 | ||
352 | static void bcap_lock(struct vb2_queue *vq) | ||
353 | { | ||
354 | struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); | ||
355 | mutex_lock(&bcap_dev->mutex); | ||
356 | } | ||
357 | |||
358 | static void bcap_unlock(struct vb2_queue *vq) | ||
359 | { | ||
360 | struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); | ||
361 | mutex_unlock(&bcap_dev->mutex); | ||
362 | } | ||
363 | |||
364 | static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count) | 352 | static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count) |
365 | { | 353 | { |
366 | struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); | 354 | struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); |
@@ -457,8 +445,8 @@ static struct vb2_ops bcap_video_qops = { | |||
457 | .buf_prepare = bcap_buffer_prepare, | 445 | .buf_prepare = bcap_buffer_prepare, |
458 | .buf_cleanup = bcap_buffer_cleanup, | 446 | .buf_cleanup = bcap_buffer_cleanup, |
459 | .buf_queue = bcap_buffer_queue, | 447 | .buf_queue = bcap_buffer_queue, |
460 | .wait_prepare = bcap_unlock, | 448 | .wait_prepare = vb2_ops_wait_prepare, |
461 | .wait_finish = bcap_lock, | 449 | .wait_finish = vb2_ops_wait_finish, |
462 | .start_streaming = bcap_start_streaming, | 450 | .start_streaming = bcap_start_streaming, |
463 | .stop_streaming = bcap_stop_streaming, | 451 | .stop_streaming = bcap_stop_streaming, |
464 | }; | 452 | }; |
@@ -841,7 +829,8 @@ static int bcap_querycap(struct file *file, void *priv, | |||
841 | { | 829 | { |
842 | struct bcap_device *bcap_dev = video_drvdata(file); | 830 | struct bcap_device *bcap_dev = video_drvdata(file); |
843 | 831 | ||
844 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; | 832 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; |
833 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
845 | strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver)); | 834 | strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver)); |
846 | strlcpy(cap->bus_info, "Blackfin Platform", sizeof(cap->bus_info)); | 835 | strlcpy(cap->bus_info, "Blackfin Platform", sizeof(cap->bus_info)); |
847 | strlcpy(cap->card, bcap_dev->cfg->card_name, sizeof(cap->card)); | 836 | strlcpy(cap->card, bcap_dev->cfg->card_name, sizeof(cap->card)); |
@@ -995,6 +984,7 @@ static int bcap_probe(struct platform_device *pdev) | |||
995 | q->ops = &bcap_video_qops; | 984 | q->ops = &bcap_video_qops; |
996 | q->mem_ops = &vb2_dma_contig_memops; | 985 | q->mem_ops = &vb2_dma_contig_memops; |
997 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 986 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
987 | q->lock = &bcap_dev->mutex; | ||
998 | 988 | ||
999 | ret = vb2_queue_init(q); | 989 | ret = vb2_queue_init(q); |
1000 | if (ret) | 990 | if (ret) |
diff --git a/drivers/media/platform/coda/Makefile b/drivers/media/platform/coda/Makefile index 3543291e6273..25ce15561695 100644 --- a/drivers/media/platform/coda/Makefile +++ b/drivers/media/platform/coda/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | coda-objs := coda-common.o coda-bit.o coda-h264.o | 1 | coda-objs := coda-common.o coda-bit.o coda-h264.o coda-jpeg.o |
2 | 2 | ||
3 | obj-$(CONFIG_VIDEO_CODA) += coda.o | 3 | obj-$(CONFIG_VIDEO_CODA) += coda.o |
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c index 9b8ea8bbeb4e..b4029ae293d3 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c | |||
@@ -217,11 +217,34 @@ static bool coda_bitstream_try_queue(struct coda_ctx *ctx, | |||
217 | void coda_fill_bitstream(struct coda_ctx *ctx) | 217 | void coda_fill_bitstream(struct coda_ctx *ctx) |
218 | { | 218 | { |
219 | struct vb2_buffer *src_buf; | 219 | struct vb2_buffer *src_buf; |
220 | struct coda_timestamp *ts; | 220 | struct coda_buffer_meta *meta; |
221 | u32 start; | ||
221 | 222 | ||
222 | while (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) > 0) { | 223 | while (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) > 0) { |
224 | /* | ||
225 | * Only queue a single JPEG into the bitstream buffer, except | ||
226 | * to increase payload over 512 bytes or if in hold state. | ||
227 | */ | ||
228 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG && | ||
229 | (coda_get_bitstream_payload(ctx) >= 512) && !ctx->hold) | ||
230 | break; | ||
231 | |||
223 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); | 232 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); |
224 | 233 | ||
234 | /* Drop frames that do not start/end with a SOI/EOI markers */ | ||
235 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG && | ||
236 | !coda_jpeg_check_buffer(ctx, src_buf)) { | ||
237 | v4l2_err(&ctx->dev->v4l2_dev, | ||
238 | "dropping invalid JPEG frame\n"); | ||
239 | src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); | ||
240 | v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); | ||
241 | continue; | ||
242 | } | ||
243 | |||
244 | /* Buffer start position */ | ||
245 | start = ctx->bitstream_fifo.kfifo.in & | ||
246 | ctx->bitstream_fifo.kfifo.mask; | ||
247 | |||
225 | if (coda_bitstream_try_queue(ctx, src_buf)) { | 248 | if (coda_bitstream_try_queue(ctx, src_buf)) { |
226 | /* | 249 | /* |
227 | * Source buffer is queued in the bitstream ringbuffer; | 250 | * Source buffer is queued in the bitstream ringbuffer; |
@@ -229,12 +252,16 @@ void coda_fill_bitstream(struct coda_ctx *ctx) | |||
229 | */ | 252 | */ |
230 | src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); | 253 | src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); |
231 | 254 | ||
232 | ts = kmalloc(sizeof(*ts), GFP_KERNEL); | 255 | meta = kmalloc(sizeof(*meta), GFP_KERNEL); |
233 | if (ts) { | 256 | if (meta) { |
234 | ts->sequence = src_buf->v4l2_buf.sequence; | 257 | meta->sequence = src_buf->v4l2_buf.sequence; |
235 | ts->timecode = src_buf->v4l2_buf.timecode; | 258 | meta->timecode = src_buf->v4l2_buf.timecode; |
236 | ts->timestamp = src_buf->v4l2_buf.timestamp; | 259 | meta->timestamp = src_buf->v4l2_buf.timestamp; |
237 | list_add_tail(&ts->list, &ctx->timestamp_list); | 260 | meta->start = start; |
261 | meta->end = ctx->bitstream_fifo.kfifo.in & | ||
262 | ctx->bitstream_fifo.kfifo.mask; | ||
263 | list_add_tail(&meta->list, | ||
264 | &ctx->buffer_meta_list); | ||
238 | } | 265 | } |
239 | 266 | ||
240 | v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); | 267 | v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); |
@@ -691,6 +718,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
691 | struct vb2_buffer *buf; | 718 | struct vb2_buffer *buf; |
692 | int gamma, ret, value; | 719 | int gamma, ret, value; |
693 | u32 dst_fourcc; | 720 | u32 dst_fourcc; |
721 | u32 stride; | ||
694 | 722 | ||
695 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | 723 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); |
696 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); | 724 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); |
@@ -710,6 +738,14 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
710 | return -EFAULT; | 738 | return -EFAULT; |
711 | } | 739 | } |
712 | 740 | ||
741 | if (dst_fourcc == V4L2_PIX_FMT_JPEG) { | ||
742 | if (!ctx->params.jpeg_qmat_tab[0]) | ||
743 | ctx->params.jpeg_qmat_tab[0] = kmalloc(64, GFP_KERNEL); | ||
744 | if (!ctx->params.jpeg_qmat_tab[1]) | ||
745 | ctx->params.jpeg_qmat_tab[1] = kmalloc(64, GFP_KERNEL); | ||
746 | coda_set_jpeg_compression_quality(ctx, ctx->params.jpeg_quality); | ||
747 | } | ||
748 | |||
713 | mutex_lock(&dev->coda_mutex); | 749 | mutex_lock(&dev->coda_mutex); |
714 | 750 | ||
715 | coda_write(dev, ctx->parabuf.paddr, CODA_REG_BIT_PARA_BUF_ADDR); | 751 | coda_write(dev, ctx->parabuf.paddr, CODA_REG_BIT_PARA_BUF_ADDR); |
@@ -729,10 +765,10 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
729 | break; | 765 | break; |
730 | } | 766 | } |
731 | 767 | ||
732 | value = coda_read(dev, CODA_REG_BIT_FRAME_MEM_CTRL); | 768 | ctx->frame_mem_ctrl &= ~CODA_FRAME_CHROMA_INTERLEAVE; |
733 | value &= ~(1 << 2 | 0x7 << 9); | 769 | if (q_data_src->fourcc == V4L2_PIX_FMT_NV12) |
734 | ctx->frame_mem_ctrl = value; | 770 | ctx->frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE; |
735 | coda_write(dev, value, CODA_REG_BIT_FRAME_MEM_CTRL); | 771 | coda_write(dev, ctx->frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL); |
736 | 772 | ||
737 | if (dev->devtype->product == CODA_DX6) { | 773 | if (dev->devtype->product == CODA_DX6) { |
738 | /* Configure the coda */ | 774 | /* Configure the coda */ |
@@ -741,6 +777,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
741 | } | 777 | } |
742 | 778 | ||
743 | /* Could set rotation here if needed */ | 779 | /* Could set rotation here if needed */ |
780 | value = 0; | ||
744 | switch (dev->devtype->product) { | 781 | switch (dev->devtype->product) { |
745 | case CODA_DX6: | 782 | case CODA_DX6: |
746 | value = (q_data_src->width & CODADX6_PICWIDTH_MASK) | 783 | value = (q_data_src->width & CODADX6_PICWIDTH_MASK) |
@@ -764,6 +801,8 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
764 | << CODA_PICHEIGHT_OFFSET; | 801 | << CODA_PICHEIGHT_OFFSET; |
765 | } | 802 | } |
766 | coda_write(dev, value, CODA_CMD_ENC_SEQ_SRC_SIZE); | 803 | coda_write(dev, value, CODA_CMD_ENC_SEQ_SRC_SIZE); |
804 | if (dst_fourcc == V4L2_PIX_FMT_JPEG) | ||
805 | ctx->params.framerate = 0; | ||
767 | coda_write(dev, ctx->params.framerate, | 806 | coda_write(dev, ctx->params.framerate, |
768 | CODA_CMD_ENC_SEQ_SRC_F_RATE); | 807 | CODA_CMD_ENC_SEQ_SRC_F_RATE); |
769 | 808 | ||
@@ -797,6 +836,16 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
797 | } | 836 | } |
798 | coda_write(dev, value, CODA_CMD_ENC_SEQ_264_PARA); | 837 | coda_write(dev, value, CODA_CMD_ENC_SEQ_264_PARA); |
799 | break; | 838 | break; |
839 | case V4L2_PIX_FMT_JPEG: | ||
840 | coda_write(dev, 0, CODA_CMD_ENC_SEQ_JPG_PARA); | ||
841 | coda_write(dev, ctx->params.jpeg_restart_interval, | ||
842 | CODA_CMD_ENC_SEQ_JPG_RST_INTERVAL); | ||
843 | coda_write(dev, 0, CODA_CMD_ENC_SEQ_JPG_THUMB_EN); | ||
844 | coda_write(dev, 0, CODA_CMD_ENC_SEQ_JPG_THUMB_SIZE); | ||
845 | coda_write(dev, 0, CODA_CMD_ENC_SEQ_JPG_THUMB_OFFSET); | ||
846 | |||
847 | coda_jpeg_write_tables(ctx); | ||
848 | break; | ||
800 | default: | 849 | default: |
801 | v4l2_err(v4l2_dev, | 850 | v4l2_err(v4l2_dev, |
802 | "dst format (0x%08x) invalid.\n", dst_fourcc); | 851 | "dst format (0x%08x) invalid.\n", dst_fourcc); |
@@ -804,28 +853,36 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
804 | goto out; | 853 | goto out; |
805 | } | 854 | } |
806 | 855 | ||
807 | switch (ctx->params.slice_mode) { | 856 | /* |
808 | case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE: | 857 | * slice mode and GOP size registers are used for thumb size/offset |
809 | value = 0; | 858 | * in JPEG mode |
810 | break; | 859 | */ |
811 | case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB: | 860 | if (dst_fourcc != V4L2_PIX_FMT_JPEG) { |
812 | value = (ctx->params.slice_max_mb & CODA_SLICING_SIZE_MASK) | 861 | switch (ctx->params.slice_mode) { |
813 | << CODA_SLICING_SIZE_OFFSET; | 862 | case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE: |
814 | value |= (1 & CODA_SLICING_UNIT_MASK) | 863 | value = 0; |
815 | << CODA_SLICING_UNIT_OFFSET; | 864 | break; |
816 | value |= 1 & CODA_SLICING_MODE_MASK; | 865 | case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB: |
817 | break; | 866 | value = (ctx->params.slice_max_mb & |
818 | case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES: | 867 | CODA_SLICING_SIZE_MASK) |
819 | value = (ctx->params.slice_max_bits & CODA_SLICING_SIZE_MASK) | 868 | << CODA_SLICING_SIZE_OFFSET; |
820 | << CODA_SLICING_SIZE_OFFSET; | 869 | value |= (1 & CODA_SLICING_UNIT_MASK) |
821 | value |= (0 & CODA_SLICING_UNIT_MASK) | 870 | << CODA_SLICING_UNIT_OFFSET; |
822 | << CODA_SLICING_UNIT_OFFSET; | 871 | value |= 1 & CODA_SLICING_MODE_MASK; |
823 | value |= 1 & CODA_SLICING_MODE_MASK; | 872 | break; |
824 | break; | 873 | case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES: |
874 | value = (ctx->params.slice_max_bits & | ||
875 | CODA_SLICING_SIZE_MASK) | ||
876 | << CODA_SLICING_SIZE_OFFSET; | ||
877 | value |= (0 & CODA_SLICING_UNIT_MASK) | ||
878 | << CODA_SLICING_UNIT_OFFSET; | ||
879 | value |= 1 & CODA_SLICING_MODE_MASK; | ||
880 | break; | ||
881 | } | ||
882 | coda_write(dev, value, CODA_CMD_ENC_SEQ_SLICE_MODE); | ||
883 | value = ctx->params.gop_size & CODA_GOP_SIZE_MASK; | ||
884 | coda_write(dev, value, CODA_CMD_ENC_SEQ_GOP_SIZE); | ||
825 | } | 885 | } |
826 | coda_write(dev, value, CODA_CMD_ENC_SEQ_SLICE_MODE); | ||
827 | value = ctx->params.gop_size & CODA_GOP_SIZE_MASK; | ||
828 | coda_write(dev, value, CODA_CMD_ENC_SEQ_GOP_SIZE); | ||
829 | 886 | ||
830 | if (ctx->params.bitrate) { | 887 | if (ctx->params.bitrate) { |
831 | /* Rate control enabled */ | 888 | /* Rate control enabled */ |
@@ -916,19 +973,24 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
916 | goto out; | 973 | goto out; |
917 | } | 974 | } |
918 | 975 | ||
919 | if (dev->devtype->product == CODA_960) | 976 | if (dst_fourcc != V4L2_PIX_FMT_JPEG) { |
920 | ctx->num_internal_frames = 4; | 977 | if (dev->devtype->product == CODA_960) |
921 | else | 978 | ctx->num_internal_frames = 4; |
922 | ctx->num_internal_frames = 2; | 979 | else |
923 | ret = coda_alloc_framebuffers(ctx, q_data_src, dst_fourcc); | 980 | ctx->num_internal_frames = 2; |
924 | if (ret < 0) { | 981 | ret = coda_alloc_framebuffers(ctx, q_data_src, dst_fourcc); |
925 | v4l2_err(v4l2_dev, "failed to allocate framebuffers\n"); | 982 | if (ret < 0) { |
926 | goto out; | 983 | v4l2_err(v4l2_dev, "failed to allocate framebuffers\n"); |
984 | goto out; | ||
985 | } | ||
986 | stride = q_data_src->bytesperline; | ||
987 | } else { | ||
988 | ctx->num_internal_frames = 0; | ||
989 | stride = 0; | ||
927 | } | 990 | } |
928 | |||
929 | coda_write(dev, ctx->num_internal_frames, CODA_CMD_SET_FRAME_BUF_NUM); | 991 | coda_write(dev, ctx->num_internal_frames, CODA_CMD_SET_FRAME_BUF_NUM); |
930 | coda_write(dev, q_data_src->bytesperline, | 992 | coda_write(dev, stride, CODA_CMD_SET_FRAME_BUF_STRIDE); |
931 | CODA_CMD_SET_FRAME_BUF_STRIDE); | 993 | |
932 | if (dev->devtype->product == CODA_7541) { | 994 | if (dev->devtype->product == CODA_7541) { |
933 | coda_write(dev, q_data_src->bytesperline, | 995 | coda_write(dev, q_data_src->bytesperline, |
934 | CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE); | 996 | CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE); |
@@ -1036,9 +1098,10 @@ static int coda_prepare_encode(struct coda_ctx *ctx) | |||
1036 | struct coda_dev *dev = ctx->dev; | 1098 | struct coda_dev *dev = ctx->dev; |
1037 | int force_ipicture; | 1099 | int force_ipicture; |
1038 | int quant_param = 0; | 1100 | int quant_param = 0; |
1039 | u32 picture_y, picture_cb, picture_cr; | ||
1040 | u32 pic_stream_buffer_addr, pic_stream_buffer_size; | 1101 | u32 pic_stream_buffer_addr, pic_stream_buffer_size; |
1102 | u32 rot_mode = 0; | ||
1041 | u32 dst_fourcc; | 1103 | u32 dst_fourcc; |
1104 | u32 reg; | ||
1042 | 1105 | ||
1043 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); | 1106 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); |
1044 | dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); | 1107 | dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); |
@@ -1076,7 +1139,7 @@ static int coda_prepare_encode(struct coda_ctx *ctx) | |||
1076 | ctx->vpu_header_size[0] + | 1139 | ctx->vpu_header_size[0] + |
1077 | ctx->vpu_header_size[1] + | 1140 | ctx->vpu_header_size[1] + |
1078 | ctx->vpu_header_size[2]; | 1141 | ctx->vpu_header_size[2]; |
1079 | pic_stream_buffer_size = CODA_MAX_FRAME_SIZE - | 1142 | pic_stream_buffer_size = q_data_dst->sizeimage - |
1080 | ctx->vpu_header_size[0] - | 1143 | ctx->vpu_header_size[0] - |
1081 | ctx->vpu_header_size[1] - | 1144 | ctx->vpu_header_size[1] - |
1082 | ctx->vpu_header_size[2]; | 1145 | ctx->vpu_header_size[2]; |
@@ -1090,7 +1153,7 @@ static int coda_prepare_encode(struct coda_ctx *ctx) | |||
1090 | } else { | 1153 | } else { |
1091 | pic_stream_buffer_addr = | 1154 | pic_stream_buffer_addr = |
1092 | vb2_dma_contig_plane_dma_addr(dst_buf, 0); | 1155 | vb2_dma_contig_plane_dma_addr(dst_buf, 0); |
1093 | pic_stream_buffer_size = CODA_MAX_FRAME_SIZE; | 1156 | pic_stream_buffer_size = q_data_dst->sizeimage; |
1094 | } | 1157 | } |
1095 | 1158 | ||
1096 | if (src_buf->v4l2_buf.flags & V4L2_BUF_FLAG_KEYFRAME) { | 1159 | if (src_buf->v4l2_buf.flags & V4L2_BUF_FLAG_KEYFRAME) { |
@@ -1102,6 +1165,9 @@ static int coda_prepare_encode(struct coda_ctx *ctx) | |||
1102 | case V4L2_PIX_FMT_MPEG4: | 1165 | case V4L2_PIX_FMT_MPEG4: |
1103 | quant_param = ctx->params.mpeg4_intra_qp; | 1166 | quant_param = ctx->params.mpeg4_intra_qp; |
1104 | break; | 1167 | break; |
1168 | case V4L2_PIX_FMT_JPEG: | ||
1169 | quant_param = 30; | ||
1170 | break; | ||
1105 | default: | 1171 | default: |
1106 | v4l2_warn(&ctx->dev->v4l2_dev, | 1172 | v4l2_warn(&ctx->dev->v4l2_dev, |
1107 | "cannot set intra qp, fmt not supported\n"); | 1173 | "cannot set intra qp, fmt not supported\n"); |
@@ -1124,42 +1190,22 @@ static int coda_prepare_encode(struct coda_ctx *ctx) | |||
1124 | } | 1190 | } |
1125 | 1191 | ||
1126 | /* submit */ | 1192 | /* submit */ |
1127 | coda_write(dev, CODA_ROT_MIR_ENABLE | ctx->params.rot_mode, | 1193 | if (ctx->params.rot_mode) |
1128 | CODA_CMD_ENC_PIC_ROT_MODE); | 1194 | rot_mode = CODA_ROT_MIR_ENABLE | ctx->params.rot_mode; |
1195 | coda_write(dev, rot_mode, CODA_CMD_ENC_PIC_ROT_MODE); | ||
1129 | coda_write(dev, quant_param, CODA_CMD_ENC_PIC_QS); | 1196 | coda_write(dev, quant_param, CODA_CMD_ENC_PIC_QS); |
1130 | 1197 | ||
1131 | |||
1132 | picture_y = vb2_dma_contig_plane_dma_addr(src_buf, 0); | ||
1133 | switch (q_data_src->fourcc) { | ||
1134 | case V4L2_PIX_FMT_YVU420: | ||
1135 | /* Switch Cb and Cr for YVU420 format */ | ||
1136 | picture_cr = picture_y + q_data_src->bytesperline * | ||
1137 | q_data_src->height; | ||
1138 | picture_cb = picture_cr + q_data_src->bytesperline / 2 * | ||
1139 | q_data_src->height / 2; | ||
1140 | break; | ||
1141 | case V4L2_PIX_FMT_YUV420: | ||
1142 | default: | ||
1143 | picture_cb = picture_y + q_data_src->bytesperline * | ||
1144 | q_data_src->height; | ||
1145 | picture_cr = picture_cb + q_data_src->bytesperline / 2 * | ||
1146 | q_data_src->height / 2; | ||
1147 | break; | ||
1148 | } | ||
1149 | |||
1150 | if (dev->devtype->product == CODA_960) { | 1198 | if (dev->devtype->product == CODA_960) { |
1151 | coda_write(dev, 4/*FIXME: 0*/, CODA9_CMD_ENC_PIC_SRC_INDEX); | 1199 | coda_write(dev, 4/*FIXME: 0*/, CODA9_CMD_ENC_PIC_SRC_INDEX); |
1152 | coda_write(dev, q_data_src->width, CODA9_CMD_ENC_PIC_SRC_STRIDE); | 1200 | coda_write(dev, q_data_src->width, CODA9_CMD_ENC_PIC_SRC_STRIDE); |
1153 | coda_write(dev, 0, CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC); | 1201 | coda_write(dev, 0, CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC); |
1154 | 1202 | ||
1155 | coda_write(dev, picture_y, CODA9_CMD_ENC_PIC_SRC_ADDR_Y); | 1203 | reg = CODA9_CMD_ENC_PIC_SRC_ADDR_Y; |
1156 | coda_write(dev, picture_cb, CODA9_CMD_ENC_PIC_SRC_ADDR_CB); | ||
1157 | coda_write(dev, picture_cr, CODA9_CMD_ENC_PIC_SRC_ADDR_CR); | ||
1158 | } else { | 1204 | } else { |
1159 | coda_write(dev, picture_y, CODA_CMD_ENC_PIC_SRC_ADDR_Y); | 1205 | reg = CODA_CMD_ENC_PIC_SRC_ADDR_Y; |
1160 | coda_write(dev, picture_cb, CODA_CMD_ENC_PIC_SRC_ADDR_CB); | ||
1161 | coda_write(dev, picture_cr, CODA_CMD_ENC_PIC_SRC_ADDR_CR); | ||
1162 | } | 1206 | } |
1207 | coda_write_base(ctx, q_data_src, src_buf, reg); | ||
1208 | |||
1163 | coda_write(dev, force_ipicture << 1 & 0x2, | 1209 | coda_write(dev, force_ipicture << 1 & 0x2, |
1164 | CODA_CMD_ENC_PIC_OPTION); | 1210 | CODA_CMD_ENC_PIC_OPTION); |
1165 | 1211 | ||
@@ -1293,7 +1339,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1293 | u32 bitstream_buf, bitstream_size; | 1339 | u32 bitstream_buf, bitstream_size; |
1294 | struct coda_dev *dev = ctx->dev; | 1340 | struct coda_dev *dev = ctx->dev; |
1295 | int width, height; | 1341 | int width, height; |
1296 | u32 src_fourcc; | 1342 | u32 src_fourcc, dst_fourcc; |
1297 | u32 val; | 1343 | u32 val; |
1298 | int ret; | 1344 | int ret; |
1299 | 1345 | ||
@@ -1303,6 +1349,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1303 | bitstream_buf = ctx->bitstream.paddr; | 1349 | bitstream_buf = ctx->bitstream.paddr; |
1304 | bitstream_size = ctx->bitstream.size; | 1350 | bitstream_size = ctx->bitstream.size; |
1305 | src_fourcc = q_data_src->fourcc; | 1351 | src_fourcc = q_data_src->fourcc; |
1352 | dst_fourcc = q_data_dst->fourcc; | ||
1306 | 1353 | ||
1307 | /* Allocate per-instance buffers */ | 1354 | /* Allocate per-instance buffers */ |
1308 | ret = coda_alloc_context_buffers(ctx, q_data_src); | 1355 | ret = coda_alloc_context_buffers(ctx, q_data_src); |
@@ -1314,6 +1361,11 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1314 | /* Update coda bitstream read and write pointers from kfifo */ | 1361 | /* Update coda bitstream read and write pointers from kfifo */ |
1315 | coda_kfifo_sync_to_device_full(ctx); | 1362 | coda_kfifo_sync_to_device_full(ctx); |
1316 | 1363 | ||
1364 | ctx->frame_mem_ctrl &= ~CODA_FRAME_CHROMA_INTERLEAVE; | ||
1365 | if (dst_fourcc == V4L2_PIX_FMT_NV12) | ||
1366 | ctx->frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE; | ||
1367 | coda_write(dev, ctx->frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL); | ||
1368 | |||
1317 | ctx->display_idx = -1; | 1369 | ctx->display_idx = -1; |
1318 | ctx->frm_dis_flg = 0; | 1370 | ctx->frm_dis_flg = 0; |
1319 | coda_write(dev, 0, CODA_REG_BIT_FRM_DIS_FLG(ctx->reg_idx)); | 1371 | coda_write(dev, 0, CODA_REG_BIT_FRM_DIS_FLG(ctx->reg_idx)); |
@@ -1327,6 +1379,8 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1327 | if ((dev->devtype->product == CODA_7541) || | 1379 | if ((dev->devtype->product == CODA_7541) || |
1328 | (dev->devtype->product == CODA_960)) | 1380 | (dev->devtype->product == CODA_960)) |
1329 | val |= CODA_REORDER_ENABLE; | 1381 | val |= CODA_REORDER_ENABLE; |
1382 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG) | ||
1383 | val |= CODA_NO_INT_ENABLE; | ||
1330 | coda_write(dev, val, CODA_CMD_DEC_SEQ_OPTION); | 1384 | coda_write(dev, val, CODA_CMD_DEC_SEQ_OPTION); |
1331 | 1385 | ||
1332 | ctx->params.codec_mode = ctx->codec->mode; | 1386 | ctx->params.codec_mode = ctx->codec->mode; |
@@ -1442,13 +1496,23 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1442 | } | 1496 | } |
1443 | 1497 | ||
1444 | if (dev->devtype->product == CODA_960) { | 1498 | if (dev->devtype->product == CODA_960) { |
1445 | coda_write(dev, -1, CODA9_CMD_SET_FRAME_DELAY); | 1499 | int cbb_size, crb_size; |
1446 | 1500 | ||
1501 | coda_write(dev, -1, CODA9_CMD_SET_FRAME_DELAY); | ||
1502 | /* Luma 2x0 page, 2x6 cache, chroma 2x0 page, 2x4 cache size */ | ||
1447 | coda_write(dev, 0x20262024, CODA9_CMD_SET_FRAME_CACHE_SIZE); | 1503 | coda_write(dev, 0x20262024, CODA9_CMD_SET_FRAME_CACHE_SIZE); |
1504 | |||
1505 | if (dst_fourcc == V4L2_PIX_FMT_NV12) { | ||
1506 | cbb_size = 0; | ||
1507 | crb_size = 16; | ||
1508 | } else { | ||
1509 | cbb_size = 8; | ||
1510 | crb_size = 8; | ||
1511 | } | ||
1448 | coda_write(dev, 2 << CODA9_CACHE_PAGEMERGE_OFFSET | | 1512 | coda_write(dev, 2 << CODA9_CACHE_PAGEMERGE_OFFSET | |
1449 | 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET | | 1513 | 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET | |
1450 | 8 << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET | | 1514 | cbb_size << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET | |
1451 | 8 << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET, | 1515 | crb_size << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET, |
1452 | CODA9_CMD_SET_FRAME_CACHE_CONFIG); | 1516 | CODA9_CMD_SET_FRAME_CACHE_CONFIG); |
1453 | } | 1517 | } |
1454 | 1518 | ||
@@ -1501,20 +1565,11 @@ static int coda_prepare_decode(struct coda_ctx *ctx) | |||
1501 | struct vb2_buffer *dst_buf; | 1565 | struct vb2_buffer *dst_buf; |
1502 | struct coda_dev *dev = ctx->dev; | 1566 | struct coda_dev *dev = ctx->dev; |
1503 | struct coda_q_data *q_data_dst; | 1567 | struct coda_q_data *q_data_dst; |
1504 | u32 stridey, height; | 1568 | u32 reg_addr, reg_stride; |
1505 | u32 picture_y, picture_cb, picture_cr; | ||
1506 | 1569 | ||
1507 | dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); | 1570 | dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); |
1508 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); | 1571 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); |
1509 | 1572 | ||
1510 | if (ctx->params.rot_mode & CODA_ROT_90) { | ||
1511 | stridey = q_data_dst->height; | ||
1512 | height = q_data_dst->width; | ||
1513 | } else { | ||
1514 | stridey = q_data_dst->width; | ||
1515 | height = q_data_dst->height; | ||
1516 | } | ||
1517 | |||
1518 | /* Try to copy source buffer contents into the bitstream ringbuffer */ | 1573 | /* Try to copy source buffer contents into the bitstream ringbuffer */ |
1519 | mutex_lock(&ctx->bitstream_mutex); | 1574 | mutex_lock(&ctx->bitstream_mutex); |
1520 | coda_fill_bitstream(ctx); | 1575 | coda_fill_bitstream(ctx); |
@@ -1545,17 +1600,6 @@ static int coda_prepare_decode(struct coda_ctx *ctx) | |||
1545 | if (dev->devtype->product == CODA_960) | 1600 | if (dev->devtype->product == CODA_960) |
1546 | coda_set_gdi_regs(ctx); | 1601 | coda_set_gdi_regs(ctx); |
1547 | 1602 | ||
1548 | /* Set rotator output */ | ||
1549 | picture_y = vb2_dma_contig_plane_dma_addr(dst_buf, 0); | ||
1550 | if (q_data_dst->fourcc == V4L2_PIX_FMT_YVU420) { | ||
1551 | /* Switch Cr and Cb for YVU420 format */ | ||
1552 | picture_cr = picture_y + stridey * height; | ||
1553 | picture_cb = picture_cr + stridey / 2 * height / 2; | ||
1554 | } else { | ||
1555 | picture_cb = picture_y + stridey * height; | ||
1556 | picture_cr = picture_cb + stridey / 2 * height / 2; | ||
1557 | } | ||
1558 | |||
1559 | if (dev->devtype->product == CODA_960) { | 1603 | if (dev->devtype->product == CODA_960) { |
1560 | /* | 1604 | /* |
1561 | * The CODA960 seems to have an internal list of buffers with | 1605 | * The CODA960 seems to have an internal list of buffers with |
@@ -1565,16 +1609,16 @@ static int coda_prepare_decode(struct coda_ctx *ctx) | |||
1565 | */ | 1609 | */ |
1566 | coda_write(dev, CODA_MAX_FRAMEBUFFERS + dst_buf->v4l2_buf.index, | 1610 | coda_write(dev, CODA_MAX_FRAMEBUFFERS + dst_buf->v4l2_buf.index, |
1567 | CODA9_CMD_DEC_PIC_ROT_INDEX); | 1611 | CODA9_CMD_DEC_PIC_ROT_INDEX); |
1568 | coda_write(dev, picture_y, CODA9_CMD_DEC_PIC_ROT_ADDR_Y); | 1612 | |
1569 | coda_write(dev, picture_cb, CODA9_CMD_DEC_PIC_ROT_ADDR_CB); | 1613 | reg_addr = CODA9_CMD_DEC_PIC_ROT_ADDR_Y; |
1570 | coda_write(dev, picture_cr, CODA9_CMD_DEC_PIC_ROT_ADDR_CR); | 1614 | reg_stride = CODA9_CMD_DEC_PIC_ROT_STRIDE; |
1571 | coda_write(dev, stridey, CODA9_CMD_DEC_PIC_ROT_STRIDE); | ||
1572 | } else { | 1615 | } else { |
1573 | coda_write(dev, picture_y, CODA_CMD_DEC_PIC_ROT_ADDR_Y); | 1616 | reg_addr = CODA_CMD_DEC_PIC_ROT_ADDR_Y; |
1574 | coda_write(dev, picture_cb, CODA_CMD_DEC_PIC_ROT_ADDR_CB); | 1617 | reg_stride = CODA_CMD_DEC_PIC_ROT_STRIDE; |
1575 | coda_write(dev, picture_cr, CODA_CMD_DEC_PIC_ROT_ADDR_CR); | ||
1576 | coda_write(dev, stridey, CODA_CMD_DEC_PIC_ROT_STRIDE); | ||
1577 | } | 1618 | } |
1619 | coda_write_base(ctx, q_data_dst, dst_buf, reg_addr); | ||
1620 | coda_write(dev, q_data_dst->bytesperline, reg_stride); | ||
1621 | |||
1578 | coda_write(dev, CODA_ROT_MIR_ENABLE | ctx->params.rot_mode, | 1622 | coda_write(dev, CODA_ROT_MIR_ENABLE | ctx->params.rot_mode, |
1579 | CODA_CMD_DEC_PIC_ROT_MODE); | 1623 | CODA_CMD_DEC_PIC_ROT_MODE); |
1580 | 1624 | ||
@@ -1599,6 +1643,26 @@ static int coda_prepare_decode(struct coda_ctx *ctx) | |||
1599 | coda_write(dev, ctx->iram_info.axi_sram_use, | 1643 | coda_write(dev, ctx->iram_info.axi_sram_use, |
1600 | CODA7_REG_BIT_AXI_SRAM_USE); | 1644 | CODA7_REG_BIT_AXI_SRAM_USE); |
1601 | 1645 | ||
1646 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG) { | ||
1647 | struct coda_buffer_meta *meta; | ||
1648 | |||
1649 | /* If this is the last buffer in the bitstream, add padding */ | ||
1650 | meta = list_first_entry(&ctx->buffer_meta_list, | ||
1651 | struct coda_buffer_meta, list); | ||
1652 | if (meta->end == (ctx->bitstream_fifo.kfifo.in & | ||
1653 | ctx->bitstream_fifo.kfifo.mask)) { | ||
1654 | static unsigned char buf[512]; | ||
1655 | unsigned int pad; | ||
1656 | |||
1657 | /* Pad to multiple of 256 and then add 256 more */ | ||
1658 | pad = ((0 - meta->end) & 0xff) + 256; | ||
1659 | |||
1660 | memset(buf, 0xff, sizeof(buf)); | ||
1661 | |||
1662 | kfifo_in(&ctx->bitstream_fifo, buf, pad); | ||
1663 | } | ||
1664 | } | ||
1665 | |||
1602 | coda_kfifo_sync_to_device_full(ctx); | 1666 | coda_kfifo_sync_to_device_full(ctx); |
1603 | 1667 | ||
1604 | coda_command_async(ctx, CODA_COMMAND_PIC_RUN); | 1668 | coda_command_async(ctx, CODA_COMMAND_PIC_RUN); |
@@ -1612,7 +1676,8 @@ static void coda_finish_decode(struct coda_ctx *ctx) | |||
1612 | struct coda_q_data *q_data_src; | 1676 | struct coda_q_data *q_data_src; |
1613 | struct coda_q_data *q_data_dst; | 1677 | struct coda_q_data *q_data_dst; |
1614 | struct vb2_buffer *dst_buf; | 1678 | struct vb2_buffer *dst_buf; |
1615 | struct coda_timestamp *ts; | 1679 | struct coda_buffer_meta *meta; |
1680 | unsigned long payload; | ||
1616 | int width, height; | 1681 | int width, height; |
1617 | int decoded_idx; | 1682 | int decoded_idx; |
1618 | int display_idx; | 1683 | int display_idx; |
@@ -1739,23 +1804,23 @@ static void coda_finish_decode(struct coda_ctx *ctx) | |||
1739 | val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM) - 1; | 1804 | val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM) - 1; |
1740 | val -= ctx->sequence_offset; | 1805 | val -= ctx->sequence_offset; |
1741 | mutex_lock(&ctx->bitstream_mutex); | 1806 | mutex_lock(&ctx->bitstream_mutex); |
1742 | if (!list_empty(&ctx->timestamp_list)) { | 1807 | if (!list_empty(&ctx->buffer_meta_list)) { |
1743 | ts = list_first_entry(&ctx->timestamp_list, | 1808 | meta = list_first_entry(&ctx->buffer_meta_list, |
1744 | struct coda_timestamp, list); | 1809 | struct coda_buffer_meta, list); |
1745 | list_del(&ts->list); | 1810 | list_del(&meta->list); |
1746 | if (val != (ts->sequence & 0xffff)) { | 1811 | if (val != (meta->sequence & 0xffff)) { |
1747 | v4l2_err(&dev->v4l2_dev, | 1812 | v4l2_err(&dev->v4l2_dev, |
1748 | "sequence number mismatch (%d(%d) != %d)\n", | 1813 | "sequence number mismatch (%d(%d) != %d)\n", |
1749 | val, ctx->sequence_offset, | 1814 | val, ctx->sequence_offset, |
1750 | ts->sequence); | 1815 | meta->sequence); |
1751 | } | 1816 | } |
1752 | ctx->frame_timestamps[decoded_idx] = *ts; | 1817 | ctx->frame_metas[decoded_idx] = *meta; |
1753 | kfree(ts); | 1818 | kfree(meta); |
1754 | } else { | 1819 | } else { |
1755 | v4l2_err(&dev->v4l2_dev, "empty timestamp list!\n"); | 1820 | v4l2_err(&dev->v4l2_dev, "empty timestamp list!\n"); |
1756 | memset(&ctx->frame_timestamps[decoded_idx], 0, | 1821 | memset(&ctx->frame_metas[decoded_idx], 0, |
1757 | sizeof(struct coda_timestamp)); | 1822 | sizeof(struct coda_buffer_meta)); |
1758 | ctx->frame_timestamps[decoded_idx].sequence = val; | 1823 | ctx->frame_metas[decoded_idx].sequence = val; |
1759 | } | 1824 | } |
1760 | mutex_unlock(&ctx->bitstream_mutex); | 1825 | mutex_unlock(&ctx->bitstream_mutex); |
1761 | 1826 | ||
@@ -1794,11 +1859,22 @@ static void coda_finish_decode(struct coda_ctx *ctx) | |||
1794 | V4L2_BUF_FLAG_PFRAME | | 1859 | V4L2_BUF_FLAG_PFRAME | |
1795 | V4L2_BUF_FLAG_BFRAME); | 1860 | V4L2_BUF_FLAG_BFRAME); |
1796 | dst_buf->v4l2_buf.flags |= ctx->frame_types[ctx->display_idx]; | 1861 | dst_buf->v4l2_buf.flags |= ctx->frame_types[ctx->display_idx]; |
1797 | ts = &ctx->frame_timestamps[ctx->display_idx]; | 1862 | meta = &ctx->frame_metas[ctx->display_idx]; |
1798 | dst_buf->v4l2_buf.timecode = ts->timecode; | 1863 | dst_buf->v4l2_buf.timecode = meta->timecode; |
1799 | dst_buf->v4l2_buf.timestamp = ts->timestamp; | 1864 | dst_buf->v4l2_buf.timestamp = meta->timestamp; |
1800 | 1865 | ||
1801 | vb2_set_plane_payload(dst_buf, 0, width * height * 3 / 2); | 1866 | switch (q_data_dst->fourcc) { |
1867 | case V4L2_PIX_FMT_YUV420: | ||
1868 | case V4L2_PIX_FMT_YVU420: | ||
1869 | case V4L2_PIX_FMT_NV12: | ||
1870 | default: | ||
1871 | payload = width * height * 3 / 2; | ||
1872 | break; | ||
1873 | case V4L2_PIX_FMT_YUV422P: | ||
1874 | payload = width * height * 2; | ||
1875 | break; | ||
1876 | } | ||
1877 | vb2_set_plane_payload(dst_buf, 0, payload); | ||
1802 | 1878 | ||
1803 | v4l2_m2m_buf_done(dst_buf, ctx->frame_errors[display_idx] ? | 1879 | v4l2_m2m_buf_done(dst_buf, ctx->frame_errors[display_idx] ? |
1804 | VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); | 1880 | VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); |
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index 5f0cd5cafea2..90b7791d36e1 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #define CODA_NAME "coda" | 43 | #define CODA_NAME "coda" |
44 | 44 | ||
45 | #define CODADX6_MAX_INSTANCES 4 | 45 | #define CODADX6_MAX_INSTANCES 4 |
46 | #define CODA_MAX_FORMATS 4 | ||
46 | 47 | ||
47 | #define CODA_PARA_BUF_SIZE (10 * 1024) | 48 | #define CODA_PARA_BUF_SIZE (10 * 1024) |
48 | #define CODA_ISRAM_SIZE (2048 * 2) | 49 | #define CODA_ISRAM_SIZE (2048 * 2) |
@@ -82,6 +83,34 @@ unsigned int coda_read(struct coda_dev *dev, u32 reg) | |||
82 | return data; | 83 | return data; |
83 | } | 84 | } |
84 | 85 | ||
86 | void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data, | ||
87 | struct vb2_buffer *buf, unsigned int reg_y) | ||
88 | { | ||
89 | u32 base_y = vb2_dma_contig_plane_dma_addr(buf, 0); | ||
90 | u32 base_cb, base_cr; | ||
91 | |||
92 | switch (q_data->fourcc) { | ||
93 | case V4L2_PIX_FMT_YVU420: | ||
94 | /* Switch Cb and Cr for YVU420 format */ | ||
95 | base_cr = base_y + q_data->bytesperline * q_data->height; | ||
96 | base_cb = base_cr + q_data->bytesperline * q_data->height / 4; | ||
97 | break; | ||
98 | case V4L2_PIX_FMT_YUV420: | ||
99 | case V4L2_PIX_FMT_NV12: | ||
100 | default: | ||
101 | base_cb = base_y + q_data->bytesperline * q_data->height; | ||
102 | base_cr = base_cb + q_data->bytesperline * q_data->height / 4; | ||
103 | break; | ||
104 | case V4L2_PIX_FMT_YUV422P: | ||
105 | base_cb = base_y + q_data->bytesperline * q_data->height; | ||
106 | base_cr = base_cb + q_data->bytesperline * q_data->height / 2; | ||
107 | } | ||
108 | |||
109 | coda_write(ctx->dev, base_y, reg_y); | ||
110 | coda_write(ctx->dev, base_cb, reg_y + 4); | ||
111 | coda_write(ctx->dev, base_cr, reg_y + 8); | ||
112 | } | ||
113 | |||
85 | /* | 114 | /* |
86 | * Array of all formats supported by any version of Coda: | 115 | * Array of all formats supported by any version of Coda: |
87 | */ | 116 | */ |
@@ -95,6 +124,14 @@ static const struct coda_fmt coda_formats[] = { | |||
95 | .fourcc = V4L2_PIX_FMT_YVU420, | 124 | .fourcc = V4L2_PIX_FMT_YVU420, |
96 | }, | 125 | }, |
97 | { | 126 | { |
127 | .name = "YUV 4:2:0 Partial interleaved Y/CbCr", | ||
128 | .fourcc = V4L2_PIX_FMT_NV12, | ||
129 | }, | ||
130 | { | ||
131 | .name = "YUV 4:2:2 Planar, YCbCr", | ||
132 | .fourcc = V4L2_PIX_FMT_YUV422P, | ||
133 | }, | ||
134 | { | ||
98 | .name = "H264 Encoded Stream", | 135 | .name = "H264 Encoded Stream", |
99 | .fourcc = V4L2_PIX_FMT_H264, | 136 | .fourcc = V4L2_PIX_FMT_H264, |
100 | }, | 137 | }, |
@@ -102,6 +139,10 @@ static const struct coda_fmt coda_formats[] = { | |||
102 | .name = "MPEG4 Encoded Stream", | 139 | .name = "MPEG4 Encoded Stream", |
103 | .fourcc = V4L2_PIX_FMT_MPEG4, | 140 | .fourcc = V4L2_PIX_FMT_MPEG4, |
104 | }, | 141 | }, |
142 | { | ||
143 | .name = "JPEG Encoded Images", | ||
144 | .fourcc = V4L2_PIX_FMT_JPEG, | ||
145 | }, | ||
105 | }; | 146 | }; |
106 | 147 | ||
107 | #define CODA_CODEC(mode, src_fourcc, dst_fourcc, max_w, max_h) \ | 148 | #define CODA_CODEC(mode, src_fourcc, dst_fourcc, max_w, max_h) \ |
@@ -122,8 +163,10 @@ static const struct coda_codec codadx6_codecs[] = { | |||
122 | static const struct coda_codec coda7_codecs[] = { | 163 | static const struct coda_codec coda7_codecs[] = { |
123 | CODA_CODEC(CODA7_MODE_ENCODE_H264, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_H264, 1280, 720), | 164 | CODA_CODEC(CODA7_MODE_ENCODE_H264, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_H264, 1280, 720), |
124 | CODA_CODEC(CODA7_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1280, 720), | 165 | CODA_CODEC(CODA7_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1280, 720), |
166 | CODA_CODEC(CODA7_MODE_ENCODE_MJPG, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_JPEG, 8192, 8192), | ||
125 | CODA_CODEC(CODA7_MODE_DECODE_H264, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_YUV420, 1920, 1088), | 167 | CODA_CODEC(CODA7_MODE_DECODE_H264, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_YUV420, 1920, 1088), |
126 | CODA_CODEC(CODA7_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088), | 168 | CODA_CODEC(CODA7_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088), |
169 | CODA_CODEC(CODA7_MODE_DECODE_MJPG, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_YUV420, 8192, 8192), | ||
127 | }; | 170 | }; |
128 | 171 | ||
129 | static const struct coda_codec coda9_codecs[] = { | 172 | static const struct coda_codec coda9_codecs[] = { |
@@ -133,17 +176,115 @@ static const struct coda_codec coda9_codecs[] = { | |||
133 | CODA_CODEC(CODA9_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088), | 176 | CODA_CODEC(CODA9_MODE_DECODE_MP4, V4L2_PIX_FMT_MPEG4, V4L2_PIX_FMT_YUV420, 1920, 1088), |
134 | }; | 177 | }; |
135 | 178 | ||
179 | struct coda_video_device { | ||
180 | const char *name; | ||
181 | enum coda_inst_type type; | ||
182 | const struct coda_context_ops *ops; | ||
183 | u32 src_formats[CODA_MAX_FORMATS]; | ||
184 | u32 dst_formats[CODA_MAX_FORMATS]; | ||
185 | }; | ||
186 | |||
187 | static const struct coda_video_device coda_bit_encoder = { | ||
188 | .name = "coda-encoder", | ||
189 | .type = CODA_INST_ENCODER, | ||
190 | .ops = &coda_bit_encode_ops, | ||
191 | .src_formats = { | ||
192 | V4L2_PIX_FMT_YUV420, | ||
193 | V4L2_PIX_FMT_YVU420, | ||
194 | V4L2_PIX_FMT_NV12, | ||
195 | }, | ||
196 | .dst_formats = { | ||
197 | V4L2_PIX_FMT_H264, | ||
198 | V4L2_PIX_FMT_MPEG4, | ||
199 | }, | ||
200 | }; | ||
201 | |||
202 | static const struct coda_video_device coda_bit_jpeg_encoder = { | ||
203 | .name = "coda-jpeg-encoder", | ||
204 | .type = CODA_INST_ENCODER, | ||
205 | .ops = &coda_bit_encode_ops, | ||
206 | .src_formats = { | ||
207 | V4L2_PIX_FMT_YUV420, | ||
208 | V4L2_PIX_FMT_YVU420, | ||
209 | V4L2_PIX_FMT_NV12, | ||
210 | V4L2_PIX_FMT_YUV422P, | ||
211 | }, | ||
212 | .dst_formats = { | ||
213 | V4L2_PIX_FMT_JPEG, | ||
214 | }, | ||
215 | }; | ||
216 | |||
217 | static const struct coda_video_device coda_bit_decoder = { | ||
218 | .name = "coda-decoder", | ||
219 | .type = CODA_INST_DECODER, | ||
220 | .ops = &coda_bit_decode_ops, | ||
221 | .src_formats = { | ||
222 | V4L2_PIX_FMT_H264, | ||
223 | V4L2_PIX_FMT_MPEG4, | ||
224 | }, | ||
225 | .dst_formats = { | ||
226 | V4L2_PIX_FMT_YUV420, | ||
227 | V4L2_PIX_FMT_YVU420, | ||
228 | V4L2_PIX_FMT_NV12, | ||
229 | }, | ||
230 | }; | ||
231 | |||
232 | static const struct coda_video_device coda_bit_jpeg_decoder = { | ||
233 | .name = "coda-jpeg-decoder", | ||
234 | .type = CODA_INST_DECODER, | ||
235 | .ops = &coda_bit_decode_ops, | ||
236 | .src_formats = { | ||
237 | V4L2_PIX_FMT_JPEG, | ||
238 | }, | ||
239 | .dst_formats = { | ||
240 | V4L2_PIX_FMT_YUV420, | ||
241 | V4L2_PIX_FMT_YVU420, | ||
242 | V4L2_PIX_FMT_NV12, | ||
243 | V4L2_PIX_FMT_YUV422P, | ||
244 | }, | ||
245 | }; | ||
246 | |||
247 | static const struct coda_video_device *codadx6_video_devices[] = { | ||
248 | &coda_bit_encoder, | ||
249 | }; | ||
250 | |||
251 | static const struct coda_video_device *coda7_video_devices[] = { | ||
252 | &coda_bit_jpeg_encoder, | ||
253 | &coda_bit_jpeg_decoder, | ||
254 | &coda_bit_encoder, | ||
255 | &coda_bit_decoder, | ||
256 | }; | ||
257 | |||
258 | static const struct coda_video_device *coda9_video_devices[] = { | ||
259 | &coda_bit_encoder, | ||
260 | &coda_bit_decoder, | ||
261 | }; | ||
262 | |||
136 | static bool coda_format_is_yuv(u32 fourcc) | 263 | static bool coda_format_is_yuv(u32 fourcc) |
137 | { | 264 | { |
138 | switch (fourcc) { | 265 | switch (fourcc) { |
139 | case V4L2_PIX_FMT_YUV420: | 266 | case V4L2_PIX_FMT_YUV420: |
140 | case V4L2_PIX_FMT_YVU420: | 267 | case V4L2_PIX_FMT_YVU420: |
268 | case V4L2_PIX_FMT_NV12: | ||
269 | case V4L2_PIX_FMT_YUV422P: | ||
141 | return true; | 270 | return true; |
142 | default: | 271 | default: |
143 | return false; | 272 | return false; |
144 | } | 273 | } |
145 | } | 274 | } |
146 | 275 | ||
276 | static const char *coda_format_name(u32 fourcc) | ||
277 | { | ||
278 | int i; | ||
279 | |||
280 | for (i = 0; i < ARRAY_SIZE(coda_formats); i++) { | ||
281 | if (coda_formats[i].fourcc == fourcc) | ||
282 | return coda_formats[i].name; | ||
283 | } | ||
284 | |||
285 | return NULL; | ||
286 | } | ||
287 | |||
147 | /* | 288 | /* |
148 | * Normalize all supported YUV 4:2:0 formats to the value used in the codec | 289 | * Normalize all supported YUV 4:2:0 formats to the value used in the codec |
149 | * tables. | 290 | * tables. |
@@ -202,6 +343,17 @@ static void coda_get_max_dimensions(struct coda_dev *dev, | |||
202 | *max_h = h; | 343 | *max_h = h; |
203 | } | 344 | } |
204 | 345 | ||
346 | const struct coda_video_device *to_coda_video_device(struct video_device *vdev) | ||
347 | { | ||
348 | struct coda_dev *dev = video_get_drvdata(vdev); | ||
349 | unsigned int i = vdev - dev->vfd; | ||
350 | |||
351 | if (i >= dev->devtype->num_vdevs) | ||
352 | return NULL; | ||
353 | |||
354 | return dev->devtype->vdevs[i]; | ||
355 | } | ||
356 | |||
205 | const char *coda_product_name(int product) | 357 | const char *coda_product_name(int product) |
206 | { | 358 | { |
207 | static char buf[9]; | 359 | static char buf[9]; |
@@ -240,58 +392,28 @@ static int coda_querycap(struct file *file, void *priv, | |||
240 | static int coda_enum_fmt(struct file *file, void *priv, | 392 | static int coda_enum_fmt(struct file *file, void *priv, |
241 | struct v4l2_fmtdesc *f) | 393 | struct v4l2_fmtdesc *f) |
242 | { | 394 | { |
243 | struct coda_ctx *ctx = fh_to_ctx(priv); | 395 | struct video_device *vdev = video_devdata(file); |
244 | const struct coda_codec *codecs = ctx->dev->devtype->codecs; | 396 | const struct coda_video_device *cvd = to_coda_video_device(vdev); |
245 | const struct coda_fmt *formats = coda_formats; | 397 | const u32 *formats; |
246 | const struct coda_fmt *fmt; | 398 | const char *name; |
247 | int num_codecs = ctx->dev->devtype->num_codecs; | 399 | |
248 | int num_formats = ARRAY_SIZE(coda_formats); | 400 | if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) |
249 | int i, k, num = 0; | 401 | formats = cvd->src_formats; |
250 | bool yuv; | 402 | else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) |
251 | 403 | formats = cvd->dst_formats; | |
252 | if (ctx->inst_type == CODA_INST_ENCODER) | ||
253 | yuv = (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT); | ||
254 | else | 404 | else |
255 | yuv = (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE); | 405 | return -EINVAL; |
256 | |||
257 | for (i = 0; i < num_formats; i++) { | ||
258 | /* Skip either raw or compressed formats */ | ||
259 | if (yuv != coda_format_is_yuv(formats[i].fourcc)) | ||
260 | continue; | ||
261 | /* All uncompressed formats are always supported */ | ||
262 | if (yuv) { | ||
263 | if (num == f->index) | ||
264 | break; | ||
265 | ++num; | ||
266 | continue; | ||
267 | } | ||
268 | /* Compressed formats may be supported, check the codec list */ | ||
269 | for (k = 0; k < num_codecs; k++) { | ||
270 | if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
271 | formats[i].fourcc == codecs[k].dst_fourcc) | ||
272 | break; | ||
273 | if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | ||
274 | formats[i].fourcc == codecs[k].src_fourcc) | ||
275 | break; | ||
276 | } | ||
277 | if (k < num_codecs) { | ||
278 | if (num == f->index) | ||
279 | break; | ||
280 | ++num; | ||
281 | } | ||
282 | } | ||
283 | 406 | ||
284 | if (i < num_formats) { | 407 | if (f->index >= CODA_MAX_FORMATS || formats[f->index] == 0) |
285 | fmt = &formats[i]; | 408 | return -EINVAL; |
286 | strlcpy(f->description, fmt->name, sizeof(f->description)); | 409 | |
287 | f->pixelformat = fmt->fourcc; | 410 | name = coda_format_name(formats[f->index]); |
288 | if (!yuv) | 411 | strlcpy(f->description, name, sizeof(f->description)); |
289 | f->flags |= V4L2_FMT_FLAG_COMPRESSED; | 412 | f->pixelformat = formats[f->index]; |
290 | return 0; | 413 | if (!coda_format_is_yuv(formats[f->index])) |
291 | } | 414 | f->flags |= V4L2_FMT_FLAG_COMPRESSED; |
292 | 415 | ||
293 | /* Format not found */ | 416 | return 0; |
294 | return -EINVAL; | ||
295 | } | 417 | } |
296 | 418 | ||
297 | static int coda_g_fmt(struct file *file, void *priv, | 419 | static int coda_g_fmt(struct file *file, void *priv, |
@@ -311,7 +433,37 @@ static int coda_g_fmt(struct file *file, void *priv, | |||
311 | f->fmt.pix.bytesperline = q_data->bytesperline; | 433 | f->fmt.pix.bytesperline = q_data->bytesperline; |
312 | 434 | ||
313 | f->fmt.pix.sizeimage = q_data->sizeimage; | 435 | f->fmt.pix.sizeimage = q_data->sizeimage; |
314 | f->fmt.pix.colorspace = ctx->colorspace; | 436 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_JPEG) |
437 | f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; | ||
438 | else | ||
439 | f->fmt.pix.colorspace = ctx->colorspace; | ||
440 | |||
441 | return 0; | ||
442 | } | ||
443 | |||
444 | static int coda_try_pixelformat(struct coda_ctx *ctx, struct v4l2_format *f) | ||
445 | { | ||
446 | struct coda_q_data *q_data; | ||
447 | const u32 *formats; | ||
448 | int i; | ||
449 | |||
450 | if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) | ||
451 | formats = ctx->cvd->src_formats; | ||
452 | else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
453 | formats = ctx->cvd->dst_formats; | ||
454 | else | ||
455 | return -EINVAL; | ||
456 | |||
457 | for (i = 0; i < CODA_MAX_FORMATS; i++) { | ||
458 | if (formats[i] == f->fmt.pix.pixelformat) { | ||
459 | f->fmt.pix.pixelformat = formats[i]; | ||
460 | return 0; | ||
461 | } | ||
462 | } | ||
463 | |||
464 | /* Fall back to currently set pixelformat */ | ||
465 | q_data = get_q_data(ctx, f->type); | ||
466 | f->fmt.pix.pixelformat = q_data->fourcc; | ||
315 | 467 | ||
316 | return 0; | 468 | return 0; |
317 | } | 469 | } |
@@ -320,7 +472,6 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec, | |||
320 | struct v4l2_format *f) | 472 | struct v4l2_format *f) |
321 | { | 473 | { |
322 | struct coda_dev *dev = ctx->dev; | 474 | struct coda_dev *dev = ctx->dev; |
323 | struct coda_q_data *q_data; | ||
324 | unsigned int max_w, max_h; | 475 | unsigned int max_w, max_h; |
325 | enum v4l2_field field; | 476 | enum v4l2_field field; |
326 | 477 | ||
@@ -342,30 +493,35 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec, | |||
342 | switch (f->fmt.pix.pixelformat) { | 493 | switch (f->fmt.pix.pixelformat) { |
343 | case V4L2_PIX_FMT_YUV420: | 494 | case V4L2_PIX_FMT_YUV420: |
344 | case V4L2_PIX_FMT_YVU420: | 495 | case V4L2_PIX_FMT_YVU420: |
345 | case V4L2_PIX_FMT_H264: | 496 | case V4L2_PIX_FMT_NV12: |
346 | case V4L2_PIX_FMT_MPEG4: | 497 | /* |
347 | case V4L2_PIX_FMT_JPEG: | 498 | * Frame stride must be at least multiple of 8, |
348 | break; | 499 | * but multiple of 16 for h.264 or JPEG 4:2:x |
349 | default: | 500 | */ |
350 | q_data = get_q_data(ctx, f->type); | ||
351 | if (!q_data) | ||
352 | return -EINVAL; | ||
353 | f->fmt.pix.pixelformat = q_data->fourcc; | ||
354 | } | ||
355 | |||
356 | switch (f->fmt.pix.pixelformat) { | ||
357 | case V4L2_PIX_FMT_YUV420: | ||
358 | case V4L2_PIX_FMT_YVU420: | ||
359 | /* Frame stride must be multiple of 8, but 16 for h.264 */ | ||
360 | f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16); | 501 | f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16); |
361 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * | 502 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * |
362 | f->fmt.pix.height * 3 / 2; | 503 | f->fmt.pix.height * 3 / 2; |
363 | break; | 504 | break; |
505 | case V4L2_PIX_FMT_YUV422P: | ||
506 | f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16); | ||
507 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * | ||
508 | f->fmt.pix.height * 2; | ||
509 | break; | ||
510 | case V4L2_PIX_FMT_JPEG: | ||
511 | f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; | ||
512 | /* fallthrough */ | ||
364 | case V4L2_PIX_FMT_H264: | 513 | case V4L2_PIX_FMT_H264: |
365 | case V4L2_PIX_FMT_MPEG4: | 514 | case V4L2_PIX_FMT_MPEG4: |
366 | case V4L2_PIX_FMT_JPEG: | ||
367 | f->fmt.pix.bytesperline = 0; | 515 | f->fmt.pix.bytesperline = 0; |
368 | f->fmt.pix.sizeimage = CODA_MAX_FRAME_SIZE; | 516 | /* |
517 | * This is a rough estimate for sensible compressed buffer | ||
518 | * sizes (between 1 and 16 bits per pixel). This could be | ||
519 | * improved by better format specific worst case estimates. | ||
520 | */ | ||
521 | f->fmt.pix.sizeimage = round_up(clamp(f->fmt.pix.sizeimage, | ||
522 | f->fmt.pix.width * f->fmt.pix.height / 8, | ||
523 | f->fmt.pix.width * f->fmt.pix.height * 2), | ||
524 | PAGE_SIZE); | ||
369 | break; | 525 | break; |
370 | default: | 526 | default: |
371 | BUG(); | 527 | BUG(); |
@@ -378,34 +534,35 @@ static int coda_try_fmt_vid_cap(struct file *file, void *priv, | |||
378 | struct v4l2_format *f) | 534 | struct v4l2_format *f) |
379 | { | 535 | { |
380 | struct coda_ctx *ctx = fh_to_ctx(priv); | 536 | struct coda_ctx *ctx = fh_to_ctx(priv); |
381 | const struct coda_codec *codec = NULL; | 537 | const struct coda_q_data *q_data_src; |
538 | const struct coda_codec *codec; | ||
382 | struct vb2_queue *src_vq; | 539 | struct vb2_queue *src_vq; |
383 | int ret; | 540 | int ret; |
384 | 541 | ||
542 | ret = coda_try_pixelformat(ctx, f); | ||
543 | if (ret < 0) | ||
544 | return ret; | ||
545 | |||
546 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | ||
547 | |||
385 | /* | 548 | /* |
386 | * If the source format is already fixed, try to find a codec that | 549 | * If the source format is already fixed, only allow the same output |
387 | * converts to the given destination format | 550 | * resolution |
388 | */ | 551 | */ |
389 | src_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | 552 | src_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); |
390 | if (vb2_is_streaming(src_vq)) { | 553 | if (vb2_is_streaming(src_vq)) { |
391 | struct coda_q_data *q_data_src; | ||
392 | |||
393 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | ||
394 | codec = coda_find_codec(ctx->dev, q_data_src->fourcc, | ||
395 | f->fmt.pix.pixelformat); | ||
396 | if (!codec) | ||
397 | return -EINVAL; | ||
398 | |||
399 | f->fmt.pix.width = q_data_src->width; | 554 | f->fmt.pix.width = q_data_src->width; |
400 | f->fmt.pix.height = q_data_src->height; | 555 | f->fmt.pix.height = q_data_src->height; |
401 | } else { | ||
402 | /* Otherwise determine codec by encoded format, if possible */ | ||
403 | codec = coda_find_codec(ctx->dev, V4L2_PIX_FMT_YUV420, | ||
404 | f->fmt.pix.pixelformat); | ||
405 | } | 556 | } |
406 | 557 | ||
407 | f->fmt.pix.colorspace = ctx->colorspace; | 558 | f->fmt.pix.colorspace = ctx->colorspace; |
408 | 559 | ||
560 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | ||
561 | codec = coda_find_codec(ctx->dev, q_data_src->fourcc, | ||
562 | f->fmt.pix.pixelformat); | ||
563 | if (!codec) | ||
564 | return -EINVAL; | ||
565 | |||
409 | ret = coda_try_fmt(ctx, codec, f); | 566 | ret = coda_try_fmt(ctx, codec, f); |
410 | if (ret < 0) | 567 | if (ret < 0) |
411 | return ret; | 568 | return ret; |
@@ -426,21 +583,24 @@ static int coda_try_fmt_vid_out(struct file *file, void *priv, | |||
426 | struct v4l2_format *f) | 583 | struct v4l2_format *f) |
427 | { | 584 | { |
428 | struct coda_ctx *ctx = fh_to_ctx(priv); | 585 | struct coda_ctx *ctx = fh_to_ctx(priv); |
429 | const struct coda_codec *codec = NULL; | 586 | struct coda_dev *dev = ctx->dev; |
587 | const struct coda_q_data *q_data_dst; | ||
588 | const struct coda_codec *codec; | ||
589 | int ret; | ||
430 | 590 | ||
431 | /* Determine codec by encoded format, returns NULL if raw or invalid */ | 591 | ret = coda_try_pixelformat(ctx, f); |
432 | if (ctx->inst_type == CODA_INST_DECODER) { | 592 | if (ret < 0) |
433 | codec = coda_find_codec(ctx->dev, f->fmt.pix.pixelformat, | 593 | return ret; |
434 | V4L2_PIX_FMT_YUV420); | 594 | |
435 | if (!codec) | 595 | if (!f->fmt.pix.colorspace) { |
436 | codec = coda_find_codec(ctx->dev, V4L2_PIX_FMT_H264, | 596 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_JPEG) |
437 | V4L2_PIX_FMT_YUV420); | 597 | f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; |
438 | if (!codec) | 598 | else |
439 | return -EINVAL; | 599 | f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; |
440 | } | 600 | } |
441 | 601 | ||
442 | if (!f->fmt.pix.colorspace) | 602 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); |
443 | f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; | 603 | codec = coda_find_codec(dev, f->fmt.pix.pixelformat, q_data_dst->fourcc); |
444 | 604 | ||
445 | return coda_try_fmt(ctx, codec, f); | 605 | return coda_try_fmt(ctx, codec, f); |
446 | } | 606 | } |
@@ -781,6 +941,7 @@ static int coda_job_ready(void *m2m_priv) | |||
781 | 941 | ||
782 | if (ctx->hold || | 942 | if (ctx->hold || |
783 | ((ctx->inst_type == CODA_INST_DECODER) && | 943 | ((ctx->inst_type == CODA_INST_DECODER) && |
944 | !v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) && | ||
784 | (coda_get_bitstream_payload(ctx) < 512) && | 945 | (coda_get_bitstream_payload(ctx) < 512) && |
785 | !(ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG))) { | 946 | !(ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG))) { |
786 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | 947 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, |
@@ -862,25 +1023,17 @@ static void coda_set_tiled_map_type(struct coda_ctx *ctx, int tiled_map_type) | |||
862 | 1023 | ||
863 | static void set_default_params(struct coda_ctx *ctx) | 1024 | static void set_default_params(struct coda_ctx *ctx) |
864 | { | 1025 | { |
865 | u32 src_fourcc, dst_fourcc; | 1026 | unsigned int max_w, max_h, size; |
866 | int max_w; | ||
867 | int max_h; | ||
868 | 1027 | ||
869 | if (ctx->inst_type == CODA_INST_ENCODER) { | 1028 | ctx->codec = coda_find_codec(ctx->dev, ctx->cvd->src_formats[0], |
870 | src_fourcc = V4L2_PIX_FMT_YUV420; | 1029 | ctx->cvd->dst_formats[0]); |
871 | dst_fourcc = V4L2_PIX_FMT_H264; | 1030 | max_w = min(ctx->codec->max_w, 1920U); |
872 | } else { | 1031 | max_h = min(ctx->codec->max_h, 1088U); |
873 | src_fourcc = V4L2_PIX_FMT_H264; | 1032 | size = max_w * max_h * 3 / 2; |
874 | dst_fourcc = V4L2_PIX_FMT_YUV420; | ||
875 | } | ||
876 | ctx->codec = coda_find_codec(ctx->dev, src_fourcc, dst_fourcc); | ||
877 | max_w = ctx->codec->max_w; | ||
878 | max_h = ctx->codec->max_h; | ||
879 | 1033 | ||
880 | ctx->params.codec_mode = ctx->codec->mode; | 1034 | ctx->params.codec_mode = ctx->codec->mode; |
881 | ctx->colorspace = V4L2_COLORSPACE_REC709; | 1035 | ctx->colorspace = V4L2_COLORSPACE_REC709; |
882 | ctx->params.framerate = 30; | 1036 | ctx->params.framerate = 30; |
883 | ctx->aborting = 0; | ||
884 | 1037 | ||
885 | /* Default formats for output and input queues */ | 1038 | /* Default formats for output and input queues */ |
886 | ctx->q_data[V4L2_M2M_SRC].fourcc = ctx->codec->src_fourcc; | 1039 | ctx->q_data[V4L2_M2M_SRC].fourcc = ctx->codec->src_fourcc; |
@@ -891,14 +1044,14 @@ static void set_default_params(struct coda_ctx *ctx) | |||
891 | ctx->q_data[V4L2_M2M_DST].height = max_h; | 1044 | ctx->q_data[V4L2_M2M_DST].height = max_h; |
892 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_YUV420) { | 1045 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_YUV420) { |
893 | ctx->q_data[V4L2_M2M_SRC].bytesperline = max_w; | 1046 | ctx->q_data[V4L2_M2M_SRC].bytesperline = max_w; |
894 | ctx->q_data[V4L2_M2M_SRC].sizeimage = (max_w * max_h * 3) / 2; | 1047 | ctx->q_data[V4L2_M2M_SRC].sizeimage = size; |
895 | ctx->q_data[V4L2_M2M_DST].bytesperline = 0; | 1048 | ctx->q_data[V4L2_M2M_DST].bytesperline = 0; |
896 | ctx->q_data[V4L2_M2M_DST].sizeimage = CODA_MAX_FRAME_SIZE; | 1049 | ctx->q_data[V4L2_M2M_DST].sizeimage = round_up(size, PAGE_SIZE); |
897 | } else { | 1050 | } else { |
898 | ctx->q_data[V4L2_M2M_SRC].bytesperline = 0; | 1051 | ctx->q_data[V4L2_M2M_SRC].bytesperline = 0; |
899 | ctx->q_data[V4L2_M2M_SRC].sizeimage = CODA_MAX_FRAME_SIZE; | 1052 | ctx->q_data[V4L2_M2M_SRC].sizeimage = round_up(size, PAGE_SIZE); |
900 | ctx->q_data[V4L2_M2M_DST].bytesperline = max_w; | 1053 | ctx->q_data[V4L2_M2M_DST].bytesperline = max_w; |
901 | ctx->q_data[V4L2_M2M_DST].sizeimage = (max_w * max_h * 3) / 2; | 1054 | ctx->q_data[V4L2_M2M_DST].sizeimage = size; |
902 | } | 1055 | } |
903 | ctx->q_data[V4L2_M2M_SRC].rect.width = max_w; | 1056 | ctx->q_data[V4L2_M2M_SRC].rect.width = max_w; |
904 | ctx->q_data[V4L2_M2M_SRC].rect.height = max_h; | 1057 | ctx->q_data[V4L2_M2M_SRC].rect.height = max_h; |
@@ -964,7 +1117,7 @@ static void coda_buf_queue(struct vb2_buffer *vb) | |||
964 | * In the decoder case, immediately try to copy the buffer into the | 1117 | * In the decoder case, immediately try to copy the buffer into the |
965 | * bitstream ringbuffer and mark it as ready to be dequeued. | 1118 | * bitstream ringbuffer and mark it as ready to be dequeued. |
966 | */ | 1119 | */ |
967 | if (q_data->fourcc == V4L2_PIX_FMT_H264 && | 1120 | if (ctx->inst_type == CODA_INST_DECODER && |
968 | vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { | 1121 | vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
969 | /* | 1122 | /* |
970 | * For backwards compatibility, queuing an empty buffer marks | 1123 | * For backwards compatibility, queuing an empty buffer marks |
@@ -1027,12 +1180,13 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) | |||
1027 | struct v4l2_device *v4l2_dev = &ctx->dev->v4l2_dev; | 1180 | struct v4l2_device *v4l2_dev = &ctx->dev->v4l2_dev; |
1028 | struct coda_q_data *q_data_src, *q_data_dst; | 1181 | struct coda_q_data *q_data_src, *q_data_dst; |
1029 | struct vb2_buffer *buf; | 1182 | struct vb2_buffer *buf; |
1030 | u32 dst_fourcc; | ||
1031 | int ret = 0; | 1183 | int ret = 0; |
1032 | 1184 | ||
1033 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | 1185 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); |
1034 | if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { | 1186 | if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
1035 | if (q_data_src->fourcc == V4L2_PIX_FMT_H264) { | 1187 | if (q_data_src->fourcc == V4L2_PIX_FMT_H264 || |
1188 | (q_data_src->fourcc == V4L2_PIX_FMT_JPEG && | ||
1189 | ctx->dev->devtype->product == CODA_7541)) { | ||
1036 | /* copy the buffers that where queued before streamon */ | 1190 | /* copy the buffers that where queued before streamon */ |
1037 | mutex_lock(&ctx->bitstream_mutex); | 1191 | mutex_lock(&ctx->bitstream_mutex); |
1038 | coda_fill_bitstream(ctx); | 1192 | coda_fill_bitstream(ctx); |
@@ -1063,13 +1217,12 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) | |||
1063 | if (!(ctx->streamon_out & ctx->streamon_cap)) | 1217 | if (!(ctx->streamon_out & ctx->streamon_cap)) |
1064 | return 0; | 1218 | return 0; |
1065 | 1219 | ||
1066 | /* Allow decoder device_run with no new buffers queued */ | 1220 | /* Allow BIT decoder device_run with no new buffers queued */ |
1067 | if (ctx->inst_type == CODA_INST_DECODER) | 1221 | if (ctx->inst_type == CODA_INST_DECODER) |
1068 | v4l2_m2m_set_src_buffered(ctx->fh.m2m_ctx, true); | 1222 | v4l2_m2m_set_src_buffered(ctx->fh.m2m_ctx, true); |
1069 | 1223 | ||
1070 | ctx->gopcounter = ctx->params.gop_size - 1; | 1224 | ctx->gopcounter = ctx->params.gop_size - 1; |
1071 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); | 1225 | q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); |
1072 | dst_fourcc = q_data_dst->fourcc; | ||
1073 | 1226 | ||
1074 | ctx->codec = coda_find_codec(ctx->dev, q_data_src->fourcc, | 1227 | ctx->codec = coda_find_codec(ctx->dev, q_data_src->fourcc, |
1075 | q_data_dst->fourcc); | 1228 | q_data_dst->fourcc); |
@@ -1079,6 +1232,10 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) | |||
1079 | goto err; | 1232 | goto err; |
1080 | } | 1233 | } |
1081 | 1234 | ||
1235 | if (q_data_dst->fourcc == V4L2_PIX_FMT_JPEG) | ||
1236 | ctx->params.gop_size = 1; | ||
1237 | ctx->gopcounter = ctx->params.gop_size - 1; | ||
1238 | |||
1082 | ret = ctx->ops->start_streaming(ctx); | 1239 | ret = ctx->ops->start_streaming(ctx); |
1083 | if (ctx->inst_type == CODA_INST_DECODER) { | 1240 | if (ctx->inst_type == CODA_INST_DECODER) { |
1084 | if (ret == -EAGAIN) | 1241 | if (ret == -EAGAIN) |
@@ -1093,10 +1250,10 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) | |||
1093 | err: | 1250 | err: |
1094 | if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { | 1251 | if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
1095 | while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx))) | 1252 | while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx))) |
1096 | v4l2_m2m_buf_done(buf, VB2_BUF_STATE_DEQUEUED); | 1253 | v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED); |
1097 | } else { | 1254 | } else { |
1098 | while ((buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx))) | 1255 | while ((buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx))) |
1099 | v4l2_m2m_buf_done(buf, VB2_BUF_STATE_DEQUEUED); | 1256 | v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED); |
1100 | } | 1257 | } |
1101 | return ret; | 1258 | return ret; |
1102 | } | 1259 | } |
@@ -1131,19 +1288,20 @@ static void coda_stop_streaming(struct vb2_queue *q) | |||
1131 | } | 1288 | } |
1132 | 1289 | ||
1133 | if (!ctx->streamon_out && !ctx->streamon_cap) { | 1290 | if (!ctx->streamon_out && !ctx->streamon_cap) { |
1134 | struct coda_timestamp *ts; | 1291 | struct coda_buffer_meta *meta; |
1135 | 1292 | ||
1136 | mutex_lock(&ctx->bitstream_mutex); | 1293 | mutex_lock(&ctx->bitstream_mutex); |
1137 | while (!list_empty(&ctx->timestamp_list)) { | 1294 | while (!list_empty(&ctx->buffer_meta_list)) { |
1138 | ts = list_first_entry(&ctx->timestamp_list, | 1295 | meta = list_first_entry(&ctx->buffer_meta_list, |
1139 | struct coda_timestamp, list); | 1296 | struct coda_buffer_meta, list); |
1140 | list_del(&ts->list); | 1297 | list_del(&meta->list); |
1141 | kfree(ts); | 1298 | kfree(meta); |
1142 | } | 1299 | } |
1143 | mutex_unlock(&ctx->bitstream_mutex); | 1300 | mutex_unlock(&ctx->bitstream_mutex); |
1144 | kfifo_init(&ctx->bitstream_fifo, | 1301 | kfifo_init(&ctx->bitstream_fifo, |
1145 | ctx->bitstream.vaddr, ctx->bitstream.size); | 1302 | ctx->bitstream.vaddr, ctx->bitstream.size); |
1146 | ctx->runcounter = 0; | 1303 | ctx->runcounter = 0; |
1304 | ctx->aborting = 0; | ||
1147 | } | 1305 | } |
1148 | } | 1306 | } |
1149 | 1307 | ||
@@ -1226,6 +1384,12 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl) | |||
1226 | case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: | 1384 | case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: |
1227 | ctx->params.intra_refresh = ctrl->val; | 1385 | ctx->params.intra_refresh = ctrl->val; |
1228 | break; | 1386 | break; |
1387 | case V4L2_CID_JPEG_COMPRESSION_QUALITY: | ||
1388 | coda_set_jpeg_compression_quality(ctx, ctrl->val); | ||
1389 | break; | ||
1390 | case V4L2_CID_JPEG_RESTART_INTERVAL: | ||
1391 | ctx->params.jpeg_restart_interval = ctrl->val; | ||
1392 | break; | ||
1229 | default: | 1393 | default: |
1230 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | 1394 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, |
1231 | "Invalid control, id=%d, val=%d\n", | 1395 | "Invalid control, id=%d, val=%d\n", |
@@ -1240,14 +1404,8 @@ static const struct v4l2_ctrl_ops coda_ctrl_ops = { | |||
1240 | .s_ctrl = coda_s_ctrl, | 1404 | .s_ctrl = coda_s_ctrl, |
1241 | }; | 1405 | }; |
1242 | 1406 | ||
1243 | static int coda_ctrls_setup(struct coda_ctx *ctx) | 1407 | static void coda_encode_ctrls(struct coda_ctx *ctx) |
1244 | { | 1408 | { |
1245 | v4l2_ctrl_handler_init(&ctx->ctrls, 9); | ||
1246 | |||
1247 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | ||
1248 | V4L2_CID_HFLIP, 0, 1, 1, 0); | ||
1249 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | ||
1250 | V4L2_CID_VFLIP, 0, 1, 1, 0); | ||
1251 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | 1409 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, |
1252 | V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1, 0); | 1410 | V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1, 0); |
1253 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | 1411 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, |
@@ -1291,6 +1449,30 @@ static int coda_ctrls_setup(struct coda_ctx *ctx) | |||
1291 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | 1449 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, |
1292 | V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, 0, | 1450 | V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, 0, |
1293 | 1920 * 1088 / 256, 1, 0); | 1451 | 1920 * 1088 / 256, 1, 0); |
1452 | } | ||
1453 | |||
1454 | static void coda_jpeg_encode_ctrls(struct coda_ctx *ctx) | ||
1455 | { | ||
1456 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | ||
1457 | V4L2_CID_JPEG_COMPRESSION_QUALITY, 5, 100, 1, 50); | ||
1458 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | ||
1459 | V4L2_CID_JPEG_RESTART_INTERVAL, 0, 100, 1, 0); | ||
1460 | } | ||
1461 | |||
1462 | static int coda_ctrls_setup(struct coda_ctx *ctx) | ||
1463 | { | ||
1464 | v4l2_ctrl_handler_init(&ctx->ctrls, 2); | ||
1465 | |||
1466 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | ||
1467 | V4L2_CID_HFLIP, 0, 1, 1, 0); | ||
1468 | v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, | ||
1469 | V4L2_CID_VFLIP, 0, 1, 1, 0); | ||
1470 | if (ctx->inst_type == CODA_INST_ENCODER) { | ||
1471 | if (ctx->cvd->dst_formats[0] == V4L2_PIX_FMT_JPEG) | ||
1472 | coda_jpeg_encode_ctrls(ctx); | ||
1473 | else | ||
1474 | coda_encode_ctrls(ctx); | ||
1475 | } | ||
1294 | 1476 | ||
1295 | if (ctx->ctrls.error) { | 1477 | if (ctx->ctrls.error) { |
1296 | v4l2_err(&ctx->dev->v4l2_dev, | 1478 | v4l2_err(&ctx->dev->v4l2_dev, |
@@ -1364,10 +1546,14 @@ static int coda_next_free_instance(struct coda_dev *dev) | |||
1364 | return idx; | 1546 | return idx; |
1365 | } | 1547 | } |
1366 | 1548 | ||
1367 | static int coda_open(struct file *file, enum coda_inst_type inst_type, | 1549 | /* |
1368 | const struct coda_context_ops *ctx_ops) | 1550 | * File operations |
1551 | */ | ||
1552 | |||
1553 | static int coda_open(struct file *file) | ||
1369 | { | 1554 | { |
1370 | struct coda_dev *dev = video_drvdata(file); | 1555 | struct video_device *vdev = video_devdata(file); |
1556 | struct coda_dev *dev = video_get_drvdata(vdev); | ||
1371 | struct coda_ctx *ctx = NULL; | 1557 | struct coda_ctx *ctx = NULL; |
1372 | char *name; | 1558 | char *name; |
1373 | int ret; | 1559 | int ret; |
@@ -1388,8 +1574,9 @@ static int coda_open(struct file *file, enum coda_inst_type inst_type, | |||
1388 | ctx->debugfs_entry = debugfs_create_dir(name, dev->debugfs_root); | 1574 | ctx->debugfs_entry = debugfs_create_dir(name, dev->debugfs_root); |
1389 | kfree(name); | 1575 | kfree(name); |
1390 | 1576 | ||
1391 | ctx->inst_type = inst_type; | 1577 | ctx->cvd = to_coda_video_device(vdev); |
1392 | ctx->ops = ctx_ops; | 1578 | ctx->inst_type = ctx->cvd->type; |
1579 | ctx->ops = ctx->cvd->ops; | ||
1393 | init_completion(&ctx->completion); | 1580 | init_completion(&ctx->completion); |
1394 | INIT_WORK(&ctx->pic_run_work, coda_pic_run_work); | 1581 | INIT_WORK(&ctx->pic_run_work, coda_pic_run_work); |
1395 | INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work); | 1582 | INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work); |
@@ -1399,8 +1586,10 @@ static int coda_open(struct file *file, enum coda_inst_type inst_type, | |||
1399 | ctx->dev = dev; | 1586 | ctx->dev = dev; |
1400 | ctx->idx = idx; | 1587 | ctx->idx = idx; |
1401 | switch (dev->devtype->product) { | 1588 | switch (dev->devtype->product) { |
1402 | case CODA_7541: | ||
1403 | case CODA_960: | 1589 | case CODA_960: |
1590 | ctx->frame_mem_ctrl = 1 << 12; | ||
1591 | /* fallthrough */ | ||
1592 | case CODA_7541: | ||
1404 | ctx->reg_idx = 0; | 1593 | ctx->reg_idx = 0; |
1405 | break; | 1594 | break; |
1406 | default: | 1595 | default: |
@@ -1441,16 +1630,17 @@ static int coda_open(struct file *file, enum coda_inst_type inst_type, | |||
1441 | 1630 | ||
1442 | ctx->fh.ctrl_handler = &ctx->ctrls; | 1631 | ctx->fh.ctrl_handler = &ctx->ctrls; |
1443 | 1632 | ||
1444 | ret = coda_alloc_context_buf(ctx, &ctx->parabuf, CODA_PARA_BUF_SIZE, | 1633 | ret = coda_alloc_context_buf(ctx, &ctx->parabuf, |
1445 | "parabuf"); | 1634 | CODA_PARA_BUF_SIZE, "parabuf"); |
1446 | if (ret < 0) { | 1635 | if (ret < 0) { |
1447 | v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf"); | 1636 | v4l2_err(&dev->v4l2_dev, "failed to allocate parabuf"); |
1448 | goto err_dma_alloc; | 1637 | goto err_dma_alloc; |
1449 | } | 1638 | } |
1450 | 1639 | ||
1451 | ctx->bitstream.size = CODA_MAX_FRAME_SIZE; | 1640 | ctx->bitstream.size = CODA_MAX_FRAME_SIZE; |
1452 | ctx->bitstream.vaddr = dma_alloc_writecombine(&dev->plat_dev->dev, | 1641 | ctx->bitstream.vaddr = dma_alloc_writecombine( |
1453 | ctx->bitstream.size, &ctx->bitstream.paddr, GFP_KERNEL); | 1642 | &dev->plat_dev->dev, ctx->bitstream.size, |
1643 | &ctx->bitstream.paddr, GFP_KERNEL); | ||
1454 | if (!ctx->bitstream.vaddr) { | 1644 | if (!ctx->bitstream.vaddr) { |
1455 | v4l2_err(&dev->v4l2_dev, | 1645 | v4l2_err(&dev->v4l2_dev, |
1456 | "failed to allocate bitstream ringbuffer"); | 1646 | "failed to allocate bitstream ringbuffer"); |
@@ -1461,7 +1651,7 @@ static int coda_open(struct file *file, enum coda_inst_type inst_type, | |||
1461 | ctx->bitstream.vaddr, ctx->bitstream.size); | 1651 | ctx->bitstream.vaddr, ctx->bitstream.size); |
1462 | mutex_init(&ctx->bitstream_mutex); | 1652 | mutex_init(&ctx->bitstream_mutex); |
1463 | mutex_init(&ctx->buffer_mutex); | 1653 | mutex_init(&ctx->buffer_mutex); |
1464 | INIT_LIST_HEAD(&ctx->timestamp_list); | 1654 | INIT_LIST_HEAD(&ctx->buffer_meta_list); |
1465 | 1655 | ||
1466 | coda_lock(ctx); | 1656 | coda_lock(ctx); |
1467 | list_add(&ctx->list, &dev->instances); | 1657 | list_add(&ctx->list, &dev->instances); |
@@ -1495,16 +1685,6 @@ err_coda_max: | |||
1495 | return ret; | 1685 | return ret; |
1496 | } | 1686 | } |
1497 | 1687 | ||
1498 | static int coda_encoder_open(struct file *file) | ||
1499 | { | ||
1500 | return coda_open(file, CODA_INST_ENCODER, &coda_bit_encode_ops); | ||
1501 | } | ||
1502 | |||
1503 | static int coda_decoder_open(struct file *file) | ||
1504 | { | ||
1505 | return coda_open(file, CODA_INST_DECODER, &coda_bit_decode_ops); | ||
1506 | } | ||
1507 | |||
1508 | static int coda_release(struct file *file) | 1688 | static int coda_release(struct file *file) |
1509 | { | 1689 | { |
1510 | struct coda_dev *dev = video_drvdata(file); | 1690 | struct coda_dev *dev = video_drvdata(file); |
@@ -1515,6 +1695,9 @@ static int coda_release(struct file *file) | |||
1515 | 1695 | ||
1516 | debugfs_remove_recursive(ctx->debugfs_entry); | 1696 | debugfs_remove_recursive(ctx->debugfs_entry); |
1517 | 1697 | ||
1698 | if (ctx->inst_type == CODA_INST_DECODER) | ||
1699 | coda_bit_stream_end_flag(ctx); | ||
1700 | |||
1518 | /* If this instance is running, call .job_abort and wait for it to end */ | 1701 | /* If this instance is running, call .job_abort and wait for it to end */ |
1519 | v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); | 1702 | v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); |
1520 | 1703 | ||
@@ -1528,8 +1711,10 @@ static int coda_release(struct file *file) | |||
1528 | list_del(&ctx->list); | 1711 | list_del(&ctx->list); |
1529 | coda_unlock(ctx); | 1712 | coda_unlock(ctx); |
1530 | 1713 | ||
1531 | dma_free_writecombine(&dev->plat_dev->dev, ctx->bitstream.size, | 1714 | if (ctx->bitstream.vaddr) { |
1532 | ctx->bitstream.vaddr, ctx->bitstream.paddr); | 1715 | dma_free_writecombine(&dev->plat_dev->dev, ctx->bitstream.size, |
1716 | ctx->bitstream.vaddr, ctx->bitstream.paddr); | ||
1717 | } | ||
1533 | if (ctx->dev->devtype->product == CODA_DX6) | 1718 | if (ctx->dev->devtype->product == CODA_DX6) |
1534 | coda_free_aux_buf(dev, &ctx->workbuf); | 1719 | coda_free_aux_buf(dev, &ctx->workbuf); |
1535 | 1720 | ||
@@ -1548,18 +1733,9 @@ static int coda_release(struct file *file) | |||
1548 | return 0; | 1733 | return 0; |
1549 | } | 1734 | } |
1550 | 1735 | ||
1551 | static const struct v4l2_file_operations coda_encoder_fops = { | 1736 | static const struct v4l2_file_operations coda_fops = { |
1552 | .owner = THIS_MODULE, | ||
1553 | .open = coda_encoder_open, | ||
1554 | .release = coda_release, | ||
1555 | .poll = v4l2_m2m_fop_poll, | ||
1556 | .unlocked_ioctl = video_ioctl2, | ||
1557 | .mmap = v4l2_m2m_fop_mmap, | ||
1558 | }; | ||
1559 | |||
1560 | static const struct v4l2_file_operations coda_decoder_fops = { | ||
1561 | .owner = THIS_MODULE, | 1737 | .owner = THIS_MODULE, |
1562 | .open = coda_decoder_open, | 1738 | .open = coda_open, |
1563 | .release = coda_release, | 1739 | .release = coda_release, |
1564 | .poll = v4l2_m2m_fop_poll, | 1740 | .poll = v4l2_m2m_fop_poll, |
1565 | .unlocked_ioctl = video_ioctl2, | 1741 | .unlocked_ioctl = video_ioctl2, |
@@ -1664,8 +1840,16 @@ err_clk_per: | |||
1664 | return ret; | 1840 | return ret; |
1665 | } | 1841 | } |
1666 | 1842 | ||
1667 | static int coda_register_device(struct coda_dev *dev, struct video_device *vfd) | 1843 | static int coda_register_device(struct coda_dev *dev, int i) |
1668 | { | 1844 | { |
1845 | struct video_device *vfd = &dev->vfd[i]; | ||
1846 | |||
1847 | if (i > ARRAY_SIZE(dev->vfd)) | ||
1848 | return -EINVAL; | ||
1849 | |||
1850 | snprintf(vfd->name, sizeof(vfd->name), dev->devtype->vdevs[i]->name); | ||
1851 | vfd->fops = &coda_fops; | ||
1852 | vfd->ioctl_ops = &coda_ioctl_ops; | ||
1669 | vfd->release = video_device_release_empty, | 1853 | vfd->release = video_device_release_empty, |
1670 | vfd->lock = &dev->dev_mutex; | 1854 | vfd->lock = &dev->dev_mutex; |
1671 | vfd->v4l2_dev = &dev->v4l2_dev; | 1855 | vfd->v4l2_dev = &dev->v4l2_dev; |
@@ -1684,7 +1868,7 @@ static void coda_fw_callback(const struct firmware *fw, void *context) | |||
1684 | { | 1868 | { |
1685 | struct coda_dev *dev = context; | 1869 | struct coda_dev *dev = context; |
1686 | struct platform_device *pdev = dev->plat_dev; | 1870 | struct platform_device *pdev = dev->plat_dev; |
1687 | int ret; | 1871 | int i, ret; |
1688 | 1872 | ||
1689 | if (!fw) { | 1873 | if (!fw) { |
1690 | v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); | 1874 | v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); |
@@ -1725,33 +1909,25 @@ static void coda_fw_callback(const struct firmware *fw, void *context) | |||
1725 | goto rel_ctx; | 1909 | goto rel_ctx; |
1726 | } | 1910 | } |
1727 | 1911 | ||
1728 | dev->vfd[0].fops = &coda_encoder_fops, | 1912 | for (i = 0; i < dev->devtype->num_vdevs; i++) { |
1729 | dev->vfd[0].ioctl_ops = &coda_ioctl_ops; | 1913 | ret = coda_register_device(dev, i); |
1730 | snprintf(dev->vfd[0].name, sizeof(dev->vfd[0].name), "coda-encoder"); | 1914 | if (ret) { |
1731 | ret = coda_register_device(dev, &dev->vfd[0]); | 1915 | v4l2_err(&dev->v4l2_dev, |
1732 | if (ret) { | 1916 | "Failed to register %s video device: %d\n", |
1733 | v4l2_err(&dev->v4l2_dev, | 1917 | dev->devtype->vdevs[i]->name, ret); |
1734 | "Failed to register encoder video device\n"); | 1918 | goto rel_vfd; |
1735 | goto rel_m2m; | 1919 | } |
1736 | } | ||
1737 | |||
1738 | dev->vfd[1].fops = &coda_decoder_fops, | ||
1739 | dev->vfd[1].ioctl_ops = &coda_ioctl_ops; | ||
1740 | snprintf(dev->vfd[1].name, sizeof(dev->vfd[1].name), "coda-decoder"); | ||
1741 | ret = coda_register_device(dev, &dev->vfd[1]); | ||
1742 | if (ret) { | ||
1743 | v4l2_err(&dev->v4l2_dev, | ||
1744 | "Failed to register decoder video device\n"); | ||
1745 | goto rel_m2m; | ||
1746 | } | 1920 | } |
1747 | 1921 | ||
1748 | v4l2_info(&dev->v4l2_dev, "codec registered as /dev/video[%d-%d]\n", | 1922 | v4l2_info(&dev->v4l2_dev, "codec registered as /dev/video[%d-%d]\n", |
1749 | dev->vfd[0].num, dev->vfd[1].num); | 1923 | dev->vfd[0].num, dev->vfd[i - 1].num); |
1750 | 1924 | ||
1751 | pm_runtime_put_sync(&pdev->dev); | 1925 | pm_runtime_put_sync(&pdev->dev); |
1752 | return; | 1926 | return; |
1753 | 1927 | ||
1754 | rel_m2m: | 1928 | rel_vfd: |
1929 | while (--i >= 0) | ||
1930 | video_unregister_device(&dev->vfd[i]); | ||
1755 | v4l2_m2m_release(dev->m2m_dev); | 1931 | v4l2_m2m_release(dev->m2m_dev); |
1756 | rel_ctx: | 1932 | rel_ctx: |
1757 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); | 1933 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); |
@@ -1783,6 +1959,8 @@ static const struct coda_devtype coda_devdata[] = { | |||
1783 | .product = CODA_DX6, | 1959 | .product = CODA_DX6, |
1784 | .codecs = codadx6_codecs, | 1960 | .codecs = codadx6_codecs, |
1785 | .num_codecs = ARRAY_SIZE(codadx6_codecs), | 1961 | .num_codecs = ARRAY_SIZE(codadx6_codecs), |
1962 | .vdevs = codadx6_video_devices, | ||
1963 | .num_vdevs = ARRAY_SIZE(codadx6_video_devices), | ||
1786 | .workbuf_size = 288 * 1024 + FMO_SLICE_SAVE_BUF_SIZE * 8 * 1024, | 1964 | .workbuf_size = 288 * 1024 + FMO_SLICE_SAVE_BUF_SIZE * 8 * 1024, |
1787 | .iram_size = 0xb000, | 1965 | .iram_size = 0xb000, |
1788 | }, | 1966 | }, |
@@ -1791,6 +1969,8 @@ static const struct coda_devtype coda_devdata[] = { | |||
1791 | .product = CODA_7541, | 1969 | .product = CODA_7541, |
1792 | .codecs = coda7_codecs, | 1970 | .codecs = coda7_codecs, |
1793 | .num_codecs = ARRAY_SIZE(coda7_codecs), | 1971 | .num_codecs = ARRAY_SIZE(coda7_codecs), |
1972 | .vdevs = coda7_video_devices, | ||
1973 | .num_vdevs = ARRAY_SIZE(coda7_video_devices), | ||
1794 | .workbuf_size = 128 * 1024, | 1974 | .workbuf_size = 128 * 1024, |
1795 | .tempbuf_size = 304 * 1024, | 1975 | .tempbuf_size = 304 * 1024, |
1796 | .iram_size = 0x14000, | 1976 | .iram_size = 0x14000, |
@@ -1800,6 +1980,8 @@ static const struct coda_devtype coda_devdata[] = { | |||
1800 | .product = CODA_960, | 1980 | .product = CODA_960, |
1801 | .codecs = coda9_codecs, | 1981 | .codecs = coda9_codecs, |
1802 | .num_codecs = ARRAY_SIZE(coda9_codecs), | 1982 | .num_codecs = ARRAY_SIZE(coda9_codecs), |
1983 | .vdevs = coda9_video_devices, | ||
1984 | .num_vdevs = ARRAY_SIZE(coda9_video_devices), | ||
1803 | .workbuf_size = 80 * 1024, | 1985 | .workbuf_size = 80 * 1024, |
1804 | .tempbuf_size = 204 * 1024, | 1986 | .tempbuf_size = 204 * 1024, |
1805 | .iram_size = 0x21000, | 1987 | .iram_size = 0x21000, |
@@ -1809,6 +1991,8 @@ static const struct coda_devtype coda_devdata[] = { | |||
1809 | .product = CODA_960, | 1991 | .product = CODA_960, |
1810 | .codecs = coda9_codecs, | 1992 | .codecs = coda9_codecs, |
1811 | .num_codecs = ARRAY_SIZE(coda9_codecs), | 1993 | .num_codecs = ARRAY_SIZE(coda9_codecs), |
1994 | .vdevs = coda9_video_devices, | ||
1995 | .num_vdevs = ARRAY_SIZE(coda9_video_devices), | ||
1812 | .workbuf_size = 80 * 1024, | 1996 | .workbuf_size = 80 * 1024, |
1813 | .tempbuf_size = 204 * 1024, | 1997 | .tempbuf_size = 204 * 1024, |
1814 | .iram_size = 0x20000, | 1998 | .iram_size = 0x20000, |
@@ -1846,10 +2030,18 @@ static int coda_probe(struct platform_device *pdev) | |||
1846 | int ret, irq; | 2030 | int ret, irq; |
1847 | 2031 | ||
1848 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); | 2032 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); |
1849 | if (!dev) { | 2033 | if (!dev) |
1850 | dev_err(&pdev->dev, "Not enough memory for %s\n", | ||
1851 | CODA_NAME); | ||
1852 | return -ENOMEM; | 2034 | return -ENOMEM; |
2035 | |||
2036 | pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); | ||
2037 | |||
2038 | if (of_id) { | ||
2039 | dev->devtype = of_id->data; | ||
2040 | } else if (pdev_id) { | ||
2041 | dev->devtype = &coda_devdata[pdev_id->driver_data]; | ||
2042 | } else { | ||
2043 | ret = -EINVAL; | ||
2044 | goto err_v4l2_register; | ||
1853 | } | 2045 | } |
1854 | 2046 | ||
1855 | spin_lock_init(&dev->irqlock); | 2047 | spin_lock_init(&dev->irqlock); |
@@ -1919,17 +2111,6 @@ static int coda_probe(struct platform_device *pdev) | |||
1919 | mutex_init(&dev->dev_mutex); | 2111 | mutex_init(&dev->dev_mutex); |
1920 | mutex_init(&dev->coda_mutex); | 2112 | mutex_init(&dev->coda_mutex); |
1921 | 2113 | ||
1922 | pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); | ||
1923 | |||
1924 | if (of_id) { | ||
1925 | dev->devtype = of_id->data; | ||
1926 | } else if (pdev_id) { | ||
1927 | dev->devtype = &coda_devdata[pdev_id->driver_data]; | ||
1928 | } else { | ||
1929 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1930 | return -EINVAL; | ||
1931 | } | ||
1932 | |||
1933 | dev->debugfs_root = debugfs_create_dir("coda", NULL); | 2114 | dev->debugfs_root = debugfs_create_dir("coda", NULL); |
1934 | if (!dev->debugfs_root) | 2115 | if (!dev->debugfs_root) |
1935 | dev_warn(&pdev->dev, "failed to create debugfs root\n"); | 2116 | dev_warn(&pdev->dev, "failed to create debugfs root\n"); |
@@ -1941,8 +2122,7 @@ static int coda_probe(struct platform_device *pdev) | |||
1941 | dev->debugfs_root); | 2122 | dev->debugfs_root); |
1942 | if (ret < 0) { | 2123 | if (ret < 0) { |
1943 | dev_err(&pdev->dev, "failed to allocate work buffer\n"); | 2124 | dev_err(&pdev->dev, "failed to allocate work buffer\n"); |
1944 | v4l2_device_unregister(&dev->v4l2_dev); | 2125 | goto err_v4l2_register; |
1945 | return ret; | ||
1946 | } | 2126 | } |
1947 | } | 2127 | } |
1948 | 2128 | ||
@@ -1952,8 +2132,7 @@ static int coda_probe(struct platform_device *pdev) | |||
1952 | dev->debugfs_root); | 2132 | dev->debugfs_root); |
1953 | if (ret < 0) { | 2133 | if (ret < 0) { |
1954 | dev_err(&pdev->dev, "failed to allocate temp buffer\n"); | 2134 | dev_err(&pdev->dev, "failed to allocate temp buffer\n"); |
1955 | v4l2_device_unregister(&dev->v4l2_dev); | 2135 | goto err_v4l2_register; |
1956 | return ret; | ||
1957 | } | 2136 | } |
1958 | } | 2137 | } |
1959 | 2138 | ||
@@ -1973,7 +2152,8 @@ static int coda_probe(struct platform_device *pdev) | |||
1973 | dev->workqueue = alloc_workqueue("coda", WQ_UNBOUND | WQ_MEM_RECLAIM, 1); | 2152 | dev->workqueue = alloc_workqueue("coda", WQ_UNBOUND | WQ_MEM_RECLAIM, 1); |
1974 | if (!dev->workqueue) { | 2153 | if (!dev->workqueue) { |
1975 | dev_err(&pdev->dev, "unable to alloc workqueue\n"); | 2154 | dev_err(&pdev->dev, "unable to alloc workqueue\n"); |
1976 | return -ENOMEM; | 2155 | ret = -ENOMEM; |
2156 | goto err_v4l2_register; | ||
1977 | } | 2157 | } |
1978 | 2158 | ||
1979 | platform_set_drvdata(pdev, dev); | 2159 | platform_set_drvdata(pdev, dev); |
@@ -1988,14 +2168,21 @@ static int coda_probe(struct platform_device *pdev) | |||
1988 | pm_runtime_enable(&pdev->dev); | 2168 | pm_runtime_enable(&pdev->dev); |
1989 | 2169 | ||
1990 | return coda_firmware_request(dev); | 2170 | return coda_firmware_request(dev); |
2171 | |||
2172 | err_v4l2_register: | ||
2173 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2174 | return ret; | ||
1991 | } | 2175 | } |
1992 | 2176 | ||
1993 | static int coda_remove(struct platform_device *pdev) | 2177 | static int coda_remove(struct platform_device *pdev) |
1994 | { | 2178 | { |
1995 | struct coda_dev *dev = platform_get_drvdata(pdev); | 2179 | struct coda_dev *dev = platform_get_drvdata(pdev); |
2180 | int i; | ||
1996 | 2181 | ||
1997 | video_unregister_device(&dev->vfd[0]); | 2182 | for (i = 0; i < ARRAY_SIZE(dev->vfd); i++) { |
1998 | video_unregister_device(&dev->vfd[1]); | 2183 | if (video_get_drvdata(&dev->vfd[i])) |
2184 | video_unregister_device(&dev->vfd[i]); | ||
2185 | } | ||
1999 | if (dev->m2m_dev) | 2186 | if (dev->m2m_dev) |
2000 | v4l2_m2m_release(dev->m2m_dev); | 2187 | v4l2_m2m_release(dev->m2m_dev); |
2001 | pm_runtime_disable(&pdev->dev); | 2188 | pm_runtime_disable(&pdev->dev); |
diff --git a/drivers/media/platform/coda/coda-jpeg.c b/drivers/media/platform/coda/coda-jpeg.c new file mode 100644 index 000000000000..8fa3e353f9e2 --- /dev/null +++ b/drivers/media/platform/coda/coda-jpeg.c | |||
@@ -0,0 +1,238 @@ | |||
1 | /* | ||
2 | * Coda multi-standard codec IP - JPEG support functions | ||
3 | * | ||
4 | * Copyright (C) 2014 Philipp Zabel, Pengutronix | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/swab.h> | ||
14 | |||
15 | #include "coda.h" | ||
16 | |||
17 | #define SOI_MARKER 0xffd8 | ||
18 | #define EOI_MARKER 0xffd9 | ||
19 | |||
20 | /* | ||
21 | * Typical Huffman tables for 8-bit precision luminance and | ||
22 | * chrominance from JPEG ITU-T.81 (ISO/IEC 10918-1) Annex K.3 | ||
23 | */ | ||
24 | |||
25 | static const unsigned char luma_dc_bits[16] = { | ||
26 | 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, | ||
27 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
28 | }; | ||
29 | |||
30 | static const unsigned char luma_dc_value[12] = { | ||
31 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | ||
32 | 0x08, 0x09, 0x0a, 0x0b, | ||
33 | }; | ||
34 | |||
35 | static const unsigned char chroma_dc_bits[16] = { | ||
36 | 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, | ||
37 | 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
38 | }; | ||
39 | |||
40 | static const unsigned char chroma_dc_value[12] = { | ||
41 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | ||
42 | 0x08, 0x09, 0x0a, 0x0b, | ||
43 | }; | ||
44 | |||
45 | static const unsigned char luma_ac_bits[16] = { | ||
46 | 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, | ||
47 | 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, | ||
48 | }; | ||
49 | |||
50 | static const unsigned char luma_ac_value[162 + 2] = { | ||
51 | 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, | ||
52 | 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, | ||
53 | 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, | ||
54 | 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, | ||
55 | 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, | ||
56 | 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, | ||
57 | 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, | ||
58 | 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, | ||
59 | 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, | ||
60 | 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, | ||
61 | 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, | ||
62 | 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, | ||
63 | 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, | ||
64 | 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, | ||
65 | 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, | ||
66 | 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, | ||
67 | 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, | ||
68 | 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, | ||
69 | 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, | ||
70 | 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, | ||
71 | 0xf9, 0xfa, /* padded to 32-bit */ | ||
72 | }; | ||
73 | |||
74 | static const unsigned char chroma_ac_bits[16] = { | ||
75 | 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, | ||
76 | 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, | ||
77 | }; | ||
78 | |||
79 | static const unsigned char chroma_ac_value[162 + 2] = { | ||
80 | 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, | ||
81 | 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, | ||
82 | 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, | ||
83 | 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, | ||
84 | 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, | ||
85 | 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, | ||
86 | 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, | ||
87 | 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, | ||
88 | 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, | ||
89 | 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, | ||
90 | 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, | ||
91 | 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, | ||
92 | 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, | ||
93 | 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, | ||
94 | 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, | ||
95 | 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, | ||
96 | 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, | ||
97 | 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, | ||
98 | 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, | ||
99 | 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, | ||
100 | 0xf9, 0xfa, /* padded to 32-bit */ | ||
101 | }; | ||
102 | |||
103 | /* | ||
104 | * Quantization tables for luminance and chrominance components in | ||
105 | * zig-zag scan order from the Freescale i.MX VPU libaries | ||
106 | */ | ||
107 | |||
108 | static unsigned char luma_q[64] = { | ||
109 | 0x06, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x05, | ||
110 | 0x05, 0x06, 0x09, 0x06, 0x05, 0x06, 0x09, 0x0b, | ||
111 | 0x08, 0x06, 0x06, 0x08, 0x0b, 0x0c, 0x0a, 0x0a, | ||
112 | 0x0b, 0x0a, 0x0a, 0x0c, 0x10, 0x0c, 0x0c, 0x0c, | ||
113 | 0x0c, 0x0c, 0x0c, 0x10, 0x0c, 0x0c, 0x0c, 0x0c, | ||
114 | 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
115 | 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
116 | 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
117 | }; | ||
118 | |||
119 | static unsigned char chroma_q[64] = { | ||
120 | 0x07, 0x07, 0x07, 0x0d, 0x0c, 0x0d, 0x18, 0x10, | ||
121 | 0x10, 0x18, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, | ||
122 | 0x0e, 0x0e, 0x0e, 0x0e, 0x14, 0x11, 0x0c, 0x0c, | ||
123 | 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, | ||
124 | 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, | ||
125 | 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
126 | 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
127 | 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, | ||
128 | }; | ||
129 | |||
130 | struct coda_memcpy_desc { | ||
131 | int offset; | ||
132 | const void *src; | ||
133 | size_t len; | ||
134 | }; | ||
135 | |||
136 | static void coda_memcpy_parabuf(void *parabuf, | ||
137 | const struct coda_memcpy_desc *desc) | ||
138 | { | ||
139 | u32 *dst = parabuf + desc->offset; | ||
140 | const u32 *src = desc->src; | ||
141 | int len = desc->len / 4; | ||
142 | int i; | ||
143 | |||
144 | for (i = 0; i < len; i += 2) { | ||
145 | dst[i + 1] = swab32(src[i]); | ||
146 | dst[i] = swab32(src[i + 1]); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | int coda_jpeg_write_tables(struct coda_ctx *ctx) | ||
151 | { | ||
152 | int i; | ||
153 | static const struct coda_memcpy_desc huff[8] = { | ||
154 | { 0, luma_dc_bits, sizeof(luma_dc_bits) }, | ||
155 | { 16, luma_dc_value, sizeof(luma_dc_value) }, | ||
156 | { 32, luma_ac_bits, sizeof(luma_ac_bits) }, | ||
157 | { 48, luma_ac_value, sizeof(luma_ac_value) }, | ||
158 | { 216, chroma_dc_bits, sizeof(chroma_dc_bits) }, | ||
159 | { 232, chroma_dc_value, sizeof(chroma_dc_value) }, | ||
160 | { 248, chroma_ac_bits, sizeof(chroma_ac_bits) }, | ||
161 | { 264, chroma_ac_value, sizeof(chroma_ac_value) }, | ||
162 | }; | ||
163 | struct coda_memcpy_desc qmat[3] = { | ||
164 | { 512, ctx->params.jpeg_qmat_tab[0], 64 }, | ||
165 | { 576, ctx->params.jpeg_qmat_tab[1], 64 }, | ||
166 | { 640, ctx->params.jpeg_qmat_tab[1], 64 }, | ||
167 | }; | ||
168 | |||
169 | /* Write huffman tables to parameter memory */ | ||
170 | for (i = 0; i < ARRAY_SIZE(huff); i++) | ||
171 | coda_memcpy_parabuf(ctx->parabuf.vaddr, huff + i); | ||
172 | |||
173 | /* Write Q-matrix to parameter memory */ | ||
174 | for (i = 0; i < ARRAY_SIZE(qmat); i++) | ||
175 | coda_memcpy_parabuf(ctx->parabuf.vaddr, qmat + i); | ||
176 | |||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb) | ||
181 | { | ||
182 | void *vaddr = vb2_plane_vaddr(vb, 0); | ||
183 | u16 soi = be16_to_cpup((__be16 *)vaddr); | ||
184 | u16 eoi = be16_to_cpup((__be16 *)(vaddr + | ||
185 | vb2_get_plane_payload(vb, 0) - 2)); | ||
186 | |||
187 | return soi == SOI_MARKER && eoi == EOI_MARKER; | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * Scale quantization table using nonlinear scaling factor | ||
192 | * u8 qtab[64], scale [50,190] | ||
193 | */ | ||
194 | static void coda_scale_quant_table(u8 *q_tab, int scale) | ||
195 | { | ||
196 | unsigned int temp; | ||
197 | int i; | ||
198 | |||
199 | for (i = 0; i < 64; i++) { | ||
200 | temp = DIV_ROUND_CLOSEST((unsigned int)q_tab[i] * scale, 100); | ||
201 | if (temp <= 0) | ||
202 | temp = 1; | ||
203 | if (temp > 255) | ||
204 | temp = 255; | ||
205 | q_tab[i] = (unsigned char)temp; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality) | ||
210 | { | ||
211 | unsigned int scale; | ||
212 | |||
213 | ctx->params.jpeg_quality = quality; | ||
214 | |||
215 | /* Clip quality setting to [5,100] interval */ | ||
216 | if (quality > 100) | ||
217 | quality = 100; | ||
218 | if (quality < 5) | ||
219 | quality = 5; | ||
220 | |||
221 | /* | ||
222 | * Non-linear scaling factor: | ||
223 | * [5,50] -> [1000..100], [51,100] -> [98..0] | ||
224 | */ | ||
225 | if (quality < 50) | ||
226 | scale = 5000 / quality; | ||
227 | else | ||
228 | scale = 200 - 2 * quality; | ||
229 | |||
230 | if (ctx->params.jpeg_qmat_tab[0]) { | ||
231 | memcpy(ctx->params.jpeg_qmat_tab[0], luma_q, 64); | ||
232 | coda_scale_quant_table(ctx->params.jpeg_qmat_tab[0], scale); | ||
233 | } | ||
234 | if (ctx->params.jpeg_qmat_tab[1]) { | ||
235 | memcpy(ctx->params.jpeg_qmat_tab[1], chroma_q, 64); | ||
236 | coda_scale_quant_table(ctx->params.jpeg_qmat_tab[1], scale); | ||
237 | } | ||
238 | } | ||
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h index bbc18c0dacd9..5dd47e5f97c1 100644 --- a/drivers/media/platform/coda/coda.h +++ b/drivers/media/platform/coda/coda.h | |||
@@ -45,11 +45,15 @@ enum coda_product { | |||
45 | CODA_960 = 0xf020, | 45 | CODA_960 = 0xf020, |
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct coda_video_device; | ||
49 | |||
48 | struct coda_devtype { | 50 | struct coda_devtype { |
49 | char *firmware; | 51 | char *firmware; |
50 | enum coda_product product; | 52 | enum coda_product product; |
51 | const struct coda_codec *codecs; | 53 | const struct coda_codec *codecs; |
52 | unsigned int num_codecs; | 54 | unsigned int num_codecs; |
55 | const struct coda_video_device **vdevs; | ||
56 | unsigned int num_vdevs; | ||
53 | size_t workbuf_size; | 57 | size_t workbuf_size; |
54 | size_t tempbuf_size; | 58 | size_t tempbuf_size; |
55 | size_t iram_size; | 59 | size_t iram_size; |
@@ -65,7 +69,7 @@ struct coda_aux_buf { | |||
65 | 69 | ||
66 | struct coda_dev { | 70 | struct coda_dev { |
67 | struct v4l2_device v4l2_dev; | 71 | struct v4l2_device v4l2_dev; |
68 | struct video_device vfd[2]; | 72 | struct video_device vfd[5]; |
69 | struct platform_device *plat_dev; | 73 | struct platform_device *plat_dev; |
70 | const struct coda_devtype *devtype; | 74 | const struct coda_devtype *devtype; |
71 | 75 | ||
@@ -114,6 +118,9 @@ struct coda_params { | |||
114 | u8 mpeg4_inter_qp; | 118 | u8 mpeg4_inter_qp; |
115 | u8 gop_size; | 119 | u8 gop_size; |
116 | int intra_refresh; | 120 | int intra_refresh; |
121 | u8 jpeg_quality; | ||
122 | u8 jpeg_restart_interval; | ||
123 | u8 *jpeg_qmat_tab[3]; | ||
117 | int codec_mode; | 124 | int codec_mode; |
118 | int codec_mode_aux; | 125 | int codec_mode_aux; |
119 | enum v4l2_mpeg_video_multi_slice_mode slice_mode; | 126 | enum v4l2_mpeg_video_multi_slice_mode slice_mode; |
@@ -123,11 +130,13 @@ struct coda_params { | |||
123 | u32 slice_max_mb; | 130 | u32 slice_max_mb; |
124 | }; | 131 | }; |
125 | 132 | ||
126 | struct coda_timestamp { | 133 | struct coda_buffer_meta { |
127 | struct list_head list; | 134 | struct list_head list; |
128 | u32 sequence; | 135 | u32 sequence; |
129 | struct v4l2_timecode timecode; | 136 | struct v4l2_timecode timecode; |
130 | struct timeval timestamp; | 137 | struct timeval timestamp; |
138 | u32 start; | ||
139 | u32 end; | ||
131 | }; | 140 | }; |
132 | 141 | ||
133 | /* Per-queue, driver-specific private data */ | 142 | /* Per-queue, driver-specific private data */ |
@@ -183,6 +192,7 @@ struct coda_ctx { | |||
183 | struct work_struct pic_run_work; | 192 | struct work_struct pic_run_work; |
184 | struct work_struct seq_end_work; | 193 | struct work_struct seq_end_work; |
185 | struct completion completion; | 194 | struct completion completion; |
195 | const struct coda_video_device *cvd; | ||
186 | const struct coda_context_ops *ops; | 196 | const struct coda_context_ops *ops; |
187 | int aborting; | 197 | int aborting; |
188 | int initialized; | 198 | int initialized; |
@@ -212,9 +222,9 @@ struct coda_ctx { | |||
212 | struct coda_aux_buf slicebuf; | 222 | struct coda_aux_buf slicebuf; |
213 | struct coda_aux_buf internal_frames[CODA_MAX_FRAMEBUFFERS]; | 223 | struct coda_aux_buf internal_frames[CODA_MAX_FRAMEBUFFERS]; |
214 | u32 frame_types[CODA_MAX_FRAMEBUFFERS]; | 224 | u32 frame_types[CODA_MAX_FRAMEBUFFERS]; |
215 | struct coda_timestamp frame_timestamps[CODA_MAX_FRAMEBUFFERS]; | 225 | struct coda_buffer_meta frame_metas[CODA_MAX_FRAMEBUFFERS]; |
216 | u32 frame_errors[CODA_MAX_FRAMEBUFFERS]; | 226 | u32 frame_errors[CODA_MAX_FRAMEBUFFERS]; |
217 | struct list_head timestamp_list; | 227 | struct list_head buffer_meta_list; |
218 | struct coda_aux_buf workbuf; | 228 | struct coda_aux_buf workbuf; |
219 | int num_internal_frames; | 229 | int num_internal_frames; |
220 | int idx; | 230 | int idx; |
@@ -232,6 +242,8 @@ extern int coda_debug; | |||
232 | 242 | ||
233 | void coda_write(struct coda_dev *dev, u32 data, u32 reg); | 243 | void coda_write(struct coda_dev *dev, u32 data, u32 reg); |
234 | unsigned int coda_read(struct coda_dev *dev, u32 reg); | 244 | unsigned int coda_read(struct coda_dev *dev, u32 reg); |
245 | void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data, | ||
246 | struct vb2_buffer *buf, unsigned int reg_y); | ||
235 | 247 | ||
236 | int coda_alloc_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf, | 248 | int coda_alloc_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf, |
237 | size_t size, const char *name, struct dentry *parent); | 249 | size_t size, const char *name, struct dentry *parent); |
@@ -281,6 +293,10 @@ void coda_bit_stream_end_flag(struct coda_ctx *ctx); | |||
281 | 293 | ||
282 | int coda_h264_padding(int size, char *p); | 294 | int coda_h264_padding(int size, char *p); |
283 | 295 | ||
296 | bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb); | ||
297 | int coda_jpeg_write_tables(struct coda_ctx *ctx); | ||
298 | void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality); | ||
299 | |||
284 | extern const struct coda_context_ops coda_bit_encode_ops; | 300 | extern const struct coda_context_ops coda_bit_encode_ops; |
285 | extern const struct coda_context_ops coda_bit_decode_ops; | 301 | extern const struct coda_context_ops coda_bit_decode_ops; |
286 | 302 | ||
diff --git a/drivers/media/platform/coda/coda_regs.h b/drivers/media/platform/coda/coda_regs.h index c791275e307b..8e015b8aa8fa 100644 --- a/drivers/media/platform/coda/coda_regs.h +++ b/drivers/media/platform/coda/coda_regs.h | |||
@@ -147,6 +147,7 @@ | |||
147 | #define CODA_CMD_DEC_SEQ_BB_START 0x180 | 147 | #define CODA_CMD_DEC_SEQ_BB_START 0x180 |
148 | #define CODA_CMD_DEC_SEQ_BB_SIZE 0x184 | 148 | #define CODA_CMD_DEC_SEQ_BB_SIZE 0x184 |
149 | #define CODA_CMD_DEC_SEQ_OPTION 0x188 | 149 | #define CODA_CMD_DEC_SEQ_OPTION 0x188 |
150 | #define CODA_NO_INT_ENABLE (1 << 10) | ||
150 | #define CODA_REORDER_ENABLE (1 << 1) | 151 | #define CODA_REORDER_ENABLE (1 << 1) |
151 | #define CODADX6_QP_REPORT (1 << 0) | 152 | #define CODADX6_QP_REPORT (1 << 0) |
152 | #define CODA7_MP4_DEBLK_ENABLE (1 << 0) | 153 | #define CODA7_MP4_DEBLK_ENABLE (1 << 0) |
@@ -332,6 +333,12 @@ | |||
332 | #define CODA9_CMD_ENC_SEQ_ME_OPTION 0x1d8 | 333 | #define CODA9_CMD_ENC_SEQ_ME_OPTION 0x1d8 |
333 | #define CODA_RET_ENC_SEQ_SUCCESS 0x1c0 | 334 | #define CODA_RET_ENC_SEQ_SUCCESS 0x1c0 |
334 | 335 | ||
336 | #define CODA_CMD_ENC_SEQ_JPG_PARA 0x198 | ||
337 | #define CODA_CMD_ENC_SEQ_JPG_RST_INTERVAL 0x19C | ||
338 | #define CODA_CMD_ENC_SEQ_JPG_THUMB_EN 0x1a0 | ||
339 | #define CODA_CMD_ENC_SEQ_JPG_THUMB_SIZE 0x1a4 | ||
340 | #define CODA_CMD_ENC_SEQ_JPG_THUMB_OFFSET 0x1a8 | ||
341 | |||
335 | /* Encoder Picture Run */ | 342 | /* Encoder Picture Run */ |
336 | #define CODA9_CMD_ENC_PIC_SRC_INDEX 0x180 | 343 | #define CODA9_CMD_ENC_PIC_SRC_INDEX 0x180 |
337 | #define CODA9_CMD_ENC_PIC_SRC_STRIDE 0x184 | 344 | #define CODA9_CMD_ENC_PIC_SRC_STRIDE 0x184 |
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c index 33b9660b7f77..244d3d6c244c 100644 --- a/drivers/media/platform/davinci/vpbe.c +++ b/drivers/media/platform/davinci/vpbe.c | |||
@@ -227,7 +227,7 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index) | |||
227 | vpbe_current_encoder_info(vpbe_dev); | 227 | vpbe_current_encoder_info(vpbe_dev); |
228 | struct vpbe_config *cfg = vpbe_dev->cfg; | 228 | struct vpbe_config *cfg = vpbe_dev->cfg; |
229 | struct venc_platform_data *venc_device = vpbe_dev->venc_device; | 229 | struct venc_platform_data *venc_device = vpbe_dev->venc_device; |
230 | enum v4l2_mbus_pixelcode if_params; | 230 | u32 if_params; |
231 | int enc_out_index; | 231 | int enc_out_index; |
232 | int sd_index; | 232 | int sd_index; |
233 | int ret = 0; | 233 | int ret = 0; |
@@ -341,7 +341,7 @@ static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev, | |||
341 | 341 | ||
342 | if (!(cfg->outputs[out_index].output.capabilities & | 342 | if (!(cfg->outputs[out_index].output.capabilities & |
343 | V4L2_OUT_CAP_DV_TIMINGS)) | 343 | V4L2_OUT_CAP_DV_TIMINGS)) |
344 | return -EINVAL; | 344 | return -ENODATA; |
345 | 345 | ||
346 | for (i = 0; i < output->num_modes; i++) { | 346 | for (i = 0; i < output->num_modes; i++) { |
347 | if (output->modes[i].timings_type == VPBE_ENC_DV_TIMINGS && | 347 | if (output->modes[i].timings_type == VPBE_ENC_DV_TIMINGS && |
@@ -384,6 +384,13 @@ static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev, | |||
384 | static int vpbe_g_dv_timings(struct vpbe_device *vpbe_dev, | 384 | static int vpbe_g_dv_timings(struct vpbe_device *vpbe_dev, |
385 | struct v4l2_dv_timings *dv_timings) | 385 | struct v4l2_dv_timings *dv_timings) |
386 | { | 386 | { |
387 | struct vpbe_config *cfg = vpbe_dev->cfg; | ||
388 | int out_index = vpbe_dev->current_out_index; | ||
389 | |||
390 | if (!(cfg->outputs[out_index].output.capabilities & | ||
391 | V4L2_OUT_CAP_DV_TIMINGS)) | ||
392 | return -ENODATA; | ||
393 | |||
387 | if (vpbe_dev->current_timings.timings_type & | 394 | if (vpbe_dev->current_timings.timings_type & |
388 | VPBE_ENC_DV_TIMINGS) { | 395 | VPBE_ENC_DV_TIMINGS) { |
389 | *dv_timings = vpbe_dev->current_timings.dv_timings; | 396 | *dv_timings = vpbe_dev->current_timings.dv_timings; |
@@ -409,7 +416,7 @@ static int vpbe_enum_dv_timings(struct vpbe_device *vpbe_dev, | |||
409 | int i; | 416 | int i; |
410 | 417 | ||
411 | if (!(output->output.capabilities & V4L2_OUT_CAP_DV_TIMINGS)) | 418 | if (!(output->output.capabilities & V4L2_OUT_CAP_DV_TIMINGS)) |
412 | return -EINVAL; | 419 | return -ENODATA; |
413 | 420 | ||
414 | for (i = 0; i < output->num_modes; i++) { | 421 | for (i = 0; i < output->num_modes; i++) { |
415 | if (output->modes[i].timings_type == VPBE_ENC_DV_TIMINGS) { | 422 | if (output->modes[i].timings_type == VPBE_ENC_DV_TIMINGS) { |
@@ -440,7 +447,7 @@ static int vpbe_s_std(struct vpbe_device *vpbe_dev, v4l2_std_id std_id) | |||
440 | 447 | ||
441 | if (!(cfg->outputs[out_index].output.capabilities & | 448 | if (!(cfg->outputs[out_index].output.capabilities & |
442 | V4L2_OUT_CAP_STD)) | 449 | V4L2_OUT_CAP_STD)) |
443 | return -EINVAL; | 450 | return -ENODATA; |
444 | 451 | ||
445 | ret = vpbe_get_std_info(vpbe_dev, std_id); | 452 | ret = vpbe_get_std_info(vpbe_dev, std_id); |
446 | if (ret) | 453 | if (ret) |
@@ -473,6 +480,11 @@ static int vpbe_s_std(struct vpbe_device *vpbe_dev, v4l2_std_id std_id) | |||
473 | static int vpbe_g_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id) | 480 | static int vpbe_g_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id) |
474 | { | 481 | { |
475 | struct vpbe_enc_mode_info *cur_timings = &vpbe_dev->current_timings; | 482 | struct vpbe_enc_mode_info *cur_timings = &vpbe_dev->current_timings; |
483 | struct vpbe_config *cfg = vpbe_dev->cfg; | ||
484 | int out_index = vpbe_dev->current_out_index; | ||
485 | |||
486 | if (!(cfg->outputs[out_index].output.capabilities & V4L2_OUT_CAP_STD)) | ||
487 | return -ENODATA; | ||
476 | 488 | ||
477 | if (cur_timings->timings_type & VPBE_ENC_STD) { | 489 | if (cur_timings->timings_type & VPBE_ENC_STD) { |
478 | *std_id = cur_timings->std_id; | 490 | *std_id = cur_timings->std_id; |
@@ -613,6 +625,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) | |||
613 | } | 625 | } |
614 | if (clk_prepare_enable(vpbe_dev->dac_clk)) { | 626 | if (clk_prepare_enable(vpbe_dev->dac_clk)) { |
615 | ret = -ENODEV; | 627 | ret = -ENODEV; |
628 | clk_put(vpbe_dev->dac_clk); | ||
616 | goto fail_mutex_unlock; | 629 | goto fail_mutex_unlock; |
617 | } | 630 | } |
618 | } | 631 | } |
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 73496d953ba0..21a5a56eb5ea 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c | |||
@@ -152,8 +152,8 @@ static irqreturn_t venc_isr(int irq, void *arg) | |||
152 | 152 | ||
153 | for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { | 153 | for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { |
154 | layer = disp_dev->dev[i]; | 154 | layer = disp_dev->dev[i]; |
155 | /* If streaming is started in this layer */ | 155 | |
156 | if (!layer->started) | 156 | if (!vb2_start_streaming_called(&layer->buffer_queue)) |
157 | continue; | 157 | continue; |
158 | 158 | ||
159 | if (layer->layer_first_int) { | 159 | if (layer->layer_first_int) { |
@@ -207,31 +207,23 @@ static irqreturn_t venc_isr(int irq, void *arg) | |||
207 | */ | 207 | */ |
208 | static int vpbe_buffer_prepare(struct vb2_buffer *vb) | 208 | static int vpbe_buffer_prepare(struct vb2_buffer *vb) |
209 | { | 209 | { |
210 | struct vpbe_fh *fh = vb2_get_drv_priv(vb->vb2_queue); | ||
211 | struct vb2_queue *q = vb->vb2_queue; | 210 | struct vb2_queue *q = vb->vb2_queue; |
212 | struct vpbe_layer *layer = fh->layer; | 211 | struct vpbe_layer *layer = vb2_get_drv_priv(q); |
213 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 212 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
214 | unsigned long addr; | 213 | unsigned long addr; |
215 | 214 | ||
216 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | 215 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, |
217 | "vpbe_buffer_prepare\n"); | 216 | "vpbe_buffer_prepare\n"); |
218 | 217 | ||
219 | if (vb->state != VB2_BUF_STATE_ACTIVE && | 218 | vb2_set_plane_payload(vb, 0, layer->pix_fmt.sizeimage); |
220 | vb->state != VB2_BUF_STATE_PREPARED) { | 219 | if (vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) |
221 | vb2_set_plane_payload(vb, 0, layer->pix_fmt.sizeimage); | 220 | return -EINVAL; |
222 | if (vb2_plane_vaddr(vb, 0) && | ||
223 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) | ||
224 | return -EINVAL; | ||
225 | 221 | ||
226 | addr = vb2_dma_contig_plane_dma_addr(vb, 0); | 222 | addr = vb2_dma_contig_plane_dma_addr(vb, 0); |
227 | if (q->streaming) { | 223 | if (!IS_ALIGNED(addr, 8)) { |
228 | if (!IS_ALIGNED(addr, 8)) { | 224 | v4l2_err(&vpbe_dev->v4l2_dev, |
229 | v4l2_err(&vpbe_dev->v4l2_dev, | 225 | "buffer_prepare:offset is not aligned to 32 bytes\n"); |
230 | "buffer_prepare:offset is \ | 226 | return -EINVAL; |
231 | not aligned to 32 bytes\n"); | ||
232 | return -EINVAL; | ||
233 | } | ||
234 | } | ||
235 | } | 227 | } |
236 | return 0; | 228 | return 0; |
237 | } | 229 | } |
@@ -247,18 +239,20 @@ vpbe_buffer_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
247 | 239 | ||
248 | { | 240 | { |
249 | /* Get the file handle object and layer object */ | 241 | /* Get the file handle object and layer object */ |
250 | struct vpbe_fh *fh = vb2_get_drv_priv(vq); | 242 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); |
251 | struct vpbe_layer *layer = fh->layer; | 243 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
252 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
253 | 244 | ||
254 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n"); | 245 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n"); |
255 | 246 | ||
247 | if (fmt && fmt->fmt.pix.sizeimage < layer->pix_fmt.sizeimage) | ||
248 | return -EINVAL; | ||
249 | |||
256 | /* Store number of buffers allocated in numbuffer member */ | 250 | /* Store number of buffers allocated in numbuffer member */ |
257 | if (*nbuffers < VPBE_DEFAULT_NUM_BUFS) | 251 | if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS) |
258 | *nbuffers = layer->numbuffers = VPBE_DEFAULT_NUM_BUFS; | 252 | *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers; |
259 | 253 | ||
260 | *nplanes = 1; | 254 | *nplanes = 1; |
261 | sizes[0] = layer->pix_fmt.sizeimage; | 255 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : layer->pix_fmt.sizeimage; |
262 | alloc_ctxs[0] = layer->alloc_ctx; | 256 | alloc_ctxs[0] = layer->alloc_ctx; |
263 | 257 | ||
264 | return 0; | 258 | return 0; |
@@ -271,12 +265,11 @@ vpbe_buffer_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
271 | static void vpbe_buffer_queue(struct vb2_buffer *vb) | 265 | static void vpbe_buffer_queue(struct vb2_buffer *vb) |
272 | { | 266 | { |
273 | /* Get the file handle object and layer object */ | 267 | /* Get the file handle object and layer object */ |
274 | struct vpbe_fh *fh = vb2_get_drv_priv(vb->vb2_queue); | ||
275 | struct vpbe_disp_buffer *buf = container_of(vb, | 268 | struct vpbe_disp_buffer *buf = container_of(vb, |
276 | struct vpbe_disp_buffer, vb); | 269 | struct vpbe_disp_buffer, vb); |
277 | struct vpbe_layer *layer = fh->layer; | 270 | struct vpbe_layer *layer = vb2_get_drv_priv(vb->vb2_queue); |
278 | struct vpbe_display *disp = fh->disp_dev; | 271 | struct vpbe_display *disp = layer->disp_dev; |
279 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 272 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
280 | unsigned long flags; | 273 | unsigned long flags; |
281 | 274 | ||
282 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | 275 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, |
@@ -288,61 +281,14 @@ static void vpbe_buffer_queue(struct vb2_buffer *vb) | |||
288 | spin_unlock_irqrestore(&disp->dma_queue_lock, flags); | 281 | spin_unlock_irqrestore(&disp->dma_queue_lock, flags); |
289 | } | 282 | } |
290 | 283 | ||
291 | /* | ||
292 | * vpbe_buf_cleanup() | ||
293 | * This function is called from the vb2 layer to free memory allocated to | ||
294 | * the buffers | ||
295 | */ | ||
296 | static void vpbe_buf_cleanup(struct vb2_buffer *vb) | ||
297 | { | ||
298 | /* Get the file handle object and layer object */ | ||
299 | struct vpbe_fh *fh = vb2_get_drv_priv(vb->vb2_queue); | ||
300 | struct vpbe_layer *layer = fh->layer; | ||
301 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
302 | struct vpbe_disp_buffer *buf = container_of(vb, | ||
303 | struct vpbe_disp_buffer, vb); | ||
304 | unsigned long flags; | ||
305 | |||
306 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
307 | "vpbe_buf_cleanup\n"); | ||
308 | |||
309 | spin_lock_irqsave(&layer->irqlock, flags); | ||
310 | if (vb->state == VB2_BUF_STATE_ACTIVE) | ||
311 | list_del_init(&buf->list); | ||
312 | spin_unlock_irqrestore(&layer->irqlock, flags); | ||
313 | } | ||
314 | |||
315 | static void vpbe_wait_prepare(struct vb2_queue *vq) | ||
316 | { | ||
317 | struct vpbe_fh *fh = vb2_get_drv_priv(vq); | ||
318 | struct vpbe_layer *layer = fh->layer; | ||
319 | |||
320 | mutex_unlock(&layer->opslock); | ||
321 | } | ||
322 | |||
323 | static void vpbe_wait_finish(struct vb2_queue *vq) | ||
324 | { | ||
325 | struct vpbe_fh *fh = vb2_get_drv_priv(vq); | ||
326 | struct vpbe_layer *layer = fh->layer; | ||
327 | |||
328 | mutex_lock(&layer->opslock); | ||
329 | } | ||
330 | |||
331 | static int vpbe_buffer_init(struct vb2_buffer *vb) | ||
332 | { | ||
333 | struct vpbe_disp_buffer *buf = container_of(vb, | ||
334 | struct vpbe_disp_buffer, vb); | ||
335 | |||
336 | INIT_LIST_HEAD(&buf->list); | ||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) | 284 | static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) |
341 | { | 285 | { |
342 | struct vpbe_fh *fh = vb2_get_drv_priv(vq); | 286 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); |
343 | struct vpbe_layer *layer = fh->layer; | 287 | struct osd_state *osd_device = layer->disp_dev->osd_device; |
344 | int ret; | 288 | int ret; |
345 | 289 | ||
290 | osd_device->ops.disable_layer(osd_device, layer->layer_info.id); | ||
291 | |||
346 | /* Get the next frame from the buffer queue */ | 292 | /* Get the next frame from the buffer queue */ |
347 | layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next, | 293 | layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next, |
348 | struct vpbe_disp_buffer, list); | 294 | struct vpbe_disp_buffer, list); |
@@ -354,7 +300,7 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
354 | layer->field_id = 0; | 300 | layer->field_id = 0; |
355 | 301 | ||
356 | /* Set parameters in OSD and VENC */ | 302 | /* Set parameters in OSD and VENC */ |
357 | ret = vpbe_set_osd_display_params(fh->disp_dev, layer); | 303 | ret = vpbe_set_osd_display_params(layer->disp_dev, layer); |
358 | if (ret < 0) { | 304 | if (ret < 0) { |
359 | struct vpbe_disp_buffer *buf, *tmp; | 305 | struct vpbe_disp_buffer *buf, *tmp; |
360 | 306 | ||
@@ -371,7 +317,6 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
371 | * if request format is yuv420 semiplanar, need to | 317 | * if request format is yuv420 semiplanar, need to |
372 | * enable both video windows | 318 | * enable both video windows |
373 | */ | 319 | */ |
374 | layer->started = 1; | ||
375 | layer->layer_first_int = 1; | 320 | layer->layer_first_int = 1; |
376 | 321 | ||
377 | return ret; | 322 | return ret; |
@@ -379,14 +324,16 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
379 | 324 | ||
380 | static void vpbe_stop_streaming(struct vb2_queue *vq) | 325 | static void vpbe_stop_streaming(struct vb2_queue *vq) |
381 | { | 326 | { |
382 | struct vpbe_fh *fh = vb2_get_drv_priv(vq); | 327 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); |
383 | struct vpbe_layer *layer = fh->layer; | 328 | struct osd_state *osd_device = layer->disp_dev->osd_device; |
384 | struct vpbe_display *disp = fh->disp_dev; | 329 | struct vpbe_display *disp = layer->disp_dev; |
385 | unsigned long flags; | 330 | unsigned long flags; |
386 | 331 | ||
387 | if (!vb2_is_streaming(vq)) | 332 | if (!vb2_is_streaming(vq)) |
388 | return; | 333 | return; |
389 | 334 | ||
335 | osd_device->ops.disable_layer(osd_device, layer->layer_info.id); | ||
336 | |||
390 | /* release all active buffers */ | 337 | /* release all active buffers */ |
391 | spin_lock_irqsave(&disp->dma_queue_lock, flags); | 338 | spin_lock_irqsave(&disp->dma_queue_lock, flags); |
392 | if (layer->cur_frm == layer->next_frm) { | 339 | if (layer->cur_frm == layer->next_frm) { |
@@ -411,13 +358,11 @@ static void vpbe_stop_streaming(struct vb2_queue *vq) | |||
411 | 358 | ||
412 | static struct vb2_ops video_qops = { | 359 | static struct vb2_ops video_qops = { |
413 | .queue_setup = vpbe_buffer_queue_setup, | 360 | .queue_setup = vpbe_buffer_queue_setup, |
414 | .wait_prepare = vpbe_wait_prepare, | 361 | .wait_prepare = vb2_ops_wait_prepare, |
415 | .wait_finish = vpbe_wait_finish, | 362 | .wait_finish = vb2_ops_wait_finish, |
416 | .buf_init = vpbe_buffer_init, | ||
417 | .buf_prepare = vpbe_buffer_prepare, | 363 | .buf_prepare = vpbe_buffer_prepare, |
418 | .start_streaming = vpbe_start_streaming, | 364 | .start_streaming = vpbe_start_streaming, |
419 | .stop_streaming = vpbe_stop_streaming, | 365 | .stop_streaming = vpbe_stop_streaming, |
420 | .buf_cleanup = vpbe_buf_cleanup, | ||
421 | .buf_queue = vpbe_buffer_queue, | 366 | .buf_queue = vpbe_buffer_queue, |
422 | }; | 367 | }; |
423 | 368 | ||
@@ -691,10 +636,9 @@ static int vpbe_try_format(struct vpbe_display *disp_dev, | |||
691 | static int vpbe_display_querycap(struct file *file, void *priv, | 636 | static int vpbe_display_querycap(struct file *file, void *priv, |
692 | struct v4l2_capability *cap) | 637 | struct v4l2_capability *cap) |
693 | { | 638 | { |
694 | struct vpbe_fh *fh = file->private_data; | 639 | struct vpbe_layer *layer = video_drvdata(file); |
695 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 640 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
696 | 641 | ||
697 | cap->version = VPBE_DISPLAY_VERSION_CODE; | ||
698 | cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; | 642 | cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; |
699 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | 643 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
700 | snprintf(cap->driver, sizeof(cap->driver), "%s", | 644 | snprintf(cap->driver, sizeof(cap->driver), "%s", |
@@ -709,9 +653,8 @@ static int vpbe_display_querycap(struct file *file, void *priv, | |||
709 | static int vpbe_display_s_crop(struct file *file, void *priv, | 653 | static int vpbe_display_s_crop(struct file *file, void *priv, |
710 | const struct v4l2_crop *crop) | 654 | const struct v4l2_crop *crop) |
711 | { | 655 | { |
712 | struct vpbe_fh *fh = file->private_data; | 656 | struct vpbe_layer *layer = video_drvdata(file); |
713 | struct vpbe_layer *layer = fh->layer; | 657 | struct vpbe_display *disp_dev = layer->disp_dev; |
714 | struct vpbe_display *disp_dev = fh->disp_dev; | ||
715 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; | 658 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; |
716 | struct osd_layer_config *cfg = &layer->layer_info.config; | 659 | struct osd_layer_config *cfg = &layer->layer_info.config; |
717 | struct osd_state *osd_device = disp_dev->osd_device; | 660 | struct osd_state *osd_device = disp_dev->osd_device; |
@@ -778,11 +721,10 @@ static int vpbe_display_s_crop(struct file *file, void *priv, | |||
778 | static int vpbe_display_g_crop(struct file *file, void *priv, | 721 | static int vpbe_display_g_crop(struct file *file, void *priv, |
779 | struct v4l2_crop *crop) | 722 | struct v4l2_crop *crop) |
780 | { | 723 | { |
781 | struct vpbe_fh *fh = file->private_data; | 724 | struct vpbe_layer *layer = video_drvdata(file); |
782 | struct vpbe_layer *layer = fh->layer; | ||
783 | struct osd_layer_config *cfg = &layer->layer_info.config; | 725 | struct osd_layer_config *cfg = &layer->layer_info.config; |
784 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 726 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
785 | struct osd_state *osd_device = fh->disp_dev->osd_device; | 727 | struct osd_state *osd_device = layer->disp_dev->osd_device; |
786 | struct v4l2_rect *rect = &crop->c; | 728 | struct v4l2_rect *rect = &crop->c; |
787 | 729 | ||
788 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | 730 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, |
@@ -806,8 +748,8 @@ static int vpbe_display_g_crop(struct file *file, void *priv, | |||
806 | static int vpbe_display_cropcap(struct file *file, void *priv, | 748 | static int vpbe_display_cropcap(struct file *file, void *priv, |
807 | struct v4l2_cropcap *cropcap) | 749 | struct v4l2_cropcap *cropcap) |
808 | { | 750 | { |
809 | struct vpbe_fh *fh = file->private_data; | 751 | struct vpbe_layer *layer = video_drvdata(file); |
810 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 752 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
811 | 753 | ||
812 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_CROPCAP ioctl\n"); | 754 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_CROPCAP ioctl\n"); |
813 | 755 | ||
@@ -824,9 +766,8 @@ static int vpbe_display_cropcap(struct file *file, void *priv, | |||
824 | static int vpbe_display_g_fmt(struct file *file, void *priv, | 766 | static int vpbe_display_g_fmt(struct file *file, void *priv, |
825 | struct v4l2_format *fmt) | 767 | struct v4l2_format *fmt) |
826 | { | 768 | { |
827 | struct vpbe_fh *fh = file->private_data; | 769 | struct vpbe_layer *layer = video_drvdata(file); |
828 | struct vpbe_layer *layer = fh->layer; | 770 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
829 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
830 | 771 | ||
831 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | 772 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, |
832 | "VIDIOC_G_FMT, layer id = %d\n", | 773 | "VIDIOC_G_FMT, layer id = %d\n", |
@@ -846,9 +787,8 @@ static int vpbe_display_g_fmt(struct file *file, void *priv, | |||
846 | static int vpbe_display_enum_fmt(struct file *file, void *priv, | 787 | static int vpbe_display_enum_fmt(struct file *file, void *priv, |
847 | struct v4l2_fmtdesc *fmt) | 788 | struct v4l2_fmtdesc *fmt) |
848 | { | 789 | { |
849 | struct vpbe_fh *fh = file->private_data; | 790 | struct vpbe_layer *layer = video_drvdata(file); |
850 | struct vpbe_layer *layer = fh->layer; | 791 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
851 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
852 | unsigned int index = 0; | 792 | unsigned int index = 0; |
853 | 793 | ||
854 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | 794 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, |
@@ -878,9 +818,8 @@ static int vpbe_display_enum_fmt(struct file *file, void *priv, | |||
878 | static int vpbe_display_s_fmt(struct file *file, void *priv, | 818 | static int vpbe_display_s_fmt(struct file *file, void *priv, |
879 | struct v4l2_format *fmt) | 819 | struct v4l2_format *fmt) |
880 | { | 820 | { |
881 | struct vpbe_fh *fh = file->private_data; | 821 | struct vpbe_layer *layer = video_drvdata(file); |
882 | struct vpbe_layer *layer = fh->layer; | 822 | struct vpbe_display *disp_dev = layer->disp_dev; |
883 | struct vpbe_display *disp_dev = fh->disp_dev; | ||
884 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; | 823 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; |
885 | struct osd_layer_config *cfg = &layer->layer_info.config; | 824 | struct osd_layer_config *cfg = &layer->layer_info.config; |
886 | struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; | 825 | struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; |
@@ -891,11 +830,9 @@ static int vpbe_display_s_fmt(struct file *file, void *priv, | |||
891 | "VIDIOC_S_FMT, layer id = %d\n", | 830 | "VIDIOC_S_FMT, layer id = %d\n", |
892 | layer->device_id); | 831 | layer->device_id); |
893 | 832 | ||
894 | /* If streaming is started, return error */ | 833 | if (vb2_is_busy(&layer->buffer_queue)) |
895 | if (layer->started) { | ||
896 | v4l2_err(&vpbe_dev->v4l2_dev, "Streaming is started\n"); | ||
897 | return -EBUSY; | 834 | return -EBUSY; |
898 | } | 835 | |
899 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != fmt->type) { | 836 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != fmt->type) { |
900 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "invalid type\n"); | 837 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "invalid type\n"); |
901 | return -EINVAL; | 838 | return -EINVAL; |
@@ -967,9 +904,9 @@ static int vpbe_display_s_fmt(struct file *file, void *priv, | |||
967 | static int vpbe_display_try_fmt(struct file *file, void *priv, | 904 | static int vpbe_display_try_fmt(struct file *file, void *priv, |
968 | struct v4l2_format *fmt) | 905 | struct v4l2_format *fmt) |
969 | { | 906 | { |
970 | struct vpbe_fh *fh = file->private_data; | 907 | struct vpbe_layer *layer = video_drvdata(file); |
971 | struct vpbe_display *disp_dev = fh->disp_dev; | 908 | struct vpbe_display *disp_dev = layer->disp_dev; |
972 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 909 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
973 | struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; | 910 | struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; |
974 | 911 | ||
975 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_TRY_FMT\n"); | 912 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_TRY_FMT\n"); |
@@ -993,18 +930,15 @@ static int vpbe_display_try_fmt(struct file *file, void *priv, | |||
993 | static int vpbe_display_s_std(struct file *file, void *priv, | 930 | static int vpbe_display_s_std(struct file *file, void *priv, |
994 | v4l2_std_id std_id) | 931 | v4l2_std_id std_id) |
995 | { | 932 | { |
996 | struct vpbe_fh *fh = priv; | 933 | struct vpbe_layer *layer = video_drvdata(file); |
997 | struct vpbe_layer *layer = fh->layer; | 934 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
998 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
999 | int ret; | 935 | int ret; |
1000 | 936 | ||
1001 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_STD\n"); | 937 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_STD\n"); |
1002 | 938 | ||
1003 | /* If streaming is started, return error */ | 939 | if (vb2_is_busy(&layer->buffer_queue)) |
1004 | if (layer->started) { | ||
1005 | v4l2_err(&vpbe_dev->v4l2_dev, "Streaming is started\n"); | ||
1006 | return -EBUSY; | 940 | return -EBUSY; |
1007 | } | 941 | |
1008 | if (NULL != vpbe_dev->ops.s_std) { | 942 | if (NULL != vpbe_dev->ops.s_std) { |
1009 | ret = vpbe_dev->ops.s_std(vpbe_dev, std_id); | 943 | ret = vpbe_dev->ops.s_std(vpbe_dev, std_id); |
1010 | if (ret) { | 944 | if (ret) { |
@@ -1028,8 +962,8 @@ static int vpbe_display_s_std(struct file *file, void *priv, | |||
1028 | static int vpbe_display_g_std(struct file *file, void *priv, | 962 | static int vpbe_display_g_std(struct file *file, void *priv, |
1029 | v4l2_std_id *std_id) | 963 | v4l2_std_id *std_id) |
1030 | { | 964 | { |
1031 | struct vpbe_fh *fh = priv; | 965 | struct vpbe_layer *layer = video_drvdata(file); |
1032 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 966 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1033 | 967 | ||
1034 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_STD\n"); | 968 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_STD\n"); |
1035 | 969 | ||
@@ -1051,8 +985,8 @@ static int vpbe_display_g_std(struct file *file, void *priv, | |||
1051 | static int vpbe_display_enum_output(struct file *file, void *priv, | 985 | static int vpbe_display_enum_output(struct file *file, void *priv, |
1052 | struct v4l2_output *output) | 986 | struct v4l2_output *output) |
1053 | { | 987 | { |
1054 | struct vpbe_fh *fh = priv; | 988 | struct vpbe_layer *layer = video_drvdata(file); |
1055 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 989 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1056 | int ret; | 990 | int ret; |
1057 | 991 | ||
1058 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_OUTPUT\n"); | 992 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_OUTPUT\n"); |
@@ -1079,17 +1013,15 @@ static int vpbe_display_enum_output(struct file *file, void *priv, | |||
1079 | static int vpbe_display_s_output(struct file *file, void *priv, | 1013 | static int vpbe_display_s_output(struct file *file, void *priv, |
1080 | unsigned int i) | 1014 | unsigned int i) |
1081 | { | 1015 | { |
1082 | struct vpbe_fh *fh = priv; | 1016 | struct vpbe_layer *layer = video_drvdata(file); |
1083 | struct vpbe_layer *layer = fh->layer; | 1017 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1084 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1085 | int ret; | 1018 | int ret; |
1086 | 1019 | ||
1087 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_OUTPUT\n"); | 1020 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_OUTPUT\n"); |
1088 | /* If streaming is started, return error */ | 1021 | |
1089 | if (layer->started) { | 1022 | if (vb2_is_busy(&layer->buffer_queue)) |
1090 | v4l2_err(&vpbe_dev->v4l2_dev, "Streaming is started\n"); | ||
1091 | return -EBUSY; | 1023 | return -EBUSY; |
1092 | } | 1024 | |
1093 | if (NULL == vpbe_dev->ops.set_output) | 1025 | if (NULL == vpbe_dev->ops.set_output) |
1094 | return -EINVAL; | 1026 | return -EINVAL; |
1095 | 1027 | ||
@@ -1110,8 +1042,8 @@ static int vpbe_display_s_output(struct file *file, void *priv, | |||
1110 | static int vpbe_display_g_output(struct file *file, void *priv, | 1042 | static int vpbe_display_g_output(struct file *file, void *priv, |
1111 | unsigned int *i) | 1043 | unsigned int *i) |
1112 | { | 1044 | { |
1113 | struct vpbe_fh *fh = priv; | 1045 | struct vpbe_layer *layer = video_drvdata(file); |
1114 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 1046 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1115 | 1047 | ||
1116 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_OUTPUT\n"); | 1048 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_OUTPUT\n"); |
1117 | /* Get the standard from the current encoder */ | 1049 | /* Get the standard from the current encoder */ |
@@ -1130,8 +1062,8 @@ static int | |||
1130 | vpbe_display_enum_dv_timings(struct file *file, void *priv, | 1062 | vpbe_display_enum_dv_timings(struct file *file, void *priv, |
1131 | struct v4l2_enum_dv_timings *timings) | 1063 | struct v4l2_enum_dv_timings *timings) |
1132 | { | 1064 | { |
1133 | struct vpbe_fh *fh = priv; | 1065 | struct vpbe_layer *layer = video_drvdata(file); |
1134 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 1066 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1135 | int ret; | 1067 | int ret; |
1136 | 1068 | ||
1137 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_DV_TIMINGS\n"); | 1069 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_DV_TIMINGS\n"); |
@@ -1160,19 +1092,14 @@ static int | |||
1160 | vpbe_display_s_dv_timings(struct file *file, void *priv, | 1092 | vpbe_display_s_dv_timings(struct file *file, void *priv, |
1161 | struct v4l2_dv_timings *timings) | 1093 | struct v4l2_dv_timings *timings) |
1162 | { | 1094 | { |
1163 | struct vpbe_fh *fh = priv; | 1095 | struct vpbe_layer *layer = video_drvdata(file); |
1164 | struct vpbe_layer *layer = fh->layer; | 1096 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1165 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1166 | int ret; | 1097 | int ret; |
1167 | 1098 | ||
1168 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_DV_TIMINGS\n"); | 1099 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_DV_TIMINGS\n"); |
1169 | 1100 | ||
1170 | 1101 | if (vb2_is_busy(&layer->buffer_queue)) | |
1171 | /* If streaming is started, return error */ | ||
1172 | if (layer->started) { | ||
1173 | v4l2_err(&vpbe_dev->v4l2_dev, "Streaming is started\n"); | ||
1174 | return -EBUSY; | 1102 | return -EBUSY; |
1175 | } | ||
1176 | 1103 | ||
1177 | /* Set the given standard in the encoder */ | 1104 | /* Set the given standard in the encoder */ |
1178 | if (!vpbe_dev->ops.s_dv_timings) | 1105 | if (!vpbe_dev->ops.s_dv_timings) |
@@ -1198,8 +1125,8 @@ static int | |||
1198 | vpbe_display_g_dv_timings(struct file *file, void *priv, | 1125 | vpbe_display_g_dv_timings(struct file *file, void *priv, |
1199 | struct v4l2_dv_timings *dv_timings) | 1126 | struct v4l2_dv_timings *dv_timings) |
1200 | { | 1127 | { |
1201 | struct vpbe_fh *fh = priv; | 1128 | struct vpbe_layer *layer = video_drvdata(file); |
1202 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 1129 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
1203 | 1130 | ||
1204 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_DV_TIMINGS\n"); | 1131 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_DV_TIMINGS\n"); |
1205 | 1132 | ||
@@ -1215,259 +1142,6 @@ vpbe_display_g_dv_timings(struct file *file, void *priv, | |||
1215 | return 0; | 1142 | return 0; |
1216 | } | 1143 | } |
1217 | 1144 | ||
1218 | static int vpbe_display_streamoff(struct file *file, void *priv, | ||
1219 | enum v4l2_buf_type buf_type) | ||
1220 | { | ||
1221 | struct vpbe_fh *fh = file->private_data; | ||
1222 | struct vpbe_layer *layer = fh->layer; | ||
1223 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1224 | struct osd_state *osd_device = fh->disp_dev->osd_device; | ||
1225 | int ret; | ||
1226 | |||
1227 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1228 | "VIDIOC_STREAMOFF,layer id = %d\n", | ||
1229 | layer->device_id); | ||
1230 | |||
1231 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { | ||
1232 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1233 | return -EINVAL; | ||
1234 | } | ||
1235 | |||
1236 | /* If io is allowed for this file handle, return error */ | ||
1237 | if (!fh->io_allowed) { | ||
1238 | v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); | ||
1239 | return -EACCES; | ||
1240 | } | ||
1241 | |||
1242 | /* If streaming is not started, return error */ | ||
1243 | if (!layer->started) { | ||
1244 | v4l2_err(&vpbe_dev->v4l2_dev, "streaming not started in layer" | ||
1245 | " id = %d\n", layer->device_id); | ||
1246 | return -EINVAL; | ||
1247 | } | ||
1248 | |||
1249 | osd_device->ops.disable_layer(osd_device, | ||
1250 | layer->layer_info.id); | ||
1251 | layer->started = 0; | ||
1252 | ret = vb2_streamoff(&layer->buffer_queue, buf_type); | ||
1253 | |||
1254 | return ret; | ||
1255 | } | ||
1256 | |||
1257 | static int vpbe_display_streamon(struct file *file, void *priv, | ||
1258 | enum v4l2_buf_type buf_type) | ||
1259 | { | ||
1260 | struct vpbe_fh *fh = file->private_data; | ||
1261 | struct vpbe_layer *layer = fh->layer; | ||
1262 | struct vpbe_display *disp_dev = fh->disp_dev; | ||
1263 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1264 | struct osd_state *osd_device = disp_dev->osd_device; | ||
1265 | int ret; | ||
1266 | |||
1267 | osd_device->ops.disable_layer(osd_device, | ||
1268 | layer->layer_info.id); | ||
1269 | |||
1270 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_STREAMON, layerid=%d\n", | ||
1271 | layer->device_id); | ||
1272 | |||
1273 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { | ||
1274 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1275 | return -EINVAL; | ||
1276 | } | ||
1277 | |||
1278 | /* If file handle is not allowed IO, return error */ | ||
1279 | if (!fh->io_allowed) { | ||
1280 | v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); | ||
1281 | return -EACCES; | ||
1282 | } | ||
1283 | /* If Streaming is already started, return error */ | ||
1284 | if (layer->started) { | ||
1285 | v4l2_err(&vpbe_dev->v4l2_dev, "layer is already streaming\n"); | ||
1286 | return -EBUSY; | ||
1287 | } | ||
1288 | |||
1289 | /* | ||
1290 | * Call vb2_streamon to start streaming | ||
1291 | * in videobuf | ||
1292 | */ | ||
1293 | ret = vb2_streamon(&layer->buffer_queue, buf_type); | ||
1294 | if (ret) { | ||
1295 | v4l2_err(&vpbe_dev->v4l2_dev, | ||
1296 | "error in vb2_streamon\n"); | ||
1297 | return ret; | ||
1298 | } | ||
1299 | return ret; | ||
1300 | } | ||
1301 | |||
1302 | static int vpbe_display_dqbuf(struct file *file, void *priv, | ||
1303 | struct v4l2_buffer *buf) | ||
1304 | { | ||
1305 | struct vpbe_fh *fh = file->private_data; | ||
1306 | struct vpbe_layer *layer = fh->layer; | ||
1307 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1308 | int ret; | ||
1309 | |||
1310 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1311 | "VIDIOC_DQBUF, layer id = %d\n", | ||
1312 | layer->device_id); | ||
1313 | |||
1314 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { | ||
1315 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1316 | return -EINVAL; | ||
1317 | } | ||
1318 | /* If this file handle is not allowed to do IO, return error */ | ||
1319 | if (!fh->io_allowed) { | ||
1320 | v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); | ||
1321 | return -EACCES; | ||
1322 | } | ||
1323 | if (file->f_flags & O_NONBLOCK) | ||
1324 | /* Call videobuf_dqbuf for non blocking mode */ | ||
1325 | ret = vb2_dqbuf(&layer->buffer_queue, buf, 1); | ||
1326 | else | ||
1327 | /* Call videobuf_dqbuf for blocking mode */ | ||
1328 | ret = vb2_dqbuf(&layer->buffer_queue, buf, 0); | ||
1329 | |||
1330 | return ret; | ||
1331 | } | ||
1332 | |||
1333 | static int vpbe_display_qbuf(struct file *file, void *priv, | ||
1334 | struct v4l2_buffer *p) | ||
1335 | { | ||
1336 | struct vpbe_fh *fh = file->private_data; | ||
1337 | struct vpbe_layer *layer = fh->layer; | ||
1338 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1339 | |||
1340 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1341 | "VIDIOC_QBUF, layer id = %d\n", | ||
1342 | layer->device_id); | ||
1343 | |||
1344 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != p->type) { | ||
1345 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1346 | return -EINVAL; | ||
1347 | } | ||
1348 | |||
1349 | /* If this file handle is not allowed to do IO, return error */ | ||
1350 | if (!fh->io_allowed) { | ||
1351 | v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); | ||
1352 | return -EACCES; | ||
1353 | } | ||
1354 | |||
1355 | return vb2_qbuf(&layer->buffer_queue, p); | ||
1356 | } | ||
1357 | |||
1358 | static int vpbe_display_querybuf(struct file *file, void *priv, | ||
1359 | struct v4l2_buffer *buf) | ||
1360 | { | ||
1361 | struct vpbe_fh *fh = file->private_data; | ||
1362 | struct vpbe_layer *layer = fh->layer; | ||
1363 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1364 | |||
1365 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1366 | "VIDIOC_QUERYBUF, layer id = %d\n", | ||
1367 | layer->device_id); | ||
1368 | |||
1369 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { | ||
1370 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1371 | return -EINVAL; | ||
1372 | } | ||
1373 | /* Call vb2_querybuf to get information */ | ||
1374 | return vb2_querybuf(&layer->buffer_queue, buf); | ||
1375 | } | ||
1376 | |||
1377 | static int vpbe_display_reqbufs(struct file *file, void *priv, | ||
1378 | struct v4l2_requestbuffers *req_buf) | ||
1379 | { | ||
1380 | struct vpbe_fh *fh = file->private_data; | ||
1381 | struct vpbe_layer *layer = fh->layer; | ||
1382 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1383 | struct vb2_queue *q; | ||
1384 | int ret; | ||
1385 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_reqbufs\n"); | ||
1386 | |||
1387 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != req_buf->type) { | ||
1388 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1389 | return -EINVAL; | ||
1390 | } | ||
1391 | |||
1392 | /* If io users of the layer is not zero, return error */ | ||
1393 | if (0 != layer->io_usrs) { | ||
1394 | v4l2_err(&vpbe_dev->v4l2_dev, "not IO user\n"); | ||
1395 | return -EBUSY; | ||
1396 | } | ||
1397 | /* Initialize videobuf queue as per the buffer type */ | ||
1398 | layer->alloc_ctx = vb2_dma_contig_init_ctx(vpbe_dev->pdev); | ||
1399 | if (IS_ERR(layer->alloc_ctx)) { | ||
1400 | v4l2_err(&vpbe_dev->v4l2_dev, "Failed to get the context\n"); | ||
1401 | return PTR_ERR(layer->alloc_ctx); | ||
1402 | } | ||
1403 | q = &layer->buffer_queue; | ||
1404 | memset(q, 0, sizeof(*q)); | ||
1405 | q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | ||
1406 | q->io_modes = VB2_MMAP | VB2_USERPTR; | ||
1407 | q->drv_priv = fh; | ||
1408 | q->ops = &video_qops; | ||
1409 | q->mem_ops = &vb2_dma_contig_memops; | ||
1410 | q->buf_struct_size = sizeof(struct vpbe_disp_buffer); | ||
1411 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1412 | q->min_buffers_needed = 1; | ||
1413 | |||
1414 | ret = vb2_queue_init(q); | ||
1415 | if (ret) { | ||
1416 | v4l2_err(&vpbe_dev->v4l2_dev, "vb2_queue_init() failed\n"); | ||
1417 | vb2_dma_contig_cleanup_ctx(layer->alloc_ctx); | ||
1418 | return ret; | ||
1419 | } | ||
1420 | /* Set io allowed member of file handle to TRUE */ | ||
1421 | fh->io_allowed = 1; | ||
1422 | /* Increment io usrs member of layer object to 1 */ | ||
1423 | layer->io_usrs = 1; | ||
1424 | /* Store type of memory requested in layer object */ | ||
1425 | layer->memory = req_buf->memory; | ||
1426 | /* Initialize buffer queue */ | ||
1427 | INIT_LIST_HEAD(&layer->dma_queue); | ||
1428 | /* Allocate buffers */ | ||
1429 | return vb2_reqbufs(q, req_buf); | ||
1430 | } | ||
1431 | |||
1432 | /* | ||
1433 | * vpbe_display_mmap() | ||
1434 | * It is used to map kernel space buffers into user spaces | ||
1435 | */ | ||
1436 | static int vpbe_display_mmap(struct file *filep, struct vm_area_struct *vma) | ||
1437 | { | ||
1438 | /* Get the layer object and file handle object */ | ||
1439 | struct vpbe_fh *fh = filep->private_data; | ||
1440 | struct vpbe_layer *layer = fh->layer; | ||
1441 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1442 | int ret; | ||
1443 | |||
1444 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_mmap\n"); | ||
1445 | |||
1446 | if (mutex_lock_interruptible(&layer->opslock)) | ||
1447 | return -ERESTARTSYS; | ||
1448 | ret = vb2_mmap(&layer->buffer_queue, vma); | ||
1449 | mutex_unlock(&layer->opslock); | ||
1450 | return ret; | ||
1451 | } | ||
1452 | |||
1453 | /* vpbe_display_poll(): It is used for select/poll system call | ||
1454 | */ | ||
1455 | static unsigned int vpbe_display_poll(struct file *filep, poll_table *wait) | ||
1456 | { | ||
1457 | struct vpbe_fh *fh = filep->private_data; | ||
1458 | struct vpbe_layer *layer = fh->layer; | ||
1459 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | ||
1460 | unsigned int err = 0; | ||
1461 | |||
1462 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_poll\n"); | ||
1463 | if (layer->started) { | ||
1464 | mutex_lock(&layer->opslock); | ||
1465 | err = vb2_poll(&layer->buffer_queue, filep, wait); | ||
1466 | mutex_unlock(&layer->opslock); | ||
1467 | } | ||
1468 | return err; | ||
1469 | } | ||
1470 | |||
1471 | /* | 1145 | /* |
1472 | * vpbe_display_open() | 1146 | * vpbe_display_open() |
1473 | * It creates object of file handle structure and stores it in private_data | 1147 | * It creates object of file handle structure and stores it in private_data |
@@ -1475,30 +1149,22 @@ static unsigned int vpbe_display_poll(struct file *filep, poll_table *wait) | |||
1475 | */ | 1149 | */ |
1476 | static int vpbe_display_open(struct file *file) | 1150 | static int vpbe_display_open(struct file *file) |
1477 | { | 1151 | { |
1478 | struct vpbe_fh *fh = NULL; | ||
1479 | struct vpbe_layer *layer = video_drvdata(file); | 1152 | struct vpbe_layer *layer = video_drvdata(file); |
1480 | struct video_device *vdev = video_devdata(file); | ||
1481 | struct vpbe_display *disp_dev = layer->disp_dev; | 1153 | struct vpbe_display *disp_dev = layer->disp_dev; |
1482 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; | 1154 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; |
1483 | struct osd_state *osd_device = disp_dev->osd_device; | 1155 | struct osd_state *osd_device = disp_dev->osd_device; |
1484 | int err; | 1156 | int err; |
1485 | 1157 | ||
1486 | /* Allocate memory for the file handle object */ | 1158 | /* creating context for file descriptor */ |
1487 | fh = kmalloc(sizeof(struct vpbe_fh), GFP_KERNEL); | 1159 | err = v4l2_fh_open(file); |
1488 | if (fh == NULL) { | 1160 | if (err) { |
1489 | v4l2_err(&vpbe_dev->v4l2_dev, | 1161 | v4l2_err(&vpbe_dev->v4l2_dev, "v4l2_fh_open failed\n"); |
1490 | "unable to allocate memory for file handle object\n"); | 1162 | return err; |
1491 | return -ENOMEM; | ||
1492 | } | 1163 | } |
1493 | v4l2_fh_init(&fh->fh, vdev); | ||
1494 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1495 | "vpbe display open plane = %d\n", | ||
1496 | layer->device_id); | ||
1497 | 1164 | ||
1498 | /* store pointer to fh in private_data member of filep */ | 1165 | /* leaving if layer is already initialized */ |
1499 | file->private_data = fh; | 1166 | if (!v4l2_fh_is_singular_file(file)) |
1500 | fh->layer = layer; | 1167 | return err; |
1501 | fh->disp_dev = disp_dev; | ||
1502 | 1168 | ||
1503 | if (!layer->usrs) { | 1169 | if (!layer->usrs) { |
1504 | if (mutex_lock_interruptible(&layer->opslock)) | 1170 | if (mutex_lock_interruptible(&layer->opslock)) |
@@ -1511,15 +1177,12 @@ static int vpbe_display_open(struct file *file) | |||
1511 | /* Couldn't get layer */ | 1177 | /* Couldn't get layer */ |
1512 | v4l2_err(&vpbe_dev->v4l2_dev, | 1178 | v4l2_err(&vpbe_dev->v4l2_dev, |
1513 | "Display Manager failed to allocate layer\n"); | 1179 | "Display Manager failed to allocate layer\n"); |
1514 | kfree(fh); | 1180 | v4l2_fh_release(file); |
1515 | return -EINVAL; | 1181 | return -EINVAL; |
1516 | } | 1182 | } |
1517 | } | 1183 | } |
1518 | /* Increment layer usrs counter */ | 1184 | /* Increment layer usrs counter */ |
1519 | layer->usrs++; | 1185 | layer->usrs++; |
1520 | /* Set io_allowed member to false */ | ||
1521 | fh->io_allowed = 0; | ||
1522 | v4l2_fh_add(&fh->fh); | ||
1523 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | 1186 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, |
1524 | "vpbe display device opened successfully\n"); | 1187 | "vpbe display device opened successfully\n"); |
1525 | return 0; | 1188 | return 0; |
@@ -1532,30 +1195,18 @@ static int vpbe_display_open(struct file *file) | |||
1532 | */ | 1195 | */ |
1533 | static int vpbe_display_release(struct file *file) | 1196 | static int vpbe_display_release(struct file *file) |
1534 | { | 1197 | { |
1535 | /* Get the layer object and file handle object */ | 1198 | struct vpbe_layer *layer = video_drvdata(file); |
1536 | struct vpbe_fh *fh = file->private_data; | ||
1537 | struct vpbe_layer *layer = fh->layer; | ||
1538 | struct osd_layer_config *cfg = &layer->layer_info.config; | 1199 | struct osd_layer_config *cfg = &layer->layer_info.config; |
1539 | struct vpbe_display *disp_dev = fh->disp_dev; | 1200 | struct vpbe_display *disp_dev = layer->disp_dev; |
1540 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; | 1201 | struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; |
1541 | struct osd_state *osd_device = disp_dev->osd_device; | 1202 | struct osd_state *osd_device = disp_dev->osd_device; |
1542 | 1203 | ||
1543 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_release\n"); | 1204 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_release\n"); |
1544 | 1205 | ||
1545 | mutex_lock(&layer->opslock); | 1206 | mutex_lock(&layer->opslock); |
1546 | /* if this instance is doing IO */ | ||
1547 | if (fh->io_allowed) { | ||
1548 | /* Reset io_usrs member of layer object */ | ||
1549 | layer->io_usrs = 0; | ||
1550 | |||
1551 | osd_device->ops.disable_layer(osd_device, | ||
1552 | layer->layer_info.id); | ||
1553 | layer->started = 0; | ||
1554 | /* Free buffers allocated */ | ||
1555 | vb2_queue_release(&layer->buffer_queue); | ||
1556 | vb2_dma_contig_cleanup_ctx(&layer->buffer_queue); | ||
1557 | } | ||
1558 | 1207 | ||
1208 | osd_device->ops.disable_layer(osd_device, | ||
1209 | layer->layer_info.id); | ||
1559 | /* Decrement layer usrs counter */ | 1210 | /* Decrement layer usrs counter */ |
1560 | layer->usrs--; | 1211 | layer->usrs--; |
1561 | /* If this file handle has initialize encoder device, reset it */ | 1212 | /* If this file handle has initialize encoder device, reset it */ |
@@ -1575,14 +1226,9 @@ static int vpbe_display_release(struct file *file) | |||
1575 | layer->layer_info.id); | 1226 | layer->layer_info.id); |
1576 | } | 1227 | } |
1577 | 1228 | ||
1578 | v4l2_fh_del(&fh->fh); | 1229 | _vb2_fop_release(file, NULL); |
1579 | v4l2_fh_exit(&fh->fh); | ||
1580 | file->private_data = NULL; | ||
1581 | mutex_unlock(&layer->opslock); | 1230 | mutex_unlock(&layer->opslock); |
1582 | 1231 | ||
1583 | /* Free memory allocated to file handle object */ | ||
1584 | kfree(fh); | ||
1585 | |||
1586 | disp_dev->cbcr_ofst = 0; | 1232 | disp_dev->cbcr_ofst = 0; |
1587 | 1233 | ||
1588 | return 0; | 1234 | return 0; |
@@ -1595,20 +1241,27 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { | |||
1595 | .vidioc_enum_fmt_vid_out = vpbe_display_enum_fmt, | 1241 | .vidioc_enum_fmt_vid_out = vpbe_display_enum_fmt, |
1596 | .vidioc_s_fmt_vid_out = vpbe_display_s_fmt, | 1242 | .vidioc_s_fmt_vid_out = vpbe_display_s_fmt, |
1597 | .vidioc_try_fmt_vid_out = vpbe_display_try_fmt, | 1243 | .vidioc_try_fmt_vid_out = vpbe_display_try_fmt, |
1598 | .vidioc_reqbufs = vpbe_display_reqbufs, | 1244 | |
1599 | .vidioc_querybuf = vpbe_display_querybuf, | 1245 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1600 | .vidioc_qbuf = vpbe_display_qbuf, | 1246 | .vidioc_create_bufs = vb2_ioctl_create_bufs, |
1601 | .vidioc_dqbuf = vpbe_display_dqbuf, | 1247 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1602 | .vidioc_streamon = vpbe_display_streamon, | 1248 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1603 | .vidioc_streamoff = vpbe_display_streamoff, | 1249 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1250 | .vidioc_streamon = vb2_ioctl_streamon, | ||
1251 | .vidioc_streamoff = vb2_ioctl_streamoff, | ||
1252 | .vidioc_expbuf = vb2_ioctl_expbuf, | ||
1253 | |||
1604 | .vidioc_cropcap = vpbe_display_cropcap, | 1254 | .vidioc_cropcap = vpbe_display_cropcap, |
1605 | .vidioc_g_crop = vpbe_display_g_crop, | 1255 | .vidioc_g_crop = vpbe_display_g_crop, |
1606 | .vidioc_s_crop = vpbe_display_s_crop, | 1256 | .vidioc_s_crop = vpbe_display_s_crop, |
1257 | |||
1607 | .vidioc_s_std = vpbe_display_s_std, | 1258 | .vidioc_s_std = vpbe_display_s_std, |
1608 | .vidioc_g_std = vpbe_display_g_std, | 1259 | .vidioc_g_std = vpbe_display_g_std, |
1260 | |||
1609 | .vidioc_enum_output = vpbe_display_enum_output, | 1261 | .vidioc_enum_output = vpbe_display_enum_output, |
1610 | .vidioc_s_output = vpbe_display_s_output, | 1262 | .vidioc_s_output = vpbe_display_s_output, |
1611 | .vidioc_g_output = vpbe_display_g_output, | 1263 | .vidioc_g_output = vpbe_display_g_output, |
1264 | |||
1612 | .vidioc_s_dv_timings = vpbe_display_s_dv_timings, | 1265 | .vidioc_s_dv_timings = vpbe_display_s_dv_timings, |
1613 | .vidioc_g_dv_timings = vpbe_display_g_dv_timings, | 1266 | .vidioc_g_dv_timings = vpbe_display_g_dv_timings, |
1614 | .vidioc_enum_dv_timings = vpbe_display_enum_dv_timings, | 1267 | .vidioc_enum_dv_timings = vpbe_display_enum_dv_timings, |
@@ -1619,8 +1272,8 @@ static struct v4l2_file_operations vpbe_fops = { | |||
1619 | .open = vpbe_display_open, | 1272 | .open = vpbe_display_open, |
1620 | .release = vpbe_display_release, | 1273 | .release = vpbe_display_release, |
1621 | .unlocked_ioctl = video_ioctl2, | 1274 | .unlocked_ioctl = video_ioctl2, |
1622 | .mmap = vpbe_display_mmap, | 1275 | .mmap = vb2_fop_mmap, |
1623 | .poll = vpbe_display_poll | 1276 | .poll = vb2_fop_poll, |
1624 | }; | 1277 | }; |
1625 | 1278 | ||
1626 | static int vpbe_device_get(struct device *dev, void *data) | 1279 | static int vpbe_device_get(struct device *dev, void *data) |
@@ -1700,6 +1353,7 @@ static int register_device(struct vpbe_layer *vpbe_display_layer, | |||
1700 | (int)vpbe_display_layer, | 1353 | (int)vpbe_display_layer, |
1701 | (int)&vpbe_display_layer->video_dev); | 1354 | (int)&vpbe_display_layer->video_dev); |
1702 | 1355 | ||
1356 | vpbe_display_layer->video_dev.queue = &vpbe_display_layer->buffer_queue; | ||
1703 | err = video_register_device(&vpbe_display_layer->video_dev, | 1357 | err = video_register_device(&vpbe_display_layer->video_dev, |
1704 | VFL_TYPE_GRABBER, | 1358 | VFL_TYPE_GRABBER, |
1705 | -1); | 1359 | -1); |
@@ -1724,9 +1378,10 @@ static int register_device(struct vpbe_layer *vpbe_display_layer, | |||
1724 | */ | 1378 | */ |
1725 | static int vpbe_display_probe(struct platform_device *pdev) | 1379 | static int vpbe_display_probe(struct platform_device *pdev) |
1726 | { | 1380 | { |
1727 | struct vpbe_layer *vpbe_display_layer; | ||
1728 | struct vpbe_display *disp_dev; | 1381 | struct vpbe_display *disp_dev; |
1382 | struct v4l2_device *v4l2_dev; | ||
1729 | struct resource *res = NULL; | 1383 | struct resource *res = NULL; |
1384 | struct vb2_queue *q; | ||
1730 | int k; | 1385 | int k; |
1731 | int i; | 1386 | int i; |
1732 | int err; | 1387 | int err; |
@@ -1748,13 +1403,14 @@ static int vpbe_display_probe(struct platform_device *pdev) | |||
1748 | vpbe_device_get); | 1403 | vpbe_device_get); |
1749 | if (err < 0) | 1404 | if (err < 0) |
1750 | return err; | 1405 | return err; |
1406 | |||
1407 | v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev; | ||
1751 | /* Initialize the vpbe display controller */ | 1408 | /* Initialize the vpbe display controller */ |
1752 | if (NULL != disp_dev->vpbe_dev->ops.initialize) { | 1409 | if (NULL != disp_dev->vpbe_dev->ops.initialize) { |
1753 | err = disp_dev->vpbe_dev->ops.initialize(&pdev->dev, | 1410 | err = disp_dev->vpbe_dev->ops.initialize(&pdev->dev, |
1754 | disp_dev->vpbe_dev); | 1411 | disp_dev->vpbe_dev); |
1755 | if (err) { | 1412 | if (err) { |
1756 | v4l2_err(&disp_dev->vpbe_dev->v4l2_dev, | 1413 | v4l2_err(v4l2_dev, "Error initing vpbe\n"); |
1757 | "Error initing vpbe\n"); | ||
1758 | err = -ENOMEM; | 1414 | err = -ENOMEM; |
1759 | goto probe_out; | 1415 | goto probe_out; |
1760 | } | 1416 | } |
@@ -1769,8 +1425,7 @@ static int vpbe_display_probe(struct platform_device *pdev) | |||
1769 | 1425 | ||
1770 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 1426 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
1771 | if (!res) { | 1427 | if (!res) { |
1772 | v4l2_err(&disp_dev->vpbe_dev->v4l2_dev, | 1428 | v4l2_err(v4l2_dev, "Unable to get VENC interrupt resource\n"); |
1773 | "Unable to get VENC interrupt resource\n"); | ||
1774 | err = -ENODEV; | 1429 | err = -ENODEV; |
1775 | goto probe_out; | 1430 | goto probe_out; |
1776 | } | 1431 | } |
@@ -1779,30 +1434,57 @@ static int vpbe_display_probe(struct platform_device *pdev) | |||
1779 | err = devm_request_irq(&pdev->dev, irq, venc_isr, 0, | 1434 | err = devm_request_irq(&pdev->dev, irq, venc_isr, 0, |
1780 | VPBE_DISPLAY_DRIVER, disp_dev); | 1435 | VPBE_DISPLAY_DRIVER, disp_dev); |
1781 | if (err) { | 1436 | if (err) { |
1782 | v4l2_err(&disp_dev->vpbe_dev->v4l2_dev, | 1437 | v4l2_err(v4l2_dev, "VPBE IRQ request failed\n"); |
1783 | "Unable to request interrupt\n"); | ||
1784 | goto probe_out; | 1438 | goto probe_out; |
1785 | } | 1439 | } |
1786 | 1440 | ||
1787 | for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { | 1441 | for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { |
1442 | /* initialize vb2 queue */ | ||
1443 | q = &disp_dev->dev[i]->buffer_queue; | ||
1444 | memset(q, 0, sizeof(*q)); | ||
1445 | q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | ||
1446 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; | ||
1447 | q->drv_priv = disp_dev->dev[i]; | ||
1448 | q->ops = &video_qops; | ||
1449 | q->mem_ops = &vb2_dma_contig_memops; | ||
1450 | q->buf_struct_size = sizeof(struct vpbe_disp_buffer); | ||
1451 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1452 | q->min_buffers_needed = 1; | ||
1453 | q->lock = &disp_dev->dev[i]->opslock; | ||
1454 | err = vb2_queue_init(q); | ||
1455 | if (err) { | ||
1456 | v4l2_err(v4l2_dev, "vb2_queue_init() failed\n"); | ||
1457 | goto probe_out; | ||
1458 | } | ||
1459 | |||
1460 | disp_dev->dev[i]->alloc_ctx = | ||
1461 | vb2_dma_contig_init_ctx(disp_dev->vpbe_dev->pdev); | ||
1462 | if (IS_ERR(disp_dev->dev[i]->alloc_ctx)) { | ||
1463 | v4l2_err(v4l2_dev, "Failed to get the context\n"); | ||
1464 | err = PTR_ERR(disp_dev->dev[i]->alloc_ctx); | ||
1465 | goto probe_out; | ||
1466 | } | ||
1467 | |||
1468 | INIT_LIST_HEAD(&disp_dev->dev[i]->dma_queue); | ||
1469 | |||
1788 | if (register_device(disp_dev->dev[i], disp_dev, pdev)) { | 1470 | if (register_device(disp_dev->dev[i], disp_dev, pdev)) { |
1789 | err = -ENODEV; | 1471 | err = -ENODEV; |
1790 | goto probe_out; | 1472 | goto probe_out; |
1791 | } | 1473 | } |
1792 | } | 1474 | } |
1793 | 1475 | ||
1794 | printk(KERN_DEBUG "Successfully completed the probing of vpbe v4l2 device\n"); | 1476 | v4l2_dbg(1, debug, v4l2_dev, |
1477 | "Successfully completed the probing of vpbe v4l2 device\n"); | ||
1478 | |||
1795 | return 0; | 1479 | return 0; |
1796 | 1480 | ||
1797 | probe_out: | 1481 | probe_out: |
1798 | for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) { | 1482 | for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) { |
1799 | /* Get the pointer to the layer object */ | ||
1800 | vpbe_display_layer = disp_dev->dev[k]; | ||
1801 | /* Unregister video device */ | 1483 | /* Unregister video device */ |
1802 | if (vpbe_display_layer) { | 1484 | if (disp_dev->dev[k] != NULL) { |
1803 | video_unregister_device( | 1485 | vb2_dma_contig_cleanup_ctx(disp_dev->dev[k]->alloc_ctx); |
1804 | &vpbe_display_layer->video_dev); | 1486 | video_unregister_device(&disp_dev->dev[k]->video_dev); |
1805 | kfree(disp_dev->dev[k]); | 1487 | kfree(disp_dev->dev[k]); |
1806 | } | 1488 | } |
1807 | } | 1489 | } |
1808 | return err; | 1490 | return err; |
@@ -1828,6 +1510,7 @@ static int vpbe_display_remove(struct platform_device *pdev) | |||
1828 | for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { | 1510 | for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { |
1829 | /* Get the pointer to the layer object */ | 1511 | /* Get the pointer to the layer object */ |
1830 | vpbe_display_layer = disp_dev->dev[i]; | 1512 | vpbe_display_layer = disp_dev->dev[i]; |
1513 | vb2_dma_contig_cleanup_ctx(vpbe_display_layer->alloc_ctx); | ||
1831 | /* Unregister video device */ | 1514 | /* Unregister video device */ |
1832 | video_unregister_device(&vpbe_display_layer->video_dev); | 1515 | video_unregister_device(&vpbe_display_layer->video_dev); |
1833 | 1516 | ||
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index de55f47a77db..271c4600432d 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c | |||
@@ -414,13 +414,13 @@ static int vpfe_config_image_format(struct vpfe_device *vpfe_dev, | |||
414 | /* assume V4L2_PIX_FMT_UYVY as default */ | 414 | /* assume V4L2_PIX_FMT_UYVY as default */ |
415 | pix->pixelformat = V4L2_PIX_FMT_UYVY; | 415 | pix->pixelformat = V4L2_PIX_FMT_UYVY; |
416 | v4l2_fill_mbus_format(&mbus_fmt, pix, | 416 | v4l2_fill_mbus_format(&mbus_fmt, pix, |
417 | V4L2_MBUS_FMT_YUYV10_2X10); | 417 | MEDIA_BUS_FMT_YUYV10_2X10); |
418 | } else { | 418 | } else { |
419 | pix->field = V4L2_FIELD_NONE; | 419 | pix->field = V4L2_FIELD_NONE; |
420 | /* assume V4L2_PIX_FMT_SBGGR8 */ | 420 | /* assume V4L2_PIX_FMT_SBGGR8 */ |
421 | pix->pixelformat = V4L2_PIX_FMT_SBGGR8; | 421 | pix->pixelformat = V4L2_PIX_FMT_SBGGR8; |
422 | v4l2_fill_mbus_format(&mbus_fmt, pix, | 422 | v4l2_fill_mbus_format(&mbus_fmt, pix, |
423 | V4L2_MBUS_FMT_SBGGR8_1X8); | 423 | MEDIA_BUS_FMT_SBGGR8_1X8); |
424 | } | 424 | } |
425 | 425 | ||
426 | /* if sub device supports g_mbus_fmt, override the defaults */ | 426 | /* if sub device supports g_mbus_fmt, override the defaults */ |
@@ -930,8 +930,8 @@ static int vpfe_querycap(struct file *file, void *priv, | |||
930 | 930 | ||
931 | v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n"); | 931 | v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n"); |
932 | 932 | ||
933 | cap->version = VPFE_CAPTURE_VERSION_CODE; | 933 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; |
934 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; | 934 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
935 | strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver)); | 935 | strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver)); |
936 | strlcpy(cap->bus_info, "VPFE", sizeof(cap->bus_info)); | 936 | strlcpy(cap->bus_info, "VPFE", sizeof(cap->bus_info)); |
937 | strlcpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card)); | 937 | strlcpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card)); |
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 3ccb26ff43c8..d8e1b98b7784 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c | |||
@@ -311,6 +311,8 @@ static struct vb2_ops video_qops = { | |||
311 | .start_streaming = vpif_start_streaming, | 311 | .start_streaming = vpif_start_streaming, |
312 | .stop_streaming = vpif_stop_streaming, | 312 | .stop_streaming = vpif_stop_streaming, |
313 | .buf_queue = vpif_buffer_queue, | 313 | .buf_queue = vpif_buffer_queue, |
314 | .wait_prepare = vb2_ops_wait_prepare, | ||
315 | .wait_finish = vb2_ops_wait_finish, | ||
314 | }; | 316 | }; |
315 | 317 | ||
316 | /** | 318 | /** |
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index b4c9f1d08968..3062e9fac6da 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c | |||
@@ -54,7 +54,7 @@ static const struct gsc_fmt gsc_formats[] = { | |||
54 | .corder = GSC_CBCR, | 54 | .corder = GSC_CBCR, |
55 | .num_planes = 1, | 55 | .num_planes = 1, |
56 | .num_comp = 1, | 56 | .num_comp = 1, |
57 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 57 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
58 | }, { | 58 | }, { |
59 | .name = "YUV 4:2:2 packed, CbYCrY", | 59 | .name = "YUV 4:2:2 packed, CbYCrY", |
60 | .pixelformat = V4L2_PIX_FMT_UYVY, | 60 | .pixelformat = V4L2_PIX_FMT_UYVY, |
@@ -64,7 +64,7 @@ static const struct gsc_fmt gsc_formats[] = { | |||
64 | .corder = GSC_CBCR, | 64 | .corder = GSC_CBCR, |
65 | .num_planes = 1, | 65 | .num_planes = 1, |
66 | .num_comp = 1, | 66 | .num_comp = 1, |
67 | .mbus_code = V4L2_MBUS_FMT_UYVY8_2X8, | 67 | .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, |
68 | }, { | 68 | }, { |
69 | .name = "YUV 4:2:2 packed, CrYCbY", | 69 | .name = "YUV 4:2:2 packed, CrYCbY", |
70 | .pixelformat = V4L2_PIX_FMT_VYUY, | 70 | .pixelformat = V4L2_PIX_FMT_VYUY, |
@@ -74,7 +74,7 @@ static const struct gsc_fmt gsc_formats[] = { | |||
74 | .corder = GSC_CRCB, | 74 | .corder = GSC_CRCB, |
75 | .num_planes = 1, | 75 | .num_planes = 1, |
76 | .num_comp = 1, | 76 | .num_comp = 1, |
77 | .mbus_code = V4L2_MBUS_FMT_VYUY8_2X8, | 77 | .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, |
78 | }, { | 78 | }, { |
79 | .name = "YUV 4:2:2 packed, YCrYCb", | 79 | .name = "YUV 4:2:2 packed, YCrYCb", |
80 | .pixelformat = V4L2_PIX_FMT_YVYU, | 80 | .pixelformat = V4L2_PIX_FMT_YVYU, |
@@ -84,7 +84,7 @@ static const struct gsc_fmt gsc_formats[] = { | |||
84 | .corder = GSC_CRCB, | 84 | .corder = GSC_CRCB, |
85 | .num_planes = 1, | 85 | .num_planes = 1, |
86 | .num_comp = 1, | 86 | .num_comp = 1, |
87 | .mbus_code = V4L2_MBUS_FMT_YVYU8_2X8, | 87 | .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, |
88 | }, { | 88 | }, { |
89 | .name = "YUV 4:4:4 planar, YCbYCr", | 89 | .name = "YUV 4:4:4 planar, YCbYCr", |
90 | .pixelformat = V4L2_PIX_FMT_YUV32, | 90 | .pixelformat = V4L2_PIX_FMT_YUV32, |
@@ -319,21 +319,22 @@ int gsc_enum_fmt_mplane(struct v4l2_fmtdesc *f) | |||
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | static u32 get_plane_info(struct gsc_frame *frm, u32 addr, u32 *index) | 322 | static int get_plane_info(struct gsc_frame *frm, u32 addr, u32 *index, u32 *ret_addr) |
323 | { | 323 | { |
324 | if (frm->addr.y == addr) { | 324 | if (frm->addr.y == addr) { |
325 | *index = 0; | 325 | *index = 0; |
326 | return frm->addr.y; | 326 | *ret_addr = frm->addr.y; |
327 | } else if (frm->addr.cb == addr) { | 327 | } else if (frm->addr.cb == addr) { |
328 | *index = 1; | 328 | *index = 1; |
329 | return frm->addr.cb; | 329 | *ret_addr = frm->addr.cb; |
330 | } else if (frm->addr.cr == addr) { | 330 | } else if (frm->addr.cr == addr) { |
331 | *index = 2; | 331 | *index = 2; |
332 | return frm->addr.cr; | 332 | *ret_addr = frm->addr.cr; |
333 | } else { | 333 | } else { |
334 | pr_err("Plane address is wrong"); | 334 | pr_err("Plane address is wrong"); |
335 | return -EINVAL; | 335 | return -EINVAL; |
336 | } | 336 | } |
337 | return 0; | ||
337 | } | 338 | } |
338 | 339 | ||
339 | void gsc_set_prefbuf(struct gsc_dev *gsc, struct gsc_frame *frm) | 340 | void gsc_set_prefbuf(struct gsc_dev *gsc, struct gsc_frame *frm) |
@@ -352,9 +353,11 @@ void gsc_set_prefbuf(struct gsc_dev *gsc, struct gsc_frame *frm) | |||
352 | u32 t_min, t_max; | 353 | u32 t_min, t_max; |
353 | 354 | ||
354 | t_min = min3(frm->addr.y, frm->addr.cb, frm->addr.cr); | 355 | t_min = min3(frm->addr.y, frm->addr.cb, frm->addr.cr); |
355 | low_addr = get_plane_info(frm, t_min, &low_plane); | 356 | if (get_plane_info(frm, t_min, &low_plane, &low_addr)) |
357 | return; | ||
356 | t_max = max3(frm->addr.y, frm->addr.cb, frm->addr.cr); | 358 | t_max = max3(frm->addr.y, frm->addr.cb, frm->addr.cr); |
357 | high_addr = get_plane_info(frm, t_max, &high_plane); | 359 | if (get_plane_info(frm, t_max, &high_plane, &high_addr)) |
360 | return; | ||
358 | 361 | ||
359 | mid_plane = 3 - (low_plane + high_plane); | 362 | mid_plane = 3 - (low_plane + high_plane); |
360 | if (mid_plane == 0) | 363 | if (mid_plane == 0) |
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h index ef0a6564cef9..0abdb17fb19c 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.h +++ b/drivers/media/platform/exynos-gsc/gsc-core.h | |||
@@ -117,7 +117,7 @@ enum gsc_yuv_fmt { | |||
117 | * @flags: flags indicating which operation mode format applies to | 117 | * @flags: flags indicating which operation mode format applies to |
118 | */ | 118 | */ |
119 | struct gsc_fmt { | 119 | struct gsc_fmt { |
120 | enum v4l2_mbus_pixelcode mbus_code; | 120 | u32 mbus_code; |
121 | char *name; | 121 | char *name; |
122 | u32 pixelformat; | 122 | u32 pixelformat; |
123 | u32 color; | 123 | u32 color; |
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 3d2babd5067a..8a2fd8c33d42 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c | |||
@@ -749,7 +749,7 @@ static int fimc_cap_enum_fmt_mplane(struct file *file, void *priv, | |||
749 | return -EINVAL; | 749 | return -EINVAL; |
750 | strncpy(f->description, fmt->name, sizeof(f->description) - 1); | 750 | strncpy(f->description, fmt->name, sizeof(f->description) - 1); |
751 | f->pixelformat = fmt->fourcc; | 751 | f->pixelformat = fmt->fourcc; |
752 | if (fmt->fourcc == V4L2_MBUS_FMT_JPEG_1X8) | 752 | if (fmt->fourcc == MEDIA_BUS_FMT_JPEG_1X8) |
753 | f->flags |= V4L2_FMT_FLAG_COMPRESSED; | 753 | f->flags |= V4L2_FMT_FLAG_COMPRESSED; |
754 | return 0; | 754 | return 0; |
755 | } | 755 | } |
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c index f5d85520caf3..2acc19573b6b 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.c +++ b/drivers/media/platform/exynos4-is/fimc-core.c | |||
@@ -81,7 +81,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
81 | .flags = FMT_FLAGS_M2M_OUT | FMT_HAS_ALPHA, | 81 | .flags = FMT_FLAGS_M2M_OUT | FMT_HAS_ALPHA, |
82 | }, { | 82 | }, { |
83 | .name = "YUV 4:4:4", | 83 | .name = "YUV 4:4:4", |
84 | .mbus_code = V4L2_MBUS_FMT_YUV10_1X30, | 84 | .mbus_code = MEDIA_BUS_FMT_YUV10_1X30, |
85 | .flags = FMT_FLAGS_WRITEBACK, | 85 | .flags = FMT_FLAGS_WRITEBACK, |
86 | }, { | 86 | }, { |
87 | .name = "YUV 4:2:2 packed, YCbYCr", | 87 | .name = "YUV 4:2:2 packed, YCbYCr", |
@@ -90,7 +90,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
90 | .color = FIMC_FMT_YCBYCR422, | 90 | .color = FIMC_FMT_YCBYCR422, |
91 | .memplanes = 1, | 91 | .memplanes = 1, |
92 | .colplanes = 1, | 92 | .colplanes = 1, |
93 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 93 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
94 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, | 94 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, |
95 | }, { | 95 | }, { |
96 | .name = "YUV 4:2:2 packed, CbYCrY", | 96 | .name = "YUV 4:2:2 packed, CbYCrY", |
@@ -99,7 +99,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
99 | .color = FIMC_FMT_CBYCRY422, | 99 | .color = FIMC_FMT_CBYCRY422, |
100 | .memplanes = 1, | 100 | .memplanes = 1, |
101 | .colplanes = 1, | 101 | .colplanes = 1, |
102 | .mbus_code = V4L2_MBUS_FMT_UYVY8_2X8, | 102 | .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, |
103 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, | 103 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, |
104 | }, { | 104 | }, { |
105 | .name = "YUV 4:2:2 packed, CrYCbY", | 105 | .name = "YUV 4:2:2 packed, CrYCbY", |
@@ -108,7 +108,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
108 | .color = FIMC_FMT_CRYCBY422, | 108 | .color = FIMC_FMT_CRYCBY422, |
109 | .memplanes = 1, | 109 | .memplanes = 1, |
110 | .colplanes = 1, | 110 | .colplanes = 1, |
111 | .mbus_code = V4L2_MBUS_FMT_VYUY8_2X8, | 111 | .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, |
112 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, | 112 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, |
113 | }, { | 113 | }, { |
114 | .name = "YUV 4:2:2 packed, YCrYCb", | 114 | .name = "YUV 4:2:2 packed, YCrYCb", |
@@ -117,7 +117,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
117 | .color = FIMC_FMT_YCRYCB422, | 117 | .color = FIMC_FMT_YCRYCB422, |
118 | .memplanes = 1, | 118 | .memplanes = 1, |
119 | .colplanes = 1, | 119 | .colplanes = 1, |
120 | .mbus_code = V4L2_MBUS_FMT_YVYU8_2X8, | 120 | .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, |
121 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, | 121 | .flags = FMT_FLAGS_M2M | FMT_FLAGS_CAM, |
122 | }, { | 122 | }, { |
123 | .name = "YUV 4:2:2 planar, Y/Cb/Cr", | 123 | .name = "YUV 4:2:2 planar, Y/Cb/Cr", |
@@ -190,7 +190,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
190 | .depth = { 8 }, | 190 | .depth = { 8 }, |
191 | .memplanes = 1, | 191 | .memplanes = 1, |
192 | .colplanes = 1, | 192 | .colplanes = 1, |
193 | .mbus_code = V4L2_MBUS_FMT_JPEG_1X8, | 193 | .mbus_code = MEDIA_BUS_FMT_JPEG_1X8, |
194 | .flags = FMT_FLAGS_CAM | FMT_FLAGS_COMPRESSED, | 194 | .flags = FMT_FLAGS_CAM | FMT_FLAGS_COMPRESSED, |
195 | }, { | 195 | }, { |
196 | .name = "S5C73MX interleaved UYVY/JPEG", | 196 | .name = "S5C73MX interleaved UYVY/JPEG", |
@@ -200,7 +200,7 @@ static struct fimc_fmt fimc_formats[] = { | |||
200 | .memplanes = 2, | 200 | .memplanes = 2, |
201 | .colplanes = 1, | 201 | .colplanes = 1, |
202 | .mdataplanes = 0x2, /* plane 1 holds frame meta data */ | 202 | .mdataplanes = 0x2, /* plane 1 holds frame meta data */ |
203 | .mbus_code = V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8, | 203 | .mbus_code = MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8, |
204 | .flags = FMT_FLAGS_CAM | FMT_FLAGS_COMPRESSED, | 204 | .flags = FMT_FLAGS_CAM | FMT_FLAGS_COMPRESSED, |
205 | }, | 205 | }, |
206 | }; | 206 | }; |
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index 6c75c6ced1f7..7328f0845065 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h | |||
@@ -579,8 +579,8 @@ static inline bool fimc_jpeg_fourcc(u32 pixelformat) | |||
579 | 579 | ||
580 | static inline bool fimc_user_defined_mbus_fmt(u32 code) | 580 | static inline bool fimc_user_defined_mbus_fmt(u32 code) |
581 | { | 581 | { |
582 | return (code == V4L2_MBUS_FMT_JPEG_1X8 || | 582 | return (code == MEDIA_BUS_FMT_JPEG_1X8 || |
583 | code == V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8); | 583 | code == MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8); |
584 | } | 584 | } |
585 | 585 | ||
586 | /* Return the alpha component bit mask */ | 586 | /* Return the alpha component bit mask */ |
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c index 22162b2567da..2a0cbeff0324 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.c +++ b/drivers/media/platform/exynos4-is/fimc-is.c | |||
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context) | |||
428 | * needed around for copying to the IS working memory every | 428 | * needed around for copying to the IS working memory every |
429 | * time before the Cortex-A5 is restarted. | 429 | * time before the Cortex-A5 is restarted. |
430 | */ | 430 | */ |
431 | if (is->fw.f_w) | 431 | release_firmware(is->fw.f_w); |
432 | release_firmware(is->fw.f_w); | ||
433 | is->fw.f_w = fw; | 432 | is->fw.f_w = fw; |
434 | done: | 433 | done: |
435 | mutex_unlock(&is->lock); | 434 | mutex_unlock(&is->lock); |
@@ -814,9 +813,9 @@ static int fimc_is_probe(struct platform_device *pdev) | |||
814 | return -ENOMEM; | 813 | return -ENOMEM; |
815 | 814 | ||
816 | is->irq = irq_of_parse_and_map(dev->of_node, 0); | 815 | is->irq = irq_of_parse_and_map(dev->of_node, 0); |
817 | if (is->irq < 0) { | 816 | if (!is->irq) { |
818 | dev_err(dev, "no irq found\n"); | 817 | dev_err(dev, "no irq found\n"); |
819 | return is->irq; | 818 | return -EINVAL; |
820 | } | 819 | } |
821 | 820 | ||
822 | ret = fimc_is_get_clocks(is); | 821 | ret = fimc_is_get_clocks(is); |
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev) | |||
937 | vb2_dma_contig_cleanup_ctx(is->alloc_ctx); | 936 | vb2_dma_contig_cleanup_ctx(is->alloc_ctx); |
938 | fimc_is_put_clocks(is); | 937 | fimc_is_put_clocks(is); |
939 | fimc_is_debugfs_remove(is); | 938 | fimc_is_debugfs_remove(is); |
940 | if (is->fw.f_w) | 939 | release_firmware(is->fw.f_w); |
941 | release_firmware(is->fw.f_w); | ||
942 | fimc_is_free_cpu_memory(is); | 940 | fimc_is_free_cpu_memory(is); |
943 | 941 | ||
944 | return 0; | 942 | return 0; |
diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index be62d6b9ac48..60c744915549 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c | |||
@@ -41,21 +41,21 @@ static const struct fimc_fmt fimc_isp_formats[FIMC_ISP_NUM_FORMATS] = { | |||
41 | .depth = { 8 }, | 41 | .depth = { 8 }, |
42 | .color = FIMC_FMT_RAW8, | 42 | .color = FIMC_FMT_RAW8, |
43 | .memplanes = 1, | 43 | .memplanes = 1, |
44 | .mbus_code = V4L2_MBUS_FMT_SGRBG8_1X8, | 44 | .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, |
45 | }, { | 45 | }, { |
46 | .name = "RAW10 (GRBG)", | 46 | .name = "RAW10 (GRBG)", |
47 | .fourcc = V4L2_PIX_FMT_SGRBG10, | 47 | .fourcc = V4L2_PIX_FMT_SGRBG10, |
48 | .depth = { 10 }, | 48 | .depth = { 10 }, |
49 | .color = FIMC_FMT_RAW10, | 49 | .color = FIMC_FMT_RAW10, |
50 | .memplanes = 1, | 50 | .memplanes = 1, |
51 | .mbus_code = V4L2_MBUS_FMT_SGRBG10_1X10, | 51 | .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, |
52 | }, { | 52 | }, { |
53 | .name = "RAW12 (GRBG)", | 53 | .name = "RAW12 (GRBG)", |
54 | .fourcc = V4L2_PIX_FMT_SGRBG12, | 54 | .fourcc = V4L2_PIX_FMT_SGRBG12, |
55 | .depth = { 12 }, | 55 | .depth = { 12 }, |
56 | .color = FIMC_FMT_RAW12, | 56 | .color = FIMC_FMT_RAW12, |
57 | .memplanes = 1, | 57 | .memplanes = 1, |
58 | .mbus_code = V4L2_MBUS_FMT_SGRBG12_1X12, | 58 | .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, |
59 | }, | 59 | }, |
60 | }; | 60 | }; |
61 | 61 | ||
@@ -149,7 +149,7 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd, | |||
149 | 149 | ||
150 | if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) { | 150 | if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) { |
151 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 151 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
152 | mf->code = V4L2_MBUS_FMT_YUV10_1X30; | 152 | mf->code = MEDIA_BUS_FMT_YUV10_1X30; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
@@ -175,7 +175,7 @@ static void __isp_subdev_try_format(struct fimc_isp *isp, | |||
175 | FIMC_ISP_SINK_WIDTH_MAX, 0, | 175 | FIMC_ISP_SINK_WIDTH_MAX, 0, |
176 | &mf->height, FIMC_ISP_SINK_HEIGHT_MIN, | 176 | &mf->height, FIMC_ISP_SINK_HEIGHT_MIN, |
177 | FIMC_ISP_SINK_HEIGHT_MAX, 0, 0); | 177 | FIMC_ISP_SINK_HEIGHT_MAX, 0, 0); |
178 | mf->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 178 | mf->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
179 | } else { | 179 | } else { |
180 | if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) | 180 | if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) |
181 | format = v4l2_subdev_get_try_format(fh, | 181 | format = v4l2_subdev_get_try_format(fh, |
@@ -188,7 +188,7 @@ static void __isp_subdev_try_format(struct fimc_isp *isp, | |||
188 | mf->height = format->height - FIMC_ISP_CAC_MARGIN_HEIGHT; | 188 | mf->height = format->height - FIMC_ISP_CAC_MARGIN_HEIGHT; |
189 | 189 | ||
190 | if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) { | 190 | if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) { |
191 | mf->code = V4L2_MBUS_FMT_YUV10_1X30; | 191 | mf->code = MEDIA_BUS_FMT_YUV10_1X30; |
192 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 192 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
193 | } else { | 193 | } else { |
194 | mf->code = format->code; | 194 | mf->code = format->code; |
@@ -680,11 +680,11 @@ static void __isp_subdev_set_default_format(struct fimc_isp *isp) | |||
680 | FIMC_ISP_CAC_MARGIN_WIDTH; | 680 | FIMC_ISP_CAC_MARGIN_WIDTH; |
681 | isp->sink_fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT + | 681 | isp->sink_fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT + |
682 | FIMC_ISP_CAC_MARGIN_HEIGHT; | 682 | FIMC_ISP_CAC_MARGIN_HEIGHT; |
683 | isp->sink_fmt.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 683 | isp->sink_fmt.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
684 | 684 | ||
685 | isp->src_fmt.width = DEFAULT_PREVIEW_STILL_WIDTH; | 685 | isp->src_fmt.width = DEFAULT_PREVIEW_STILL_WIDTH; |
686 | isp->src_fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT; | 686 | isp->src_fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT; |
687 | isp->src_fmt.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 687 | isp->src_fmt.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
688 | __is_set_frame_size(is, &isp->src_fmt); | 688 | __is_set_frame_size(is, &isp->src_fmt); |
689 | } | 689 | } |
690 | 690 | ||
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c b/drivers/media/platform/exynos4-is/fimc-lite-reg.c index bc3ec7d25a32..0477716a20db 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c +++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c | |||
@@ -112,24 +112,24 @@ void flite_hw_set_test_pattern(struct fimc_lite *dev, bool on) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | static const u32 src_pixfmt_map[8][3] = { | 114 | static const u32 src_pixfmt_map[8][3] = { |
115 | { V4L2_MBUS_FMT_YUYV8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_YCBYCR, | 115 | { MEDIA_BUS_FMT_YUYV8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_YCBYCR, |
116 | FLITE_REG_CIGCTRL_YUV422_1P }, | 116 | FLITE_REG_CIGCTRL_YUV422_1P }, |
117 | { V4L2_MBUS_FMT_YVYU8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_YCRYCB, | 117 | { MEDIA_BUS_FMT_YVYU8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_YCRYCB, |
118 | FLITE_REG_CIGCTRL_YUV422_1P }, | 118 | FLITE_REG_CIGCTRL_YUV422_1P }, |
119 | { V4L2_MBUS_FMT_UYVY8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_CBYCRY, | 119 | { MEDIA_BUS_FMT_UYVY8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_CBYCRY, |
120 | FLITE_REG_CIGCTRL_YUV422_1P }, | 120 | FLITE_REG_CIGCTRL_YUV422_1P }, |
121 | { V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_CRYCBY, | 121 | { MEDIA_BUS_FMT_VYUY8_2X8, FLITE_REG_CISRCSIZE_ORDER422_IN_CRYCBY, |
122 | FLITE_REG_CIGCTRL_YUV422_1P }, | 122 | FLITE_REG_CIGCTRL_YUV422_1P }, |
123 | { V4L2_MBUS_FMT_SGRBG8_1X8, 0, FLITE_REG_CIGCTRL_RAW8 }, | 123 | { MEDIA_BUS_FMT_SGRBG8_1X8, 0, FLITE_REG_CIGCTRL_RAW8 }, |
124 | { V4L2_MBUS_FMT_SGRBG10_1X10, 0, FLITE_REG_CIGCTRL_RAW10 }, | 124 | { MEDIA_BUS_FMT_SGRBG10_1X10, 0, FLITE_REG_CIGCTRL_RAW10 }, |
125 | { V4L2_MBUS_FMT_SGRBG12_1X12, 0, FLITE_REG_CIGCTRL_RAW12 }, | 125 | { MEDIA_BUS_FMT_SGRBG12_1X12, 0, FLITE_REG_CIGCTRL_RAW12 }, |
126 | { V4L2_MBUS_FMT_JPEG_1X8, 0, FLITE_REG_CIGCTRL_USER(1) }, | 126 | { MEDIA_BUS_FMT_JPEG_1X8, 0, FLITE_REG_CIGCTRL_USER(1) }, |
127 | }; | 127 | }; |
128 | 128 | ||
129 | /* Set camera input pixel format and resolution */ | 129 | /* Set camera input pixel format and resolution */ |
130 | void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f) | 130 | void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f) |
131 | { | 131 | { |
132 | enum v4l2_mbus_pixelcode pixelcode = f->fmt->mbus_code; | 132 | u32 pixelcode = f->fmt->mbus_code; |
133 | int i = ARRAY_SIZE(src_pixfmt_map); | 133 | int i = ARRAY_SIZE(src_pixfmt_map); |
134 | u32 cfg; | 134 | u32 cfg; |
135 | 135 | ||
@@ -232,10 +232,10 @@ static void flite_hw_set_pack12(struct fimc_lite *dev, int on) | |||
232 | static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f) | 232 | static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f) |
233 | { | 233 | { |
234 | static const u32 pixcode[4][2] = { | 234 | static const u32 pixcode[4][2] = { |
235 | { V4L2_MBUS_FMT_YUYV8_2X8, FLITE_REG_CIODMAFMT_YCBYCR }, | 235 | { MEDIA_BUS_FMT_YUYV8_2X8, FLITE_REG_CIODMAFMT_YCBYCR }, |
236 | { V4L2_MBUS_FMT_YVYU8_2X8, FLITE_REG_CIODMAFMT_YCRYCB }, | 236 | { MEDIA_BUS_FMT_YVYU8_2X8, FLITE_REG_CIODMAFMT_YCRYCB }, |
237 | { V4L2_MBUS_FMT_UYVY8_2X8, FLITE_REG_CIODMAFMT_CBYCRY }, | 237 | { MEDIA_BUS_FMT_UYVY8_2X8, FLITE_REG_CIODMAFMT_CBYCRY }, |
238 | { V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY }, | 238 | { MEDIA_BUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY }, |
239 | }; | 239 | }; |
240 | u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT); | 240 | u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT); |
241 | int i = ARRAY_SIZE(pixcode); | 241 | int i = ARRAY_SIZE(pixcode); |
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 6c1eb308f7b5..7e8687338155 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c | |||
@@ -48,7 +48,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
48 | .depth = { 16 }, | 48 | .depth = { 16 }, |
49 | .color = FIMC_FMT_YCBYCR422, | 49 | .color = FIMC_FMT_YCBYCR422, |
50 | .memplanes = 1, | 50 | .memplanes = 1, |
51 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 51 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
52 | .flags = FMT_FLAGS_YUV, | 52 | .flags = FMT_FLAGS_YUV, |
53 | }, { | 53 | }, { |
54 | .name = "YUV 4:2:2 packed, CbYCrY", | 54 | .name = "YUV 4:2:2 packed, CbYCrY", |
@@ -57,7 +57,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
57 | .depth = { 16 }, | 57 | .depth = { 16 }, |
58 | .color = FIMC_FMT_CBYCRY422, | 58 | .color = FIMC_FMT_CBYCRY422, |
59 | .memplanes = 1, | 59 | .memplanes = 1, |
60 | .mbus_code = V4L2_MBUS_FMT_UYVY8_2X8, | 60 | .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, |
61 | .flags = FMT_FLAGS_YUV, | 61 | .flags = FMT_FLAGS_YUV, |
62 | }, { | 62 | }, { |
63 | .name = "YUV 4:2:2 packed, CrYCbY", | 63 | .name = "YUV 4:2:2 packed, CrYCbY", |
@@ -66,7 +66,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
66 | .depth = { 16 }, | 66 | .depth = { 16 }, |
67 | .color = FIMC_FMT_CRYCBY422, | 67 | .color = FIMC_FMT_CRYCBY422, |
68 | .memplanes = 1, | 68 | .memplanes = 1, |
69 | .mbus_code = V4L2_MBUS_FMT_VYUY8_2X8, | 69 | .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, |
70 | .flags = FMT_FLAGS_YUV, | 70 | .flags = FMT_FLAGS_YUV, |
71 | }, { | 71 | }, { |
72 | .name = "YUV 4:2:2 packed, YCrYCb", | 72 | .name = "YUV 4:2:2 packed, YCrYCb", |
@@ -75,7 +75,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
75 | .depth = { 16 }, | 75 | .depth = { 16 }, |
76 | .color = FIMC_FMT_YCRYCB422, | 76 | .color = FIMC_FMT_YCRYCB422, |
77 | .memplanes = 1, | 77 | .memplanes = 1, |
78 | .mbus_code = V4L2_MBUS_FMT_YVYU8_2X8, | 78 | .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, |
79 | .flags = FMT_FLAGS_YUV, | 79 | .flags = FMT_FLAGS_YUV, |
80 | }, { | 80 | }, { |
81 | .name = "RAW8 (GRBG)", | 81 | .name = "RAW8 (GRBG)", |
@@ -84,7 +84,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
84 | .depth = { 8 }, | 84 | .depth = { 8 }, |
85 | .color = FIMC_FMT_RAW8, | 85 | .color = FIMC_FMT_RAW8, |
86 | .memplanes = 1, | 86 | .memplanes = 1, |
87 | .mbus_code = V4L2_MBUS_FMT_SGRBG8_1X8, | 87 | .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, |
88 | .flags = FMT_FLAGS_RAW_BAYER, | 88 | .flags = FMT_FLAGS_RAW_BAYER, |
89 | }, { | 89 | }, { |
90 | .name = "RAW10 (GRBG)", | 90 | .name = "RAW10 (GRBG)", |
@@ -93,7 +93,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
93 | .depth = { 16 }, | 93 | .depth = { 16 }, |
94 | .color = FIMC_FMT_RAW10, | 94 | .color = FIMC_FMT_RAW10, |
95 | .memplanes = 1, | 95 | .memplanes = 1, |
96 | .mbus_code = V4L2_MBUS_FMT_SGRBG10_1X10, | 96 | .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, |
97 | .flags = FMT_FLAGS_RAW_BAYER, | 97 | .flags = FMT_FLAGS_RAW_BAYER, |
98 | }, { | 98 | }, { |
99 | .name = "RAW12 (GRBG)", | 99 | .name = "RAW12 (GRBG)", |
@@ -102,7 +102,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { | |||
102 | .depth = { 16 }, | 102 | .depth = { 16 }, |
103 | .color = FIMC_FMT_RAW12, | 103 | .color = FIMC_FMT_RAW12, |
104 | .memplanes = 1, | 104 | .memplanes = 1, |
105 | .mbus_code = V4L2_MBUS_FMT_SGRBG12_1X12, | 105 | .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, |
106 | .flags = FMT_FLAGS_RAW_BAYER, | 106 | .flags = FMT_FLAGS_RAW_BAYER, |
107 | }, | 107 | }, |
108 | }; | 108 | }; |
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c b/drivers/media/platform/exynos4-is/fimc-reg.c index 2d77fd8f440a..df0cbcb69b6b 100644 --- a/drivers/media/platform/exynos4-is/fimc-reg.c +++ b/drivers/media/platform/exynos4-is/fimc-reg.c | |||
@@ -592,10 +592,10 @@ struct mbus_pixfmt_desc { | |||
592 | }; | 592 | }; |
593 | 593 | ||
594 | static const struct mbus_pixfmt_desc pix_desc[] = { | 594 | static const struct mbus_pixfmt_desc pix_desc[] = { |
595 | { V4L2_MBUS_FMT_YUYV8_2X8, FIMC_REG_CISRCFMT_ORDER422_YCBYCR, 8 }, | 595 | { MEDIA_BUS_FMT_YUYV8_2X8, FIMC_REG_CISRCFMT_ORDER422_YCBYCR, 8 }, |
596 | { V4L2_MBUS_FMT_YVYU8_2X8, FIMC_REG_CISRCFMT_ORDER422_YCRYCB, 8 }, | 596 | { MEDIA_BUS_FMT_YVYU8_2X8, FIMC_REG_CISRCFMT_ORDER422_YCRYCB, 8 }, |
597 | { V4L2_MBUS_FMT_VYUY8_2X8, FIMC_REG_CISRCFMT_ORDER422_CRYCBY, 8 }, | 597 | { MEDIA_BUS_FMT_VYUY8_2X8, FIMC_REG_CISRCFMT_ORDER422_CRYCBY, 8 }, |
598 | { V4L2_MBUS_FMT_UYVY8_2X8, FIMC_REG_CISRCFMT_ORDER422_CBYCRY, 8 }, | 598 | { MEDIA_BUS_FMT_UYVY8_2X8, FIMC_REG_CISRCFMT_ORDER422_CBYCRY, 8 }, |
599 | }; | 599 | }; |
600 | 600 | ||
601 | int fimc_hw_set_camera_source(struct fimc_dev *fimc, | 601 | int fimc_hw_set_camera_source(struct fimc_dev *fimc, |
@@ -689,11 +689,11 @@ int fimc_hw_set_camera_type(struct fimc_dev *fimc, | |||
689 | 689 | ||
690 | /* TODO: add remaining supported formats. */ | 690 | /* TODO: add remaining supported formats. */ |
691 | switch (vid_cap->ci_fmt.code) { | 691 | switch (vid_cap->ci_fmt.code) { |
692 | case V4L2_MBUS_FMT_VYUY8_2X8: | 692 | case MEDIA_BUS_FMT_VYUY8_2X8: |
693 | tmp = FIMC_REG_CSIIMGFMT_YCBCR422_8BIT; | 693 | tmp = FIMC_REG_CSIIMGFMT_YCBCR422_8BIT; |
694 | break; | 694 | break; |
695 | case V4L2_MBUS_FMT_JPEG_1X8: | 695 | case MEDIA_BUS_FMT_JPEG_1X8: |
696 | case V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8: | 696 | case MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8: |
697 | tmp = FIMC_REG_CSIIMGFMT_USER(1); | 697 | tmp = FIMC_REG_CSIIMGFMT_USER(1); |
698 | cfg |= FIMC_REG_CIGCTRL_CAM_JPEG; | 698 | cfg |= FIMC_REG_CIGCTRL_CAM_JPEG; |
699 | break; | 699 | break; |
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index be5d6fc895cb..9e1056d60c7e 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c | |||
@@ -238,34 +238,34 @@ struct csis_state { | |||
238 | */ | 238 | */ |
239 | struct csis_pix_format { | 239 | struct csis_pix_format { |
240 | unsigned int pix_width_alignment; | 240 | unsigned int pix_width_alignment; |
241 | enum v4l2_mbus_pixelcode code; | 241 | u32 code; |
242 | u32 fmt_reg; | 242 | u32 fmt_reg; |
243 | u8 data_alignment; | 243 | u8 data_alignment; |
244 | }; | 244 | }; |
245 | 245 | ||
246 | static const struct csis_pix_format s5pcsis_formats[] = { | 246 | static const struct csis_pix_format s5pcsis_formats[] = { |
247 | { | 247 | { |
248 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 248 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
249 | .fmt_reg = S5PCSIS_CFG_FMT_YCBCR422_8BIT, | 249 | .fmt_reg = S5PCSIS_CFG_FMT_YCBCR422_8BIT, |
250 | .data_alignment = 32, | 250 | .data_alignment = 32, |
251 | }, { | 251 | }, { |
252 | .code = V4L2_MBUS_FMT_JPEG_1X8, | 252 | .code = MEDIA_BUS_FMT_JPEG_1X8, |
253 | .fmt_reg = S5PCSIS_CFG_FMT_USER(1), | 253 | .fmt_reg = S5PCSIS_CFG_FMT_USER(1), |
254 | .data_alignment = 32, | 254 | .data_alignment = 32, |
255 | }, { | 255 | }, { |
256 | .code = V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8, | 256 | .code = MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8, |
257 | .fmt_reg = S5PCSIS_CFG_FMT_USER(1), | 257 | .fmt_reg = S5PCSIS_CFG_FMT_USER(1), |
258 | .data_alignment = 32, | 258 | .data_alignment = 32, |
259 | }, { | 259 | }, { |
260 | .code = V4L2_MBUS_FMT_SGRBG8_1X8, | 260 | .code = MEDIA_BUS_FMT_SGRBG8_1X8, |
261 | .fmt_reg = S5PCSIS_CFG_FMT_RAW8, | 261 | .fmt_reg = S5PCSIS_CFG_FMT_RAW8, |
262 | .data_alignment = 24, | 262 | .data_alignment = 24, |
263 | }, { | 263 | }, { |
264 | .code = V4L2_MBUS_FMT_SGRBG10_1X10, | 264 | .code = MEDIA_BUS_FMT_SGRBG10_1X10, |
265 | .fmt_reg = S5PCSIS_CFG_FMT_RAW10, | 265 | .fmt_reg = S5PCSIS_CFG_FMT_RAW10, |
266 | .data_alignment = 24, | 266 | .data_alignment = 24, |
267 | }, { | 267 | }, { |
268 | .code = V4L2_MBUS_FMT_SGRBG12_1X12, | 268 | .code = MEDIA_BUS_FMT_SGRBG12_1X12, |
269 | .fmt_reg = S5PCSIS_CFG_FMT_RAW12, | 269 | .fmt_reg = S5PCSIS_CFG_FMT_RAW12, |
270 | .data_alignment = 24, | 270 | .data_alignment = 24, |
271 | } | 271 | } |
diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c index d5dc198502ef..8afee3c17c1c 100644 --- a/drivers/media/platform/fsl-viu.c +++ b/drivers/media/platform/fsl-viu.c | |||
@@ -604,10 +604,11 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
604 | { | 604 | { |
605 | strcpy(cap->driver, "viu"); | 605 | strcpy(cap->driver, "viu"); |
606 | strcpy(cap->card, "viu"); | 606 | strcpy(cap->card, "viu"); |
607 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | | 607 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | |
608 | V4L2_CAP_STREAMING | | 608 | V4L2_CAP_STREAMING | |
609 | V4L2_CAP_VIDEO_OVERLAY | | 609 | V4L2_CAP_VIDEO_OVERLAY | |
610 | V4L2_CAP_READWRITE; | 610 | V4L2_CAP_READWRITE; |
611 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
611 | return 0; | 612 | return 0; |
612 | } | 613 | } |
613 | 614 | ||
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 7a86c77bffa0..193373ff268d 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c | |||
@@ -106,61 +106,61 @@ static struct mcam_format_struct { | |||
106 | __u32 pixelformat; | 106 | __u32 pixelformat; |
107 | int bpp; /* Bytes per pixel */ | 107 | int bpp; /* Bytes per pixel */ |
108 | bool planar; | 108 | bool planar; |
109 | enum v4l2_mbus_pixelcode mbus_code; | 109 | u32 mbus_code; |
110 | } mcam_formats[] = { | 110 | } mcam_formats[] = { |
111 | { | 111 | { |
112 | .desc = "YUYV 4:2:2", | 112 | .desc = "YUYV 4:2:2", |
113 | .pixelformat = V4L2_PIX_FMT_YUYV, | 113 | .pixelformat = V4L2_PIX_FMT_YUYV, |
114 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 114 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
115 | .bpp = 2, | 115 | .bpp = 2, |
116 | .planar = false, | 116 | .planar = false, |
117 | }, | 117 | }, |
118 | { | 118 | { |
119 | .desc = "UYVY 4:2:2", | 119 | .desc = "UYVY 4:2:2", |
120 | .pixelformat = V4L2_PIX_FMT_UYVY, | 120 | .pixelformat = V4L2_PIX_FMT_UYVY, |
121 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 121 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
122 | .bpp = 2, | 122 | .bpp = 2, |
123 | .planar = false, | 123 | .planar = false, |
124 | }, | 124 | }, |
125 | { | 125 | { |
126 | .desc = "YUV 4:2:2 PLANAR", | 126 | .desc = "YUV 4:2:2 PLANAR", |
127 | .pixelformat = V4L2_PIX_FMT_YUV422P, | 127 | .pixelformat = V4L2_PIX_FMT_YUV422P, |
128 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 128 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
129 | .bpp = 2, | 129 | .bpp = 2, |
130 | .planar = true, | 130 | .planar = true, |
131 | }, | 131 | }, |
132 | { | 132 | { |
133 | .desc = "YUV 4:2:0 PLANAR", | 133 | .desc = "YUV 4:2:0 PLANAR", |
134 | .pixelformat = V4L2_PIX_FMT_YUV420, | 134 | .pixelformat = V4L2_PIX_FMT_YUV420, |
135 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 135 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
136 | .bpp = 2, | 136 | .bpp = 2, |
137 | .planar = true, | 137 | .planar = true, |
138 | }, | 138 | }, |
139 | { | 139 | { |
140 | .desc = "YVU 4:2:0 PLANAR", | 140 | .desc = "YVU 4:2:0 PLANAR", |
141 | .pixelformat = V4L2_PIX_FMT_YVU420, | 141 | .pixelformat = V4L2_PIX_FMT_YVU420, |
142 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 142 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
143 | .bpp = 2, | 143 | .bpp = 2, |
144 | .planar = true, | 144 | .planar = true, |
145 | }, | 145 | }, |
146 | { | 146 | { |
147 | .desc = "RGB 444", | 147 | .desc = "RGB 444", |
148 | .pixelformat = V4L2_PIX_FMT_RGB444, | 148 | .pixelformat = V4L2_PIX_FMT_RGB444, |
149 | .mbus_code = V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, | 149 | .mbus_code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, |
150 | .bpp = 2, | 150 | .bpp = 2, |
151 | .planar = false, | 151 | .planar = false, |
152 | }, | 152 | }, |
153 | { | 153 | { |
154 | .desc = "RGB 565", | 154 | .desc = "RGB 565", |
155 | .pixelformat = V4L2_PIX_FMT_RGB565, | 155 | .pixelformat = V4L2_PIX_FMT_RGB565, |
156 | .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 156 | .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
157 | .bpp = 2, | 157 | .bpp = 2, |
158 | .planar = false, | 158 | .planar = false, |
159 | }, | 159 | }, |
160 | { | 160 | { |
161 | .desc = "Raw RGB Bayer", | 161 | .desc = "Raw RGB Bayer", |
162 | .pixelformat = V4L2_PIX_FMT_SBGGR8, | 162 | .pixelformat = V4L2_PIX_FMT_SBGGR8, |
163 | .mbus_code = V4L2_MBUS_FMT_SBGGR8_1X8, | 163 | .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, |
164 | .bpp = 1, | 164 | .bpp = 1, |
165 | .planar = false, | 165 | .planar = false, |
166 | }, | 166 | }, |
@@ -190,8 +190,7 @@ static const struct v4l2_pix_format mcam_def_pix_format = { | |||
190 | .sizeimage = VGA_WIDTH*VGA_HEIGHT*2, | 190 | .sizeimage = VGA_WIDTH*VGA_HEIGHT*2, |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static const enum v4l2_mbus_pixelcode mcam_def_mbus_code = | 193 | static const u32 mcam_def_mbus_code = MEDIA_BUS_FMT_YUYV8_2X8; |
194 | V4L2_MBUS_FMT_YUYV8_2X8; | ||
195 | 194 | ||
196 | 195 | ||
197 | /* | 196 | /* |
@@ -1080,6 +1079,8 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq, | |||
1080 | *nbufs = minbufs; | 1079 | *nbufs = minbufs; |
1081 | if (cam->buffer_mode == B_DMA_contig) | 1080 | if (cam->buffer_mode == B_DMA_contig) |
1082 | alloc_ctxs[0] = cam->vb_alloc_ctx; | 1081 | alloc_ctxs[0] = cam->vb_alloc_ctx; |
1082 | else if (cam->buffer_mode == B_DMA_sg) | ||
1083 | alloc_ctxs[0] = cam->vb_alloc_ctx_sg; | ||
1083 | return 0; | 1084 | return 0; |
1084 | } | 1085 | } |
1085 | 1086 | ||
@@ -1101,26 +1102,6 @@ static void mcam_vb_buf_queue(struct vb2_buffer *vb) | |||
1101 | mcam_read_setup(cam); | 1102 | mcam_read_setup(cam); |
1102 | } | 1103 | } |
1103 | 1104 | ||
1104 | |||
1105 | /* | ||
1106 | * vb2 uses these to release the mutex when waiting in dqbuf. I'm | ||
1107 | * not actually sure we need to do this (I'm not sure that vb2_dqbuf() needs | ||
1108 | * to be called with the mutex held), but better safe than sorry. | ||
1109 | */ | ||
1110 | static void mcam_vb_wait_prepare(struct vb2_queue *vq) | ||
1111 | { | ||
1112 | struct mcam_camera *cam = vb2_get_drv_priv(vq); | ||
1113 | |||
1114 | mutex_unlock(&cam->s_mutex); | ||
1115 | } | ||
1116 | |||
1117 | static void mcam_vb_wait_finish(struct vb2_queue *vq) | ||
1118 | { | ||
1119 | struct mcam_camera *cam = vb2_get_drv_priv(vq); | ||
1120 | |||
1121 | mutex_lock(&cam->s_mutex); | ||
1122 | } | ||
1123 | |||
1124 | /* | 1105 | /* |
1125 | * These need to be called with the mutex held from vb2 | 1106 | * These need to be called with the mutex held from vb2 |
1126 | */ | 1107 | */ |
@@ -1190,8 +1171,8 @@ static const struct vb2_ops mcam_vb2_ops = { | |||
1190 | .buf_queue = mcam_vb_buf_queue, | 1171 | .buf_queue = mcam_vb_buf_queue, |
1191 | .start_streaming = mcam_vb_start_streaming, | 1172 | .start_streaming = mcam_vb_start_streaming, |
1192 | .stop_streaming = mcam_vb_stop_streaming, | 1173 | .stop_streaming = mcam_vb_stop_streaming, |
1193 | .wait_prepare = mcam_vb_wait_prepare, | 1174 | .wait_prepare = vb2_ops_wait_prepare, |
1194 | .wait_finish = mcam_vb_wait_finish, | 1175 | .wait_finish = vb2_ops_wait_finish, |
1195 | }; | 1176 | }; |
1196 | 1177 | ||
1197 | 1178 | ||
@@ -1219,17 +1200,12 @@ static int mcam_vb_sg_buf_init(struct vb2_buffer *vb) | |||
1219 | static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb) | 1200 | static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb) |
1220 | { | 1201 | { |
1221 | struct mcam_vb_buffer *mvb = vb_to_mvb(vb); | 1202 | struct mcam_vb_buffer *mvb = vb_to_mvb(vb); |
1222 | struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue); | ||
1223 | struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0); | 1203 | struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0); |
1224 | struct mcam_dma_desc *desc = mvb->dma_desc; | 1204 | struct mcam_dma_desc *desc = mvb->dma_desc; |
1225 | struct scatterlist *sg; | 1205 | struct scatterlist *sg; |
1226 | int i; | 1206 | int i; |
1227 | 1207 | ||
1228 | mvb->dma_desc_nent = dma_map_sg(cam->dev, sg_table->sgl, | 1208 | for_each_sg(sg_table->sgl, sg, sg_table->nents, i) { |
1229 | sg_table->nents, DMA_FROM_DEVICE); | ||
1230 | if (mvb->dma_desc_nent <= 0) | ||
1231 | return -EIO; /* Not sure what's right here */ | ||
1232 | for_each_sg(sg_table->sgl, sg, mvb->dma_desc_nent, i) { | ||
1233 | desc->dma_addr = sg_dma_address(sg); | 1209 | desc->dma_addr = sg_dma_address(sg); |
1234 | desc->segment_len = sg_dma_len(sg); | 1210 | desc->segment_len = sg_dma_len(sg); |
1235 | desc++; | 1211 | desc++; |
@@ -1237,16 +1213,6 @@ static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb) | |||
1237 | return 0; | 1213 | return 0; |
1238 | } | 1214 | } |
1239 | 1215 | ||
1240 | static void mcam_vb_sg_buf_finish(struct vb2_buffer *vb) | ||
1241 | { | ||
1242 | struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue); | ||
1243 | struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0); | ||
1244 | |||
1245 | if (sg_table) | ||
1246 | dma_unmap_sg(cam->dev, sg_table->sgl, | ||
1247 | sg_table->nents, DMA_FROM_DEVICE); | ||
1248 | } | ||
1249 | |||
1250 | static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb) | 1216 | static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb) |
1251 | { | 1217 | { |
1252 | struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue); | 1218 | struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue); |
@@ -1263,12 +1229,11 @@ static const struct vb2_ops mcam_vb2_sg_ops = { | |||
1263 | .buf_init = mcam_vb_sg_buf_init, | 1229 | .buf_init = mcam_vb_sg_buf_init, |
1264 | .buf_prepare = mcam_vb_sg_buf_prepare, | 1230 | .buf_prepare = mcam_vb_sg_buf_prepare, |
1265 | .buf_queue = mcam_vb_buf_queue, | 1231 | .buf_queue = mcam_vb_buf_queue, |
1266 | .buf_finish = mcam_vb_sg_buf_finish, | ||
1267 | .buf_cleanup = mcam_vb_sg_buf_cleanup, | 1232 | .buf_cleanup = mcam_vb_sg_buf_cleanup, |
1268 | .start_streaming = mcam_vb_start_streaming, | 1233 | .start_streaming = mcam_vb_start_streaming, |
1269 | .stop_streaming = mcam_vb_stop_streaming, | 1234 | .stop_streaming = mcam_vb_stop_streaming, |
1270 | .wait_prepare = mcam_vb_wait_prepare, | 1235 | .wait_prepare = vb2_ops_wait_prepare, |
1271 | .wait_finish = mcam_vb_wait_finish, | 1236 | .wait_finish = vb2_ops_wait_finish, |
1272 | }; | 1237 | }; |
1273 | 1238 | ||
1274 | #endif /* MCAM_MODE_DMA_SG */ | 1239 | #endif /* MCAM_MODE_DMA_SG */ |
@@ -1280,6 +1245,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1280 | memset(vq, 0, sizeof(*vq)); | 1245 | memset(vq, 0, sizeof(*vq)); |
1281 | vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1246 | vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1282 | vq->drv_priv = cam; | 1247 | vq->drv_priv = cam; |
1248 | vq->lock = &cam->s_mutex; | ||
1283 | INIT_LIST_HEAD(&cam->buffers); | 1249 | INIT_LIST_HEAD(&cam->buffers); |
1284 | switch (cam->buffer_mode) { | 1250 | switch (cam->buffer_mode) { |
1285 | case B_DMA_contig: | 1251 | case B_DMA_contig: |
@@ -1287,10 +1253,12 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1287 | vq->ops = &mcam_vb2_ops; | 1253 | vq->ops = &mcam_vb2_ops; |
1288 | vq->mem_ops = &vb2_dma_contig_memops; | 1254 | vq->mem_ops = &vb2_dma_contig_memops; |
1289 | vq->buf_struct_size = sizeof(struct mcam_vb_buffer); | 1255 | vq->buf_struct_size = sizeof(struct mcam_vb_buffer); |
1290 | cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); | ||
1291 | vq->io_modes = VB2_MMAP | VB2_USERPTR; | 1256 | vq->io_modes = VB2_MMAP | VB2_USERPTR; |
1292 | cam->dma_setup = mcam_ctlr_dma_contig; | 1257 | cam->dma_setup = mcam_ctlr_dma_contig; |
1293 | cam->frame_complete = mcam_dma_contig_done; | 1258 | cam->frame_complete = mcam_dma_contig_done; |
1259 | cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); | ||
1260 | if (IS_ERR(cam->vb_alloc_ctx)) | ||
1261 | return PTR_ERR(cam->vb_alloc_ctx); | ||
1294 | #endif | 1262 | #endif |
1295 | break; | 1263 | break; |
1296 | case B_DMA_sg: | 1264 | case B_DMA_sg: |
@@ -1301,6 +1269,9 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1301 | vq->io_modes = VB2_MMAP | VB2_USERPTR; | 1269 | vq->io_modes = VB2_MMAP | VB2_USERPTR; |
1302 | cam->dma_setup = mcam_ctlr_dma_sg; | 1270 | cam->dma_setup = mcam_ctlr_dma_sg; |
1303 | cam->frame_complete = mcam_dma_sg_done; | 1271 | cam->frame_complete = mcam_dma_sg_done; |
1272 | cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev); | ||
1273 | if (IS_ERR(cam->vb_alloc_ctx_sg)) | ||
1274 | return PTR_ERR(cam->vb_alloc_ctx_sg); | ||
1304 | #endif | 1275 | #endif |
1305 | break; | 1276 | break; |
1306 | case B_vmalloc: | 1277 | case B_vmalloc: |
@@ -1326,6 +1297,10 @@ static void mcam_cleanup_vb2(struct mcam_camera *cam) | |||
1326 | if (cam->buffer_mode == B_DMA_contig) | 1297 | if (cam->buffer_mode == B_DMA_contig) |
1327 | vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx); | 1298 | vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx); |
1328 | #endif | 1299 | #endif |
1300 | #ifdef MCAM_MODE_DMA_SG | ||
1301 | if (cam->buffer_mode == B_DMA_sg) | ||
1302 | vb2_dma_sg_cleanup_ctx(cam->vb_alloc_ctx_sg); | ||
1303 | #endif | ||
1329 | } | 1304 | } |
1330 | 1305 | ||
1331 | 1306 | ||
@@ -1414,9 +1389,9 @@ static int mcam_vidioc_querycap(struct file *file, void *priv, | |||
1414 | { | 1389 | { |
1415 | strcpy(cap->driver, "marvell_ccic"); | 1390 | strcpy(cap->driver, "marvell_ccic"); |
1416 | strcpy(cap->card, "marvell_ccic"); | 1391 | strcpy(cap->card, "marvell_ccic"); |
1417 | cap->version = 1; | 1392 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | |
1418 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | | ||
1419 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; | 1393 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; |
1394 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
1420 | return 0; | 1395 | return 0; |
1421 | } | 1396 | } |
1422 | 1397 | ||
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h index e0e628cb98f9..aa0c6eac254a 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.h +++ b/drivers/media/platform/marvell-ccic/mcam-core.h | |||
@@ -176,6 +176,7 @@ struct mcam_camera { | |||
176 | /* DMA buffers - DMA modes */ | 176 | /* DMA buffers - DMA modes */ |
177 | struct mcam_vb_buffer *vb_bufs[MAX_DMA_BUFS]; | 177 | struct mcam_vb_buffer *vb_bufs[MAX_DMA_BUFS]; |
178 | struct vb2_alloc_ctx *vb_alloc_ctx; | 178 | struct vb2_alloc_ctx *vb_alloc_ctx; |
179 | struct vb2_alloc_ctx *vb_alloc_ctx_sg; | ||
179 | 180 | ||
180 | /* Mode-specific ops, set at open time */ | 181 | /* Mode-specific ops, set at open time */ |
181 | void (*dma_setup)(struct mcam_camera *cam); | 182 | void (*dma_setup)(struct mcam_camera *cam); |
@@ -183,7 +184,7 @@ struct mcam_camera { | |||
183 | 184 | ||
184 | /* Current operating parameters */ | 185 | /* Current operating parameters */ |
185 | struct v4l2_pix_format pix_format; | 186 | struct v4l2_pix_format pix_format; |
186 | enum v4l2_mbus_pixelcode mbus_code; | 187 | u32 mbus_code; |
187 | 188 | ||
188 | /* Locks */ | 189 | /* Locks */ |
189 | struct mutex s_mutex; /* Access to this structure */ | 190 | struct mutex s_mutex; /* Access to this structure */ |
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c index 4971ff21f82b..f923d1bc43a0 100644 --- a/drivers/media/platform/mx2_emmaprp.c +++ b/drivers/media/platform/mx2_emmaprp.c | |||
@@ -402,13 +402,8 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
402 | { | 402 | { |
403 | strncpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver) - 1); | 403 | strncpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver) - 1); |
404 | strncpy(cap->card, MEM2MEM_NAME, sizeof(cap->card) - 1); | 404 | strncpy(cap->card, MEM2MEM_NAME, sizeof(cap->card) - 1); |
405 | /* | 405 | cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING; |
406 | * This is only a mem-to-mem video device. The capture and output | 406 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
407 | * device capability flags are left only for backward compatibility | ||
408 | * and are scheduled for removal. | ||
409 | */ | ||
410 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT | | ||
411 | V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING; | ||
412 | return 0; | 407 | return 0; |
413 | } | 408 | } |
414 | 409 | ||
diff --git a/drivers/media/platform/omap/Kconfig b/drivers/media/platform/omap/Kconfig index 05de442d24e4..dc2aaab54aef 100644 --- a/drivers/media/platform/omap/Kconfig +++ b/drivers/media/platform/omap/Kconfig | |||
@@ -3,7 +3,8 @@ config VIDEO_OMAP2_VOUT_VRFB | |||
3 | 3 | ||
4 | config VIDEO_OMAP2_VOUT | 4 | config VIDEO_OMAP2_VOUT |
5 | tristate "OMAP2/OMAP3 V4L2-Display driver" | 5 | tristate "OMAP2/OMAP3 V4L2-Display driver" |
6 | depends on ARCH_OMAP2 || ARCH_OMAP3 || (COMPILE_TEST && HAS_MMU) | 6 | depends on MMU |
7 | depends on ARCH_OMAP2 || ARCH_OMAP3 | ||
7 | select VIDEOBUF_GEN | 8 | select VIDEOBUF_GEN |
8 | select VIDEOBUF_DMA_CONTIG | 9 | select VIDEOBUF_DMA_CONTIG |
9 | select OMAP2_DSS if HAS_IOMEM && ARCH_OMAP2PLUS | 10 | select OMAP2_DSS if HAS_IOMEM && ARCH_OMAP2PLUS |
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c index 64ab6fb06b9c..ba2d8f973d58 100644 --- a/drivers/media/platform/omap/omap_vout.c +++ b/drivers/media/platform/omap/omap_vout.c | |||
@@ -198,7 +198,7 @@ static int omap_vout_try_format(struct v4l2_pix_format *pix) | |||
198 | * omap_vout_uservirt_to_phys: This inline function is used to convert user | 198 | * omap_vout_uservirt_to_phys: This inline function is used to convert user |
199 | * space virtual address to physical address. | 199 | * space virtual address to physical address. |
200 | */ | 200 | */ |
201 | static u32 omap_vout_uservirt_to_phys(u32 virtp) | 201 | static unsigned long omap_vout_uservirt_to_phys(unsigned long virtp) |
202 | { | 202 | { |
203 | unsigned long physp = 0; | 203 | unsigned long physp = 0; |
204 | struct vm_area_struct *vma; | 204 | struct vm_area_struct *vma; |
@@ -418,10 +418,10 @@ static int omapvid_setup_overlay(struct omap_vout_device *vout, | |||
418 | } | 418 | } |
419 | 419 | ||
420 | v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, | 420 | v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, |
421 | "%s enable=%d addr=%x width=%d\n height=%d color_mode=%d\n" | 421 | "%s enable=%d addr=%pad width=%d\n height=%d color_mode=%d\n" |
422 | "rotation=%d mirror=%d posx=%d posy=%d out_width = %d \n" | 422 | "rotation=%d mirror=%d posx=%d posy=%d out_width = %d \n" |
423 | "out_height=%d rotation_type=%d screen_width=%d\n", | 423 | "out_height=%d rotation_type=%d screen_width=%d\n", |
424 | __func__, ovl->is_enabled(ovl), info.paddr, info.width, info.height, | 424 | __func__, ovl->is_enabled(ovl), &info.paddr, info.width, info.height, |
425 | info.color_mode, info.rotation, info.mirror, info.pos_x, | 425 | info.color_mode, info.rotation, info.mirror, info.pos_x, |
426 | info.pos_y, info.out_width, info.out_height, info.rotation_type, | 426 | info.pos_y, info.out_width, info.out_height, info.rotation_type, |
427 | info.screen_width); | 427 | info.screen_width); |
@@ -794,7 +794,7 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q, | |||
794 | vout->queued_buf_addr[vb->i] = (u8 *) | 794 | vout->queued_buf_addr[vb->i] = (u8 *) |
795 | omap_vout_uservirt_to_phys(vb->baddr); | 795 | omap_vout_uservirt_to_phys(vb->baddr); |
796 | } else { | 796 | } else { |
797 | u32 addr, dma_addr; | 797 | unsigned long addr, dma_addr; |
798 | unsigned long size; | 798 | unsigned long size; |
799 | 799 | ||
800 | addr = (unsigned long) vout->buf_virt_addr[vb->i]; | 800 | addr = (unsigned long) vout->buf_virt_addr[vb->i]; |
@@ -1054,8 +1054,9 @@ static int vidioc_querycap(struct file *file, void *fh, | |||
1054 | strlcpy(cap->driver, VOUT_NAME, sizeof(cap->driver)); | 1054 | strlcpy(cap->driver, VOUT_NAME, sizeof(cap->driver)); |
1055 | strlcpy(cap->card, vout->vfd->name, sizeof(cap->card)); | 1055 | strlcpy(cap->card, vout->vfd->name, sizeof(cap->card)); |
1056 | cap->bus_info[0] = '\0'; | 1056 | cap->bus_info[0] = '\0'; |
1057 | cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT | | 1057 | cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT | |
1058 | V4L2_CAP_VIDEO_OUTPUT_OVERLAY; | 1058 | V4L2_CAP_VIDEO_OUTPUT_OVERLAY; |
1059 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
1059 | 1060 | ||
1060 | return 0; | 1061 | return 0; |
1061 | } | 1062 | } |
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 81a9dc053d58..587489a072d5 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c | |||
@@ -36,23 +36,23 @@ __ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, | |||
36 | unsigned int pad, enum v4l2_subdev_format_whence which); | 36 | unsigned int pad, enum v4l2_subdev_format_whence which); |
37 | 37 | ||
38 | static const unsigned int ccdc_fmts[] = { | 38 | static const unsigned int ccdc_fmts[] = { |
39 | V4L2_MBUS_FMT_Y8_1X8, | 39 | MEDIA_BUS_FMT_Y8_1X8, |
40 | V4L2_MBUS_FMT_Y10_1X10, | 40 | MEDIA_BUS_FMT_Y10_1X10, |
41 | V4L2_MBUS_FMT_Y12_1X12, | 41 | MEDIA_BUS_FMT_Y12_1X12, |
42 | V4L2_MBUS_FMT_SGRBG8_1X8, | 42 | MEDIA_BUS_FMT_SGRBG8_1X8, |
43 | V4L2_MBUS_FMT_SRGGB8_1X8, | 43 | MEDIA_BUS_FMT_SRGGB8_1X8, |
44 | V4L2_MBUS_FMT_SBGGR8_1X8, | 44 | MEDIA_BUS_FMT_SBGGR8_1X8, |
45 | V4L2_MBUS_FMT_SGBRG8_1X8, | 45 | MEDIA_BUS_FMT_SGBRG8_1X8, |
46 | V4L2_MBUS_FMT_SGRBG10_1X10, | 46 | MEDIA_BUS_FMT_SGRBG10_1X10, |
47 | V4L2_MBUS_FMT_SRGGB10_1X10, | 47 | MEDIA_BUS_FMT_SRGGB10_1X10, |
48 | V4L2_MBUS_FMT_SBGGR10_1X10, | 48 | MEDIA_BUS_FMT_SBGGR10_1X10, |
49 | V4L2_MBUS_FMT_SGBRG10_1X10, | 49 | MEDIA_BUS_FMT_SGBRG10_1X10, |
50 | V4L2_MBUS_FMT_SGRBG12_1X12, | 50 | MEDIA_BUS_FMT_SGRBG12_1X12, |
51 | V4L2_MBUS_FMT_SRGGB12_1X12, | 51 | MEDIA_BUS_FMT_SRGGB12_1X12, |
52 | V4L2_MBUS_FMT_SBGGR12_1X12, | 52 | MEDIA_BUS_FMT_SBGGR12_1X12, |
53 | V4L2_MBUS_FMT_SGBRG12_1X12, | 53 | MEDIA_BUS_FMT_SGBRG12_1X12, |
54 | V4L2_MBUS_FMT_YUYV8_2X8, | 54 | MEDIA_BUS_FMT_YUYV8_2X8, |
55 | V4L2_MBUS_FMT_UYVY8_2X8, | 55 | MEDIA_BUS_FMT_UYVY8_2X8, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | /* | 58 | /* |
@@ -266,10 +266,10 @@ static int __ccdc_lsc_enable(struct isp_ccdc_device *ccdc, int enable) | |||
266 | __ccdc_get_format(ccdc, NULL, CCDC_PAD_SINK, | 266 | __ccdc_get_format(ccdc, NULL, CCDC_PAD_SINK, |
267 | V4L2_SUBDEV_FORMAT_ACTIVE); | 267 | V4L2_SUBDEV_FORMAT_ACTIVE); |
268 | 268 | ||
269 | if ((format->code != V4L2_MBUS_FMT_SGRBG10_1X10) && | 269 | if ((format->code != MEDIA_BUS_FMT_SGRBG10_1X10) && |
270 | (format->code != V4L2_MBUS_FMT_SRGGB10_1X10) && | 270 | (format->code != MEDIA_BUS_FMT_SRGGB10_1X10) && |
271 | (format->code != V4L2_MBUS_FMT_SBGGR10_1X10) && | 271 | (format->code != MEDIA_BUS_FMT_SBGGR10_1X10) && |
272 | (format->code != V4L2_MBUS_FMT_SGBRG10_1X10)) | 272 | (format->code != MEDIA_BUS_FMT_SGBRG10_1X10)) |
273 | return -EINVAL; | 273 | return -EINVAL; |
274 | 274 | ||
275 | if (enable) | 275 | if (enable) |
@@ -971,8 +971,8 @@ static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc, | |||
971 | 971 | ||
972 | format = &ccdc->formats[CCDC_PAD_SINK]; | 972 | format = &ccdc->formats[CCDC_PAD_SINK]; |
973 | 973 | ||
974 | if (format->code == V4L2_MBUS_FMT_YUYV8_2X8 || | 974 | if (format->code == MEDIA_BUS_FMT_YUYV8_2X8 || |
975 | format->code == V4L2_MBUS_FMT_UYVY8_2X8) { | 975 | format->code == MEDIA_BUS_FMT_UYVY8_2X8) { |
976 | /* According to the OMAP3 TRM the input mode only affects SYNC | 976 | /* According to the OMAP3 TRM the input mode only affects SYNC |
977 | * mode, enabling BT.656 mode should take precedence. However, | 977 | * mode, enabling BT.656 mode should take precedence. However, |
978 | * in practice setting the input mode to YCbCr data on 8 bits | 978 | * in practice setting the input mode to YCbCr data on 8 bits |
@@ -1020,7 +1020,7 @@ static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc, | |||
1020 | /* The CCDC_CFG.Y8POS bit is used in YCbCr8 input mode only. The | 1020 | /* The CCDC_CFG.Y8POS bit is used in YCbCr8 input mode only. The |
1021 | * hardware seems to ignore it in all other input modes. | 1021 | * hardware seems to ignore it in all other input modes. |
1022 | */ | 1022 | */ |
1023 | if (format->code == V4L2_MBUS_FMT_UYVY8_2X8) | 1023 | if (format->code == MEDIA_BUS_FMT_UYVY8_2X8) |
1024 | isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG, | 1024 | isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG, |
1025 | ISPCCDC_CFG_Y8POS); | 1025 | ISPCCDC_CFG_Y8POS); |
1026 | else | 1026 | else |
@@ -1168,9 +1168,9 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) | |||
1168 | 1168 | ||
1169 | if (ccdc->bt656) | 1169 | if (ccdc->bt656) |
1170 | bridge = ISPCTRL_PAR_BRIDGE_DISABLE; | 1170 | bridge = ISPCTRL_PAR_BRIDGE_DISABLE; |
1171 | else if (fmt_info->code == V4L2_MBUS_FMT_YUYV8_2X8) | 1171 | else if (fmt_info->code == MEDIA_BUS_FMT_YUYV8_2X8) |
1172 | bridge = ISPCTRL_PAR_BRIDGE_LENDIAN; | 1172 | bridge = ISPCTRL_PAR_BRIDGE_LENDIAN; |
1173 | else if (fmt_info->code == V4L2_MBUS_FMT_UYVY8_2X8) | 1173 | else if (fmt_info->code == MEDIA_BUS_FMT_UYVY8_2X8) |
1174 | bridge = ISPCTRL_PAR_BRIDGE_BENDIAN; | 1174 | bridge = ISPCTRL_PAR_BRIDGE_BENDIAN; |
1175 | else | 1175 | else |
1176 | bridge = ISPCTRL_PAR_BRIDGE_DISABLE; | 1176 | bridge = ISPCTRL_PAR_BRIDGE_DISABLE; |
@@ -1199,16 +1199,16 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) | |||
1199 | 1199 | ||
1200 | /* Mosaic filter */ | 1200 | /* Mosaic filter */ |
1201 | switch (format->code) { | 1201 | switch (format->code) { |
1202 | case V4L2_MBUS_FMT_SRGGB10_1X10: | 1202 | case MEDIA_BUS_FMT_SRGGB10_1X10: |
1203 | case V4L2_MBUS_FMT_SRGGB12_1X12: | 1203 | case MEDIA_BUS_FMT_SRGGB12_1X12: |
1204 | ccdc_pattern = ccdc_srggb_pattern; | 1204 | ccdc_pattern = ccdc_srggb_pattern; |
1205 | break; | 1205 | break; |
1206 | case V4L2_MBUS_FMT_SBGGR10_1X10: | 1206 | case MEDIA_BUS_FMT_SBGGR10_1X10: |
1207 | case V4L2_MBUS_FMT_SBGGR12_1X12: | 1207 | case MEDIA_BUS_FMT_SBGGR12_1X12: |
1208 | ccdc_pattern = ccdc_sbggr_pattern; | 1208 | ccdc_pattern = ccdc_sbggr_pattern; |
1209 | break; | 1209 | break; |
1210 | case V4L2_MBUS_FMT_SGBRG10_1X10: | 1210 | case MEDIA_BUS_FMT_SGBRG10_1X10: |
1211 | case V4L2_MBUS_FMT_SGBRG12_1X12: | 1211 | case MEDIA_BUS_FMT_SGBRG12_1X12: |
1212 | ccdc_pattern = ccdc_sgbrg_pattern; | 1212 | ccdc_pattern = ccdc_sgbrg_pattern; |
1213 | break; | 1213 | break; |
1214 | default: | 1214 | default: |
@@ -1267,7 +1267,7 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) | |||
1267 | /* The CCDC outputs data in UYVY order by default. Swap bytes to get | 1267 | /* The CCDC outputs data in UYVY order by default. Swap bytes to get |
1268 | * YUYV. | 1268 | * YUYV. |
1269 | */ | 1269 | */ |
1270 | if (format->code == V4L2_MBUS_FMT_YUYV8_1X16) | 1270 | if (format->code == MEDIA_BUS_FMT_YUYV8_1X16) |
1271 | isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG, | 1271 | isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG, |
1272 | ISPCCDC_CFG_BSWD); | 1272 | ISPCCDC_CFG_BSWD); |
1273 | else | 1273 | else |
@@ -1967,7 +1967,7 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, | |||
1967 | enum v4l2_subdev_format_whence which) | 1967 | enum v4l2_subdev_format_whence which) |
1968 | { | 1968 | { |
1969 | const struct isp_format_info *info; | 1969 | const struct isp_format_info *info; |
1970 | enum v4l2_mbus_pixelcode pixelcode; | 1970 | u32 pixelcode; |
1971 | unsigned int width = fmt->width; | 1971 | unsigned int width = fmt->width; |
1972 | unsigned int height = fmt->height; | 1972 | unsigned int height = fmt->height; |
1973 | struct v4l2_rect *crop; | 1973 | struct v4l2_rect *crop; |
@@ -1983,7 +1983,7 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, | |||
1983 | 1983 | ||
1984 | /* If not found, use SGRBG10 as default */ | 1984 | /* If not found, use SGRBG10 as default */ |
1985 | if (i >= ARRAY_SIZE(ccdc_fmts)) | 1985 | if (i >= ARRAY_SIZE(ccdc_fmts)) |
1986 | fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 1986 | fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
1987 | 1987 | ||
1988 | /* Clamp the input size. */ | 1988 | /* Clamp the input size. */ |
1989 | fmt->width = clamp_t(u32, width, 32, 4096); | 1989 | fmt->width = clamp_t(u32, width, 32, 4096); |
@@ -2007,19 +2007,19 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, | |||
2007 | * configured to pack bytes in BT.656, hiding the inaccuracy. | 2007 | * configured to pack bytes in BT.656, hiding the inaccuracy. |
2008 | * In all cases bytes can be swapped. | 2008 | * In all cases bytes can be swapped. |
2009 | */ | 2009 | */ |
2010 | if (fmt->code == V4L2_MBUS_FMT_YUYV8_2X8 || | 2010 | if (fmt->code == MEDIA_BUS_FMT_YUYV8_2X8 || |
2011 | fmt->code == V4L2_MBUS_FMT_UYVY8_2X8) { | 2011 | fmt->code == MEDIA_BUS_FMT_UYVY8_2X8) { |
2012 | /* Use the user requested format if YUV. */ | 2012 | /* Use the user requested format if YUV. */ |
2013 | if (pixelcode == V4L2_MBUS_FMT_YUYV8_2X8 || | 2013 | if (pixelcode == MEDIA_BUS_FMT_YUYV8_2X8 || |
2014 | pixelcode == V4L2_MBUS_FMT_UYVY8_2X8 || | 2014 | pixelcode == MEDIA_BUS_FMT_UYVY8_2X8 || |
2015 | pixelcode == V4L2_MBUS_FMT_YUYV8_1X16 || | 2015 | pixelcode == MEDIA_BUS_FMT_YUYV8_1X16 || |
2016 | pixelcode == V4L2_MBUS_FMT_UYVY8_1X16) | 2016 | pixelcode == MEDIA_BUS_FMT_UYVY8_1X16) |
2017 | fmt->code = pixelcode; | 2017 | fmt->code = pixelcode; |
2018 | 2018 | ||
2019 | if (fmt->code == V4L2_MBUS_FMT_YUYV8_2X8) | 2019 | if (fmt->code == MEDIA_BUS_FMT_YUYV8_2X8) |
2020 | fmt->code = V4L2_MBUS_FMT_YUYV8_1X16; | 2020 | fmt->code = MEDIA_BUS_FMT_YUYV8_1X16; |
2021 | else if (fmt->code == V4L2_MBUS_FMT_UYVY8_2X8) | 2021 | else if (fmt->code == MEDIA_BUS_FMT_UYVY8_2X8) |
2022 | fmt->code = V4L2_MBUS_FMT_UYVY8_1X16; | 2022 | fmt->code = MEDIA_BUS_FMT_UYVY8_1X16; |
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | /* Hardcode the output size to the crop rectangle size. */ | 2025 | /* Hardcode the output size to the crop rectangle size. */ |
@@ -2047,8 +2047,8 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, | |||
2047 | fmt->code = info->truncated; | 2047 | fmt->code = info->truncated; |
2048 | 2048 | ||
2049 | /* YUV formats are not supported by the video port. */ | 2049 | /* YUV formats are not supported by the video port. */ |
2050 | if (fmt->code == V4L2_MBUS_FMT_YUYV8_2X8 || | 2050 | if (fmt->code == MEDIA_BUS_FMT_YUYV8_2X8 || |
2051 | fmt->code == V4L2_MBUS_FMT_UYVY8_2X8) | 2051 | fmt->code == MEDIA_BUS_FMT_UYVY8_2X8) |
2052 | fmt->code = 0; | 2052 | fmt->code = 0; |
2053 | 2053 | ||
2054 | /* The number of lines that can be clocked out from the video | 2054 | /* The number of lines that can be clocked out from the video |
@@ -2083,7 +2083,7 @@ static void ccdc_try_crop(struct isp_ccdc_device *ccdc, | |||
2083 | * to keep the Bayer pattern. | 2083 | * to keep the Bayer pattern. |
2084 | */ | 2084 | */ |
2085 | info = omap3isp_video_format_info(sink->code); | 2085 | info = omap3isp_video_format_info(sink->code); |
2086 | if (info->flavor != V4L2_MBUS_FMT_Y8_1X8) { | 2086 | if (info->flavor != MEDIA_BUS_FMT_Y8_1X8) { |
2087 | crop->left &= ~1; | 2087 | crop->left &= ~1; |
2088 | crop->top &= ~1; | 2088 | crop->top &= ~1; |
2089 | } | 2089 | } |
@@ -2103,7 +2103,7 @@ static void ccdc_try_crop(struct isp_ccdc_device *ccdc, | |||
2103 | sink->height - crop->top); | 2103 | sink->height - crop->top); |
2104 | 2104 | ||
2105 | /* Odd width/height values don't make sense for Bayer formats. */ | 2105 | /* Odd width/height values don't make sense for Bayer formats. */ |
2106 | if (info->flavor != V4L2_MBUS_FMT_Y8_1X8) { | 2106 | if (info->flavor != MEDIA_BUS_FMT_Y8_1X8) { |
2107 | crop->width &= ~1; | 2107 | crop->width &= ~1; |
2108 | crop->height &= ~1; | 2108 | crop->height &= ~1; |
2109 | } | 2109 | } |
@@ -2135,13 +2135,13 @@ static int ccdc_enum_mbus_code(struct v4l2_subdev *sd, | |||
2135 | format = __ccdc_get_format(ccdc, fh, code->pad, | 2135 | format = __ccdc_get_format(ccdc, fh, code->pad, |
2136 | V4L2_SUBDEV_FORMAT_TRY); | 2136 | V4L2_SUBDEV_FORMAT_TRY); |
2137 | 2137 | ||
2138 | if (format->code == V4L2_MBUS_FMT_YUYV8_2X8 || | 2138 | if (format->code == MEDIA_BUS_FMT_YUYV8_2X8 || |
2139 | format->code == V4L2_MBUS_FMT_UYVY8_2X8) { | 2139 | format->code == MEDIA_BUS_FMT_UYVY8_2X8) { |
2140 | /* In YUV mode the CCDC can swap bytes. */ | 2140 | /* In YUV mode the CCDC can swap bytes. */ |
2141 | if (code->index == 0) | 2141 | if (code->index == 0) |
2142 | code->code = V4L2_MBUS_FMT_YUYV8_1X16; | 2142 | code->code = MEDIA_BUS_FMT_YUYV8_1X16; |
2143 | else if (code->index == 1) | 2143 | else if (code->index == 1) |
2144 | code->code = V4L2_MBUS_FMT_UYVY8_1X16; | 2144 | code->code = MEDIA_BUS_FMT_UYVY8_1X16; |
2145 | else | 2145 | else |
2146 | return -EINVAL; | 2146 | return -EINVAL; |
2147 | } else { | 2147 | } else { |
@@ -2383,9 +2383,7 @@ static int ccdc_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
2383 | * return true if the combination is possible | 2383 | * return true if the combination is possible |
2384 | * return false otherwise | 2384 | * return false otherwise |
2385 | */ | 2385 | */ |
2386 | static bool ccdc_is_shiftable(enum v4l2_mbus_pixelcode in, | 2386 | static bool ccdc_is_shiftable(u32 in, u32 out, unsigned int additional_shift) |
2387 | enum v4l2_mbus_pixelcode out, | ||
2388 | unsigned int additional_shift) | ||
2389 | { | 2387 | { |
2390 | const struct isp_format_info *in_info, *out_info; | 2388 | const struct isp_format_info *in_info, *out_info; |
2391 | 2389 | ||
@@ -2452,7 +2450,7 @@ static int ccdc_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) | |||
2452 | memset(&format, 0, sizeof(format)); | 2450 | memset(&format, 0, sizeof(format)); |
2453 | format.pad = CCDC_PAD_SINK; | 2451 | format.pad = CCDC_PAD_SINK; |
2454 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; | 2452 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; |
2455 | format.format.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 2453 | format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
2456 | format.format.width = 4096; | 2454 | format.format.width = 4096; |
2457 | format.format.height = 4096; | 2455 | format.format.height = 4096; |
2458 | ccdc_set_format(sd, fh, &format); | 2456 | ccdc_set_format(sd, fh, &format); |
diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 9cb49b3c04bd..f4aedb37e41e 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c | |||
@@ -289,10 +289,10 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2, | |||
289 | u32 val, format; | 289 | u32 val, format; |
290 | 290 | ||
291 | switch (config->format) { | 291 | switch (config->format) { |
292 | case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8: | 292 | case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8: |
293 | format = ISPCCP2_LCx_CTRL_FORMAT_RAW8_DPCM10_VP; | 293 | format = ISPCCP2_LCx_CTRL_FORMAT_RAW8_DPCM10_VP; |
294 | break; | 294 | break; |
295 | case V4L2_MBUS_FMT_SGRBG10_1X10: | 295 | case MEDIA_BUS_FMT_SGRBG10_1X10: |
296 | default: | 296 | default: |
297 | format = ISPCCP2_LCx_CTRL_FORMAT_RAW10_VP; /* RAW10+VP */ | 297 | format = ISPCCP2_LCx_CTRL_FORMAT_RAW10_VP; /* RAW10+VP */ |
298 | break; | 298 | break; |
@@ -438,7 +438,7 @@ static void ccp2_mem_configure(struct isp_ccp2_device *ccp2, | |||
438 | u32 val, hwords; | 438 | u32 val, hwords; |
439 | 439 | ||
440 | if (sink_pixcode != source_pixcode && | 440 | if (sink_pixcode != source_pixcode && |
441 | sink_pixcode == V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8) | 441 | sink_pixcode == MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8) |
442 | dpcm_decompress = 1; | 442 | dpcm_decompress = 1; |
443 | 443 | ||
444 | ccp2_pwr_cfg(ccp2); | 444 | ccp2_pwr_cfg(ccp2); |
@@ -604,8 +604,8 @@ void omap3isp_ccp2_isr(struct isp_ccp2_device *ccp2) | |||
604 | */ | 604 | */ |
605 | 605 | ||
606 | static const unsigned int ccp2_fmts[] = { | 606 | static const unsigned int ccp2_fmts[] = { |
607 | V4L2_MBUS_FMT_SGRBG10_1X10, | 607 | MEDIA_BUS_FMT_SGRBG10_1X10, |
608 | V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, | 608 | MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, |
609 | }; | 609 | }; |
610 | 610 | ||
611 | /* | 611 | /* |
@@ -643,8 +643,8 @@ static void ccp2_try_format(struct isp_ccp2_device *ccp2, | |||
643 | 643 | ||
644 | switch (pad) { | 644 | switch (pad) { |
645 | case CCP2_PAD_SINK: | 645 | case CCP2_PAD_SINK: |
646 | if (fmt->code != V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8) | 646 | if (fmt->code != MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8) |
647 | fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 647 | fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
648 | 648 | ||
649 | if (ccp2->input == CCP2_INPUT_SENSOR) { | 649 | if (ccp2->input == CCP2_INPUT_SENSOR) { |
650 | fmt->width = clamp_t(u32, fmt->width, | 650 | fmt->width = clamp_t(u32, fmt->width, |
@@ -671,7 +671,7 @@ static void ccp2_try_format(struct isp_ccp2_device *ccp2, | |||
671 | */ | 671 | */ |
672 | format = __ccp2_get_format(ccp2, fh, CCP2_PAD_SINK, which); | 672 | format = __ccp2_get_format(ccp2, fh, CCP2_PAD_SINK, which); |
673 | memcpy(fmt, format, sizeof(*fmt)); | 673 | memcpy(fmt, format, sizeof(*fmt)); |
674 | fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 674 | fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
675 | break; | 675 | break; |
676 | } | 676 | } |
677 | 677 | ||
@@ -808,7 +808,7 @@ static int ccp2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) | |||
808 | memset(&format, 0, sizeof(format)); | 808 | memset(&format, 0, sizeof(format)); |
809 | format.pad = CCP2_PAD_SINK; | 809 | format.pad = CCP2_PAD_SINK; |
810 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; | 810 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; |
811 | format.format.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 811 | format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
812 | format.format.width = 4096; | 812 | format.format.width = 4096; |
813 | format.format.height = 4096; | 813 | format.format.height = 4096; |
814 | ccp2_set_format(sd, fh, &format); | 814 | ccp2_set_format(sd, fh, &format); |
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index 6530b255f103..09c686d96ae8 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c | |||
@@ -78,15 +78,15 @@ static void csi2_recv_config(struct isp_device *isp, | |||
78 | } | 78 | } |
79 | 79 | ||
80 | static const unsigned int csi2_input_fmts[] = { | 80 | static const unsigned int csi2_input_fmts[] = { |
81 | V4L2_MBUS_FMT_SGRBG10_1X10, | 81 | MEDIA_BUS_FMT_SGRBG10_1X10, |
82 | V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, | 82 | MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, |
83 | V4L2_MBUS_FMT_SRGGB10_1X10, | 83 | MEDIA_BUS_FMT_SRGGB10_1X10, |
84 | V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, | 84 | MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, |
85 | V4L2_MBUS_FMT_SBGGR10_1X10, | 85 | MEDIA_BUS_FMT_SBGGR10_1X10, |
86 | V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, | 86 | MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, |
87 | V4L2_MBUS_FMT_SGBRG10_1X10, | 87 | MEDIA_BUS_FMT_SGBRG10_1X10, |
88 | V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, | 88 | MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, |
89 | V4L2_MBUS_FMT_YUYV8_2X8, | 89 | MEDIA_BUS_FMT_YUYV8_2X8, |
90 | }; | 90 | }; |
91 | 91 | ||
92 | /* To set the format on the CSI2 requires a mapping function that takes | 92 | /* To set the format on the CSI2 requires a mapping function that takes |
@@ -171,19 +171,19 @@ static u16 csi2_ctx_map_format(struct isp_csi2_device *csi2) | |||
171 | int fmtidx, destidx, is_3630; | 171 | int fmtidx, destidx, is_3630; |
172 | 172 | ||
173 | switch (fmt->code) { | 173 | switch (fmt->code) { |
174 | case V4L2_MBUS_FMT_SGRBG10_1X10: | 174 | case MEDIA_BUS_FMT_SGRBG10_1X10: |
175 | case V4L2_MBUS_FMT_SRGGB10_1X10: | 175 | case MEDIA_BUS_FMT_SRGGB10_1X10: |
176 | case V4L2_MBUS_FMT_SBGGR10_1X10: | 176 | case MEDIA_BUS_FMT_SBGGR10_1X10: |
177 | case V4L2_MBUS_FMT_SGBRG10_1X10: | 177 | case MEDIA_BUS_FMT_SGBRG10_1X10: |
178 | fmtidx = 0; | 178 | fmtidx = 0; |
179 | break; | 179 | break; |
180 | case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8: | 180 | case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8: |
181 | case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8: | 181 | case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8: |
182 | case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8: | 182 | case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8: |
183 | case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8: | 183 | case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8: |
184 | fmtidx = 1; | 184 | fmtidx = 1; |
185 | break; | 185 | break; |
186 | case V4L2_MBUS_FMT_YUYV8_2X8: | 186 | case MEDIA_BUS_FMT_YUYV8_2X8: |
187 | fmtidx = 2; | 187 | fmtidx = 2; |
188 | break; | 188 | break; |
189 | default: | 189 | default: |
@@ -843,7 +843,7 @@ csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh, | |||
843 | unsigned int pad, struct v4l2_mbus_framefmt *fmt, | 843 | unsigned int pad, struct v4l2_mbus_framefmt *fmt, |
844 | enum v4l2_subdev_format_whence which) | 844 | enum v4l2_subdev_format_whence which) |
845 | { | 845 | { |
846 | enum v4l2_mbus_pixelcode pixelcode; | 846 | u32 pixelcode; |
847 | struct v4l2_mbus_framefmt *format; | 847 | struct v4l2_mbus_framefmt *format; |
848 | const struct isp_format_info *info; | 848 | const struct isp_format_info *info; |
849 | unsigned int i; | 849 | unsigned int i; |
@@ -858,7 +858,7 @@ csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh, | |||
858 | 858 | ||
859 | /* If not found, use SGRBG10 as default */ | 859 | /* If not found, use SGRBG10 as default */ |
860 | if (i >= ARRAY_SIZE(csi2_input_fmts)) | 860 | if (i >= ARRAY_SIZE(csi2_input_fmts)) |
861 | fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 861 | fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
862 | 862 | ||
863 | fmt->width = clamp_t(u32, fmt->width, 1, 8191); | 863 | fmt->width = clamp_t(u32, fmt->width, 1, 8191); |
864 | fmt->height = clamp_t(u32, fmt->height, 1, 8191); | 864 | fmt->height = clamp_t(u32, fmt->height, 1, 8191); |
@@ -1029,7 +1029,7 @@ static int csi2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) | |||
1029 | memset(&format, 0, sizeof(format)); | 1029 | memset(&format, 0, sizeof(format)); |
1030 | format.pad = CSI2_PAD_SINK; | 1030 | format.pad = CSI2_PAD_SINK; |
1031 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; | 1031 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; |
1032 | format.format.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 1032 | format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
1033 | format.format.width = 4096; | 1033 | format.format.width = 4096; |
1034 | format.format.height = 4096; | 1034 | format.format.height = 4096; |
1035 | csi2_set_format(sd, fh, &format); | 1035 | csi2_set_format(sd, fh, &format); |
diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index 605f57ef0a49..dd9eed45d853 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c | |||
@@ -964,18 +964,16 @@ static void preview_setup_hw(struct isp_prev_device *prev, u32 update, | |||
964 | * @prev: pointer to previewer private structure | 964 | * @prev: pointer to previewer private structure |
965 | * @pixelcode: pixel code | 965 | * @pixelcode: pixel code |
966 | */ | 966 | */ |
967 | static void | 967 | static void preview_config_ycpos(struct isp_prev_device *prev, u32 pixelcode) |
968 | preview_config_ycpos(struct isp_prev_device *prev, | ||
969 | enum v4l2_mbus_pixelcode pixelcode) | ||
970 | { | 968 | { |
971 | struct isp_device *isp = to_isp_device(prev); | 969 | struct isp_device *isp = to_isp_device(prev); |
972 | enum preview_ycpos_mode mode; | 970 | enum preview_ycpos_mode mode; |
973 | 971 | ||
974 | switch (pixelcode) { | 972 | switch (pixelcode) { |
975 | case V4L2_MBUS_FMT_YUYV8_1X16: | 973 | case MEDIA_BUS_FMT_YUYV8_1X16: |
976 | mode = YCPOS_CrYCbY; | 974 | mode = YCPOS_CrYCbY; |
977 | break; | 975 | break; |
978 | case V4L2_MBUS_FMT_UYVY8_1X16: | 976 | case MEDIA_BUS_FMT_UYVY8_1X16: |
979 | mode = YCPOS_YCrYCb; | 977 | mode = YCPOS_YCrYCb; |
980 | break; | 978 | break; |
981 | default: | 979 | default: |
@@ -1028,16 +1026,16 @@ static void preview_config_input_format(struct isp_prev_device *prev, | |||
1028 | ISPPRV_PCR_WIDTH); | 1026 | ISPPRV_PCR_WIDTH); |
1029 | 1027 | ||
1030 | switch (info->flavor) { | 1028 | switch (info->flavor) { |
1031 | case V4L2_MBUS_FMT_SGRBG8_1X8: | 1029 | case MEDIA_BUS_FMT_SGRBG8_1X8: |
1032 | prev->params.cfa_order = 0; | 1030 | prev->params.cfa_order = 0; |
1033 | break; | 1031 | break; |
1034 | case V4L2_MBUS_FMT_SRGGB8_1X8: | 1032 | case MEDIA_BUS_FMT_SRGGB8_1X8: |
1035 | prev->params.cfa_order = 1; | 1033 | prev->params.cfa_order = 1; |
1036 | break; | 1034 | break; |
1037 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 1035 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
1038 | prev->params.cfa_order = 2; | 1036 | prev->params.cfa_order = 2; |
1039 | break; | 1037 | break; |
1040 | case V4L2_MBUS_FMT_SGBRG8_1X8: | 1038 | case MEDIA_BUS_FMT_SGBRG8_1X8: |
1041 | prev->params.cfa_order = 3; | 1039 | prev->params.cfa_order = 3; |
1042 | break; | 1040 | break; |
1043 | default: | 1041 | default: |
@@ -1078,8 +1076,8 @@ static void preview_config_input_size(struct isp_prev_device *prev, u32 active) | |||
1078 | unsigned int elv = prev->crop.top + prev->crop.height - 1; | 1076 | unsigned int elv = prev->crop.top + prev->crop.height - 1; |
1079 | u32 features; | 1077 | u32 features; |
1080 | 1078 | ||
1081 | if (format->code != V4L2_MBUS_FMT_Y8_1X8 && | 1079 | if (format->code != MEDIA_BUS_FMT_Y8_1X8 && |
1082 | format->code != V4L2_MBUS_FMT_Y10_1X10) { | 1080 | format->code != MEDIA_BUS_FMT_Y10_1X10) { |
1083 | sph -= 2; | 1081 | sph -= 2; |
1084 | eph += 2; | 1082 | eph += 2; |
1085 | slv -= 2; | 1083 | slv -= 2; |
@@ -1709,21 +1707,21 @@ __preview_get_crop(struct isp_prev_device *prev, struct v4l2_subdev_fh *fh, | |||
1709 | 1707 | ||
1710 | /* previewer format descriptions */ | 1708 | /* previewer format descriptions */ |
1711 | static const unsigned int preview_input_fmts[] = { | 1709 | static const unsigned int preview_input_fmts[] = { |
1712 | V4L2_MBUS_FMT_Y8_1X8, | 1710 | MEDIA_BUS_FMT_Y8_1X8, |
1713 | V4L2_MBUS_FMT_SGRBG8_1X8, | 1711 | MEDIA_BUS_FMT_SGRBG8_1X8, |
1714 | V4L2_MBUS_FMT_SRGGB8_1X8, | 1712 | MEDIA_BUS_FMT_SRGGB8_1X8, |
1715 | V4L2_MBUS_FMT_SBGGR8_1X8, | 1713 | MEDIA_BUS_FMT_SBGGR8_1X8, |
1716 | V4L2_MBUS_FMT_SGBRG8_1X8, | 1714 | MEDIA_BUS_FMT_SGBRG8_1X8, |
1717 | V4L2_MBUS_FMT_Y10_1X10, | 1715 | MEDIA_BUS_FMT_Y10_1X10, |
1718 | V4L2_MBUS_FMT_SGRBG10_1X10, | 1716 | MEDIA_BUS_FMT_SGRBG10_1X10, |
1719 | V4L2_MBUS_FMT_SRGGB10_1X10, | 1717 | MEDIA_BUS_FMT_SRGGB10_1X10, |
1720 | V4L2_MBUS_FMT_SBGGR10_1X10, | 1718 | MEDIA_BUS_FMT_SBGGR10_1X10, |
1721 | V4L2_MBUS_FMT_SGBRG10_1X10, | 1719 | MEDIA_BUS_FMT_SGBRG10_1X10, |
1722 | }; | 1720 | }; |
1723 | 1721 | ||
1724 | static const unsigned int preview_output_fmts[] = { | 1722 | static const unsigned int preview_output_fmts[] = { |
1725 | V4L2_MBUS_FMT_UYVY8_1X16, | 1723 | MEDIA_BUS_FMT_UYVY8_1X16, |
1726 | V4L2_MBUS_FMT_YUYV8_1X16, | 1724 | MEDIA_BUS_FMT_YUYV8_1X16, |
1727 | }; | 1725 | }; |
1728 | 1726 | ||
1729 | /* | 1727 | /* |
@@ -1742,7 +1740,7 @@ static void preview_try_format(struct isp_prev_device *prev, | |||
1742 | struct v4l2_mbus_framefmt *fmt, | 1740 | struct v4l2_mbus_framefmt *fmt, |
1743 | enum v4l2_subdev_format_whence which) | 1741 | enum v4l2_subdev_format_whence which) |
1744 | { | 1742 | { |
1745 | enum v4l2_mbus_pixelcode pixelcode; | 1743 | u32 pixelcode; |
1746 | struct v4l2_rect *crop; | 1744 | struct v4l2_rect *crop; |
1747 | unsigned int i; | 1745 | unsigned int i; |
1748 | 1746 | ||
@@ -1774,7 +1772,7 @@ static void preview_try_format(struct isp_prev_device *prev, | |||
1774 | 1772 | ||
1775 | /* If not found, use SGRBG10 as default */ | 1773 | /* If not found, use SGRBG10 as default */ |
1776 | if (i >= ARRAY_SIZE(preview_input_fmts)) | 1774 | if (i >= ARRAY_SIZE(preview_input_fmts)) |
1777 | fmt->code = V4L2_MBUS_FMT_SGRBG10_1X10; | 1775 | fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; |
1778 | break; | 1776 | break; |
1779 | 1777 | ||
1780 | case PREV_PAD_SOURCE: | 1778 | case PREV_PAD_SOURCE: |
@@ -1782,13 +1780,13 @@ static void preview_try_format(struct isp_prev_device *prev, | |||
1782 | *fmt = *__preview_get_format(prev, fh, PREV_PAD_SINK, which); | 1780 | *fmt = *__preview_get_format(prev, fh, PREV_PAD_SINK, which); |
1783 | 1781 | ||
1784 | switch (pixelcode) { | 1782 | switch (pixelcode) { |
1785 | case V4L2_MBUS_FMT_YUYV8_1X16: | 1783 | case MEDIA_BUS_FMT_YUYV8_1X16: |
1786 | case V4L2_MBUS_FMT_UYVY8_1X16: | 1784 | case MEDIA_BUS_FMT_UYVY8_1X16: |
1787 | fmt->code = pixelcode; | 1785 | fmt->code = pixelcode; |
1788 | break; | 1786 | break; |
1789 | 1787 | ||
1790 | default: | 1788 | default: |
1791 | fmt->code = V4L2_MBUS_FMT_YUYV8_1X16; | 1789 | fmt->code = MEDIA_BUS_FMT_YUYV8_1X16; |
1792 | break; | 1790 | break; |
1793 | } | 1791 | } |
1794 | 1792 | ||
@@ -1843,8 +1841,8 @@ static void preview_try_crop(struct isp_prev_device *prev, | |||
1843 | * and no columns in other modes. Increase the margins based on the sink | 1841 | * and no columns in other modes. Increase the margins based on the sink |
1844 | * format. | 1842 | * format. |
1845 | */ | 1843 | */ |
1846 | if (sink->code != V4L2_MBUS_FMT_Y8_1X8 && | 1844 | if (sink->code != MEDIA_BUS_FMT_Y8_1X8 && |
1847 | sink->code != V4L2_MBUS_FMT_Y10_1X10) { | 1845 | sink->code != MEDIA_BUS_FMT_Y10_1X10) { |
1848 | left += 2; | 1846 | left += 2; |
1849 | right -= 2; | 1847 | right -= 2; |
1850 | top += 2; | 1848 | top += 2; |
@@ -2092,7 +2090,7 @@ static int preview_init_formats(struct v4l2_subdev *sd, | |||
2092 | memset(&format, 0, sizeof(format)); | 2090 | memset(&format, 0, sizeof(format)); |
2093 | format.pad = PREV_PAD_SINK; | 2091 | format.pad = PREV_PAD_SINK; |
2094 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; | 2092 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; |
2095 | format.format.code = V4L2_MBUS_FMT_SGRBG10_1X10; | 2093 | format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; |
2096 | format.format.width = 4096; | 2094 | format.format.width = 4096; |
2097 | format.format.height = 4096; | 2095 | format.format.height = 4096; |
2098 | preview_set_format(sd, fh, &format); | 2096 | preview_set_format(sd, fh, &format); |
diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index 05d1ace57451..2b9bc4839876 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c | |||
@@ -198,17 +198,16 @@ static void resizer_set_bilinear(struct isp_res_device *res, | |||
198 | * @res: Device context. | 198 | * @res: Device context. |
199 | * @pixelcode: pixel code. | 199 | * @pixelcode: pixel code. |
200 | */ | 200 | */ |
201 | static void resizer_set_ycpos(struct isp_res_device *res, | 201 | static void resizer_set_ycpos(struct isp_res_device *res, u32 pixelcode) |
202 | enum v4l2_mbus_pixelcode pixelcode) | ||
203 | { | 202 | { |
204 | struct isp_device *isp = to_isp_device(res); | 203 | struct isp_device *isp = to_isp_device(res); |
205 | 204 | ||
206 | switch (pixelcode) { | 205 | switch (pixelcode) { |
207 | case V4L2_MBUS_FMT_YUYV8_1X16: | 206 | case MEDIA_BUS_FMT_YUYV8_1X16: |
208 | isp_reg_set(isp, OMAP3_ISP_IOMEM_RESZ, ISPRSZ_CNT, | 207 | isp_reg_set(isp, OMAP3_ISP_IOMEM_RESZ, ISPRSZ_CNT, |
209 | ISPRSZ_CNT_YCPOS); | 208 | ISPRSZ_CNT_YCPOS); |
210 | break; | 209 | break; |
211 | case V4L2_MBUS_FMT_UYVY8_1X16: | 210 | case MEDIA_BUS_FMT_UYVY8_1X16: |
212 | isp_reg_clr(isp, OMAP3_ISP_IOMEM_RESZ, ISPRSZ_CNT, | 211 | isp_reg_clr(isp, OMAP3_ISP_IOMEM_RESZ, ISPRSZ_CNT, |
213 | ISPRSZ_CNT_YCPOS); | 212 | ISPRSZ_CNT_YCPOS); |
214 | break; | 213 | break; |
@@ -1348,8 +1347,8 @@ static int resizer_set_selection(struct v4l2_subdev *sd, | |||
1348 | 1347 | ||
1349 | /* resizer pixel formats */ | 1348 | /* resizer pixel formats */ |
1350 | static const unsigned int resizer_formats[] = { | 1349 | static const unsigned int resizer_formats[] = { |
1351 | V4L2_MBUS_FMT_UYVY8_1X16, | 1350 | MEDIA_BUS_FMT_UYVY8_1X16, |
1352 | V4L2_MBUS_FMT_YUYV8_1X16, | 1351 | MEDIA_BUS_FMT_YUYV8_1X16, |
1353 | }; | 1352 | }; |
1354 | 1353 | ||
1355 | static unsigned int resizer_max_in_width(struct isp_res_device *res) | 1354 | static unsigned int resizer_max_in_width(struct isp_res_device *res) |
@@ -1385,9 +1384,9 @@ static void resizer_try_format(struct isp_res_device *res, | |||
1385 | 1384 | ||
1386 | switch (pad) { | 1385 | switch (pad) { |
1387 | case RESZ_PAD_SINK: | 1386 | case RESZ_PAD_SINK: |
1388 | if (fmt->code != V4L2_MBUS_FMT_YUYV8_1X16 && | 1387 | if (fmt->code != MEDIA_BUS_FMT_YUYV8_1X16 && |
1389 | fmt->code != V4L2_MBUS_FMT_UYVY8_1X16) | 1388 | fmt->code != MEDIA_BUS_FMT_UYVY8_1X16) |
1390 | fmt->code = V4L2_MBUS_FMT_YUYV8_1X16; | 1389 | fmt->code = MEDIA_BUS_FMT_YUYV8_1X16; |
1391 | 1390 | ||
1392 | fmt->width = clamp_t(u32, fmt->width, MIN_IN_WIDTH, | 1391 | fmt->width = clamp_t(u32, fmt->width, MIN_IN_WIDTH, |
1393 | resizer_max_in_width(res)); | 1392 | resizer_max_in_width(res)); |
@@ -1571,7 +1570,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, | |||
1571 | memset(&format, 0, sizeof(format)); | 1570 | memset(&format, 0, sizeof(format)); |
1572 | format.pad = RESZ_PAD_SINK; | 1571 | format.pad = RESZ_PAD_SINK; |
1573 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; | 1572 | format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; |
1574 | format.format.code = V4L2_MBUS_FMT_YUYV8_1X16; | 1573 | format.format.code = MEDIA_BUS_FMT_YUYV8_1X16; |
1575 | format.format.width = 4096; | 1574 | format.format.width = 4096; |
1576 | format.format.height = 4096; | 1575 | format.format.height = 4096; |
1577 | resizer_set_format(sd, fh, &format); | 1576 | resizer_set_format(sd, fh, &format); |
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index bc38c88c7bd9..b463fe172d16 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c | |||
@@ -39,74 +39,74 @@ | |||
39 | * corresponding in-memory formats to the table below!!! | 39 | * corresponding in-memory formats to the table below!!! |
40 | */ | 40 | */ |
41 | static struct isp_format_info formats[] = { | 41 | static struct isp_format_info formats[] = { |
42 | { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, | 42 | { MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8, |
43 | V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, | 43 | MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8, |
44 | V4L2_PIX_FMT_GREY, 8, 1, }, | 44 | V4L2_PIX_FMT_GREY, 8, 1, }, |
45 | { V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y10_1X10, | 45 | { MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y10_1X10, |
46 | V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y8_1X8, | 46 | MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y8_1X8, |
47 | V4L2_PIX_FMT_Y10, 10, 2, }, | 47 | V4L2_PIX_FMT_Y10, 10, 2, }, |
48 | { V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y10_1X10, | 48 | { MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y10_1X10, |
49 | V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y8_1X8, | 49 | MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y8_1X8, |
50 | V4L2_PIX_FMT_Y12, 12, 2, }, | 50 | V4L2_PIX_FMT_Y12, 12, 2, }, |
51 | { V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8, | 51 | { MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8, |
52 | V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8, | 52 | MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8, |
53 | V4L2_PIX_FMT_SBGGR8, 8, 1, }, | 53 | V4L2_PIX_FMT_SBGGR8, 8, 1, }, |
54 | { V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8, | 54 | { MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8, |
55 | V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8, | 55 | MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8, |
56 | V4L2_PIX_FMT_SGBRG8, 8, 1, }, | 56 | V4L2_PIX_FMT_SGBRG8, 8, 1, }, |
57 | { V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8, | 57 | { MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8, |
58 | V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8, | 58 | MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8, |
59 | V4L2_PIX_FMT_SGRBG8, 8, 1, }, | 59 | V4L2_PIX_FMT_SGRBG8, 8, 1, }, |
60 | { V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8, | 60 | { MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8, |
61 | V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8, | 61 | MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8, |
62 | V4L2_PIX_FMT_SRGGB8, 8, 1, }, | 62 | V4L2_PIX_FMT_SRGGB8, 8, 1, }, |
63 | { V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, | 63 | { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, |
64 | V4L2_MBUS_FMT_SBGGR10_1X10, 0, | 64 | MEDIA_BUS_FMT_SBGGR10_1X10, 0, |
65 | V4L2_PIX_FMT_SBGGR10DPCM8, 8, 1, }, | 65 | V4L2_PIX_FMT_SBGGR10DPCM8, 8, 1, }, |
66 | { V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, | 66 | { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, |
67 | V4L2_MBUS_FMT_SGBRG10_1X10, 0, | 67 | MEDIA_BUS_FMT_SGBRG10_1X10, 0, |
68 | V4L2_PIX_FMT_SGBRG10DPCM8, 8, 1, }, | 68 | V4L2_PIX_FMT_SGBRG10DPCM8, 8, 1, }, |
69 | { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, | 69 | { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, |
70 | V4L2_MBUS_FMT_SGRBG10_1X10, 0, | 70 | MEDIA_BUS_FMT_SGRBG10_1X10, 0, |
71 | V4L2_PIX_FMT_SGRBG10DPCM8, 8, 1, }, | 71 | V4L2_PIX_FMT_SGRBG10DPCM8, 8, 1, }, |
72 | { V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, | 72 | { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, |
73 | V4L2_MBUS_FMT_SRGGB10_1X10, 0, | 73 | MEDIA_BUS_FMT_SRGGB10_1X10, 0, |
74 | V4L2_PIX_FMT_SRGGB10DPCM8, 8, 1, }, | 74 | V4L2_PIX_FMT_SRGGB10DPCM8, 8, 1, }, |
75 | { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10, | 75 | { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10, |
76 | V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR8_1X8, | 76 | MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR8_1X8, |
77 | V4L2_PIX_FMT_SBGGR10, 10, 2, }, | 77 | V4L2_PIX_FMT_SBGGR10, 10, 2, }, |
78 | { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10, | 78 | { MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10, |
79 | V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG8_1X8, | 79 | MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG8_1X8, |
80 | V4L2_PIX_FMT_SGBRG10, 10, 2, }, | 80 | V4L2_PIX_FMT_SGBRG10, 10, 2, }, |
81 | { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10, | 81 | { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG10_1X10, |
82 | V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG8_1X8, | 82 | MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG8_1X8, |
83 | V4L2_PIX_FMT_SGRBG10, 10, 2, }, | 83 | V4L2_PIX_FMT_SGRBG10, 10, 2, }, |
84 | { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10, | 84 | { MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10, |
85 | V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB8_1X8, | 85 | MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB8_1X8, |
86 | V4L2_PIX_FMT_SRGGB10, 10, 2, }, | 86 | V4L2_PIX_FMT_SRGGB10, 10, 2, }, |
87 | { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10, | 87 | { MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR10_1X10, |
88 | V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR8_1X8, | 88 | MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR8_1X8, |
89 | V4L2_PIX_FMT_SBGGR12, 12, 2, }, | 89 | V4L2_PIX_FMT_SBGGR12, 12, 2, }, |
90 | { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10, | 90 | { MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG10_1X10, |
91 | V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG8_1X8, | 91 | MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG8_1X8, |
92 | V4L2_PIX_FMT_SGBRG12, 12, 2, }, | 92 | V4L2_PIX_FMT_SGBRG12, 12, 2, }, |
93 | { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10, | 93 | { MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG10_1X10, |
94 | V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG8_1X8, | 94 | MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG8_1X8, |
95 | V4L2_PIX_FMT_SGRBG12, 12, 2, }, | 95 | V4L2_PIX_FMT_SGRBG12, 12, 2, }, |
96 | { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10, | 96 | { MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB10_1X10, |
97 | V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB8_1X8, | 97 | MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB8_1X8, |
98 | V4L2_PIX_FMT_SRGGB12, 12, 2, }, | 98 | V4L2_PIX_FMT_SRGGB12, 12, 2, }, |
99 | { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16, | 99 | { MEDIA_BUS_FMT_UYVY8_1X16, MEDIA_BUS_FMT_UYVY8_1X16, |
100 | V4L2_MBUS_FMT_UYVY8_1X16, 0, | 100 | MEDIA_BUS_FMT_UYVY8_1X16, 0, |
101 | V4L2_PIX_FMT_UYVY, 16, 2, }, | 101 | V4L2_PIX_FMT_UYVY, 16, 2, }, |
102 | { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16, | 102 | { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YUYV8_1X16, |
103 | V4L2_MBUS_FMT_YUYV8_1X16, 0, | 103 | MEDIA_BUS_FMT_YUYV8_1X16, 0, |
104 | V4L2_PIX_FMT_YUYV, 16, 2, }, | 104 | V4L2_PIX_FMT_YUYV, 16, 2, }, |
105 | { V4L2_MBUS_FMT_UYVY8_2X8, V4L2_MBUS_FMT_UYVY8_2X8, | 105 | { MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_UYVY8_2X8, |
106 | V4L2_MBUS_FMT_UYVY8_2X8, 0, | 106 | MEDIA_BUS_FMT_UYVY8_2X8, 0, |
107 | V4L2_PIX_FMT_UYVY, 8, 2, }, | 107 | V4L2_PIX_FMT_UYVY, 8, 2, }, |
108 | { V4L2_MBUS_FMT_YUYV8_2X8, V4L2_MBUS_FMT_YUYV8_2X8, | 108 | { MEDIA_BUS_FMT_YUYV8_2X8, MEDIA_BUS_FMT_YUYV8_2X8, |
109 | V4L2_MBUS_FMT_YUYV8_2X8, 0, | 109 | MEDIA_BUS_FMT_YUYV8_2X8, 0, |
110 | V4L2_PIX_FMT_YUYV, 8, 2, }, | 110 | V4L2_PIX_FMT_YUYV, 8, 2, }, |
111 | /* Empty entry to catch the unsupported pixel code (0) used by the CCDC | 111 | /* Empty entry to catch the unsupported pixel code (0) used by the CCDC |
112 | * module and avoid NULL pointer dereferences. | 112 | * module and avoid NULL pointer dereferences. |
@@ -114,8 +114,7 @@ static struct isp_format_info formats[] = { | |||
114 | { 0, } | 114 | { 0, } |
115 | }; | 115 | }; |
116 | 116 | ||
117 | const struct isp_format_info * | 117 | const struct isp_format_info *omap3isp_video_format_info(u32 code) |
118 | omap3isp_video_format_info(enum v4l2_mbus_pixelcode code) | ||
119 | { | 118 | { |
120 | unsigned int i; | 119 | unsigned int i; |
121 | 120 | ||
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h index 0b7efedc3da9..4071dd7060ea 100644 --- a/drivers/media/platform/omap3isp/ispvideo.h +++ b/drivers/media/platform/omap3isp/ispvideo.h | |||
@@ -44,10 +44,10 @@ struct v4l2_pix_format; | |||
44 | * @bpp: Bytes per pixel (when stored in memory) | 44 | * @bpp: Bytes per pixel (when stored in memory) |
45 | */ | 45 | */ |
46 | struct isp_format_info { | 46 | struct isp_format_info { |
47 | enum v4l2_mbus_pixelcode code; | 47 | u32 code; |
48 | enum v4l2_mbus_pixelcode truncated; | 48 | u32 truncated; |
49 | enum v4l2_mbus_pixelcode uncompressed; | 49 | u32 uncompressed; |
50 | enum v4l2_mbus_pixelcode flavor; | 50 | u32 flavor; |
51 | u32 pixelformat; | 51 | u32 pixelformat; |
52 | unsigned int width; | 52 | unsigned int width; |
53 | unsigned int bpp; | 53 | unsigned int bpp; |
@@ -206,6 +206,6 @@ void omap3isp_video_resume(struct isp_video *video, int continuous); | |||
206 | struct media_pad *omap3isp_video_remote_pad(struct isp_video *video); | 206 | struct media_pad *omap3isp_video_remote_pad(struct isp_video *video); |
207 | 207 | ||
208 | const struct isp_format_info * | 208 | const struct isp_format_info * |
209 | omap3isp_video_format_info(enum v4l2_mbus_pixelcode code); | 209 | omap3isp_video_format_info(u32 code); |
210 | 210 | ||
211 | #endif /* OMAP3_ISP_VIDEO_H */ | 211 | #endif /* OMAP3_ISP_VIDEO_H */ |
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index 4f81b4c9d113..aa40c8269ab8 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c | |||
@@ -1218,11 +1218,11 @@ void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx) | |||
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | /* Media bus pixel formats supported at the camif input */ | 1220 | /* Media bus pixel formats supported at the camif input */ |
1221 | static const enum v4l2_mbus_pixelcode camif_mbus_formats[] = { | 1221 | static const u32 camif_mbus_formats[] = { |
1222 | V4L2_MBUS_FMT_YUYV8_2X8, | 1222 | MEDIA_BUS_FMT_YUYV8_2X8, |
1223 | V4L2_MBUS_FMT_YVYU8_2X8, | 1223 | MEDIA_BUS_FMT_YVYU8_2X8, |
1224 | V4L2_MBUS_FMT_UYVY8_2X8, | 1224 | MEDIA_BUS_FMT_UYVY8_2X8, |
1225 | V4L2_MBUS_FMT_VYUY8_2X8, | 1225 | MEDIA_BUS_FMT_VYUY8_2X8, |
1226 | }; | 1226 | }; |
1227 | 1227 | ||
1228 | /* | 1228 | /* |
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c index b38574702fe9..3b09b5b6ad51 100644 --- a/drivers/media/platform/s3c-camif/camif-core.c +++ b/drivers/media/platform/s3c-camif/camif-core.c | |||
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif) | |||
256 | v4l2_device_unregister_subdev(sd); | 256 | v4l2_device_unregister_subdev(sd); |
257 | camif->sensor.sd = NULL; | 257 | camif->sensor.sd = NULL; |
258 | i2c_unregister_device(client); | 258 | i2c_unregister_device(client); |
259 | if (adapter) | 259 | i2c_put_adapter(adapter); |
260 | i2c_put_adapter(adapter); | ||
261 | } | 260 | } |
262 | 261 | ||
263 | static int camif_create_media_links(struct camif_dev *camif) | 262 | static int camif_create_media_links(struct camif_dev *camif) |
diff --git a/drivers/media/platform/s3c-camif/camif-regs.c b/drivers/media/platform/s3c-camif/camif-regs.c index 6e0c9988a191..812fb3a7c4e3 100644 --- a/drivers/media/platform/s3c-camif/camif-regs.c +++ b/drivers/media/platform/s3c-camif/camif-regs.c | |||
@@ -96,10 +96,10 @@ void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect, | |||
96 | } | 96 | } |
97 | 97 | ||
98 | static const u32 src_pixfmt_map[8][2] = { | 98 | static const u32 src_pixfmt_map[8][2] = { |
99 | { V4L2_MBUS_FMT_YUYV8_2X8, CISRCFMT_ORDER422_YCBYCR }, | 99 | { MEDIA_BUS_FMT_YUYV8_2X8, CISRCFMT_ORDER422_YCBYCR }, |
100 | { V4L2_MBUS_FMT_YVYU8_2X8, CISRCFMT_ORDER422_YCRYCB }, | 100 | { MEDIA_BUS_FMT_YVYU8_2X8, CISRCFMT_ORDER422_YCRYCB }, |
101 | { V4L2_MBUS_FMT_UYVY8_2X8, CISRCFMT_ORDER422_CBYCRY }, | 101 | { MEDIA_BUS_FMT_UYVY8_2X8, CISRCFMT_ORDER422_CBYCRY }, |
102 | { V4L2_MBUS_FMT_VYUY8_2X8, CISRCFMT_ORDER422_CRYCBY }, | 102 | { MEDIA_BUS_FMT_VYUY8_2X8, CISRCFMT_ORDER422_CRYCBY }, |
103 | }; | 103 | }; |
104 | 104 | ||
105 | /* Set camera input pixel format and resolution */ | 105 | /* Set camera input pixel format and resolution */ |
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c index d79e214ce8ce..51e4edc92d28 100644 --- a/drivers/media/platform/s5p-g2d/g2d.c +++ b/drivers/media/platform/s5p-g2d/g2d.c | |||
@@ -297,14 +297,8 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
297 | strncpy(cap->driver, G2D_NAME, sizeof(cap->driver) - 1); | 297 | strncpy(cap->driver, G2D_NAME, sizeof(cap->driver) - 1); |
298 | strncpy(cap->card, G2D_NAME, sizeof(cap->card) - 1); | 298 | strncpy(cap->card, G2D_NAME, sizeof(cap->card) - 1); |
299 | cap->bus_info[0] = 0; | 299 | cap->bus_info[0] = 0; |
300 | cap->version = KERNEL_VERSION(1, 0, 0); | 300 | cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING; |
301 | /* | 301 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
302 | * This is only a mem-to-mem video device. The capture and output | ||
303 | * device capability flags are left only for backward compatibility | ||
304 | * and are scheduled for removal. | ||
305 | */ | ||
306 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT | | ||
307 | V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING; | ||
308 | return 0; | 302 | return 0; |
309 | } | 303 | } |
310 | 304 | ||
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index fe2727413f3a..3ecf0e06a4dd 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c | |||
@@ -1001,13 +1001,8 @@ static int s5p_jpeg_querycap(struct file *file, void *priv, | |||
1001 | sizeof(cap->card)); | 1001 | sizeof(cap->card)); |
1002 | } | 1002 | } |
1003 | cap->bus_info[0] = 0; | 1003 | cap->bus_info[0] = 0; |
1004 | /* | 1004 | cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M; |
1005 | * This is only a mem-to-mem video device. The capture and output | 1005 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
1006 | * device capability flags are left only for backward compatibility | ||
1007 | * and are scheduled for removal. | ||
1008 | */ | ||
1009 | cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M | | ||
1010 | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT; | ||
1011 | return 0; | 1006 | return 0; |
1012 | } | 1007 | } |
1013 | 1008 | ||
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h index 51cb2dd0e13a..83e01f3466e9 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h | |||
@@ -71,6 +71,7 @@ | |||
71 | #define S5P_FIMV_R2H_CMD_ENC_BUFFER_FUL_RET_V6 16 | 71 | #define S5P_FIMV_R2H_CMD_ENC_BUFFER_FUL_RET_V6 16 |
72 | #define S5P_FIMV_R2H_CMD_ERR_RET_V6 32 | 72 | #define S5P_FIMV_R2H_CMD_ERR_RET_V6 32 |
73 | 73 | ||
74 | #define S5P_FIMV_MFC_BUS_RESET_CTRL 0x7110 | ||
74 | #define S5P_FIMV_FW_VERSION_V6 0xf000 | 75 | #define S5P_FIMV_FW_VERSION_V6 0xf000 |
75 | 76 | ||
76 | #define S5P_FIMV_INSTANCE_ID_V6 0xf008 | 77 | #define S5P_FIMV_INSTANCE_ID_V6 0xf008 |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 363fd8c0a699..b80a576164f1 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c | |||
@@ -159,6 +159,10 @@ static void s5p_mfc_watchdog_worker(struct work_struct *work) | |||
159 | } | 159 | } |
160 | clear_bit(0, &dev->hw_lock); | 160 | clear_bit(0, &dev->hw_lock); |
161 | spin_unlock_irqrestore(&dev->irqlock, flags); | 161 | spin_unlock_irqrestore(&dev->irqlock, flags); |
162 | |||
163 | /* De-init MFC */ | ||
164 | s5p_mfc_deinit_hw(dev); | ||
165 | |||
162 | /* Double check if there is at least one instance running. | 166 | /* Double check if there is at least one instance running. |
163 | * If no instance is in memory than no firmware should be present */ | 167 | * If no instance is in memory than no firmware should be present */ |
164 | if (dev->num_inst > 0) { | 168 | if (dev->num_inst > 0) { |
@@ -220,11 +224,14 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx) | |||
220 | size_t dec_y_addr; | 224 | size_t dec_y_addr; |
221 | unsigned int frame_type; | 225 | unsigned int frame_type; |
222 | 226 | ||
223 | dec_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dec_y_adr, dev); | 227 | /* Make sure we actually have a new frame before continuing. */ |
224 | frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_dec_frame_type, dev); | 228 | frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_dec_frame_type, dev); |
229 | if (frame_type == S5P_FIMV_DECODE_FRAME_SKIPPED) | ||
230 | return; | ||
231 | dec_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dec_y_adr, dev); | ||
225 | 232 | ||
226 | /* Copy timestamp / timecode from decoded src to dst and set | 233 | /* Copy timestamp / timecode from decoded src to dst and set |
227 | appropriate flags */ | 234 | appropriate flags. */ |
228 | src_buf = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); | 235 | src_buf = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); |
229 | list_for_each_entry(dst_buf, &ctx->dst_queue, list) { | 236 | list_for_each_entry(dst_buf, &ctx->dst_queue, list) { |
230 | if (vb2_dma_contig_plane_dma_addr(dst_buf->b, 0) == dec_y_addr) { | 237 | if (vb2_dma_contig_plane_dma_addr(dst_buf->b, 0) == dec_y_addr) { |
@@ -250,6 +257,11 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx) | |||
250 | dst_buf->b->v4l2_buf.flags |= | 257 | dst_buf->b->v4l2_buf.flags |= |
251 | V4L2_BUF_FLAG_BFRAME; | 258 | V4L2_BUF_FLAG_BFRAME; |
252 | break; | 259 | break; |
260 | default: | ||
261 | /* Don't know how to handle | ||
262 | S5P_FIMV_DECODE_FRAME_OTHER_FRAME. */ | ||
263 | mfc_debug(2, "Unexpected frame type: %d\n", | ||
264 | frame_type); | ||
253 | } | 265 | } |
254 | break; | 266 | break; |
255 | } | 267 | } |
@@ -334,8 +346,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx, | |||
334 | ctx->state = MFCINST_RES_CHANGE_INIT; | 346 | ctx->state = MFCINST_RES_CHANGE_INIT; |
335 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); | 347 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); |
336 | wake_up_ctx(ctx, reason, err); | 348 | wake_up_ctx(ctx, reason, err); |
337 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 349 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
338 | BUG(); | ||
339 | s5p_mfc_clock_off(); | 350 | s5p_mfc_clock_off(); |
340 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 351 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
341 | return; | 352 | return; |
@@ -407,8 +418,7 @@ leave_handle_frame: | |||
407 | clear_work_bit(ctx); | 418 | clear_work_bit(ctx); |
408 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); | 419 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); |
409 | wake_up_ctx(ctx, reason, err); | 420 | wake_up_ctx(ctx, reason, err); |
410 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 421 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
411 | BUG(); | ||
412 | s5p_mfc_clock_off(); | 422 | s5p_mfc_clock_off(); |
413 | /* if suspending, wake up device and do not try_run again*/ | 423 | /* if suspending, wake up device and do not try_run again*/ |
414 | if (test_bit(0, &dev->enter_suspend)) | 424 | if (test_bit(0, &dev->enter_suspend)) |
@@ -455,8 +465,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev, | |||
455 | break; | 465 | break; |
456 | } | 466 | } |
457 | } | 467 | } |
458 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 468 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
459 | BUG(); | ||
460 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); | 469 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); |
461 | s5p_mfc_clock_off(); | 470 | s5p_mfc_clock_off(); |
462 | wake_up_dev(dev, reason, err); | 471 | wake_up_dev(dev, reason, err); |
@@ -510,8 +519,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx, | |||
510 | } | 519 | } |
511 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); | 520 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); |
512 | clear_work_bit(ctx); | 521 | clear_work_bit(ctx); |
513 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 522 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
514 | BUG(); | ||
515 | s5p_mfc_clock_off(); | 523 | s5p_mfc_clock_off(); |
516 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 524 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
517 | wake_up_ctx(ctx, reason, err); | 525 | wake_up_ctx(ctx, reason, err); |
@@ -549,16 +557,14 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx, | |||
549 | } else { | 557 | } else { |
550 | ctx->dpb_flush_flag = 0; | 558 | ctx->dpb_flush_flag = 0; |
551 | } | 559 | } |
552 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 560 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
553 | BUG(); | ||
554 | 561 | ||
555 | s5p_mfc_clock_off(); | 562 | s5p_mfc_clock_off(); |
556 | 563 | ||
557 | wake_up(&ctx->queue); | 564 | wake_up(&ctx->queue); |
558 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 565 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
559 | } else { | 566 | } else { |
560 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 567 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
561 | BUG(); | ||
562 | 568 | ||
563 | s5p_mfc_clock_off(); | 569 | s5p_mfc_clock_off(); |
564 | 570 | ||
@@ -635,8 +641,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv) | |||
635 | mfc_err("post_frame_start() failed\n"); | 641 | mfc_err("post_frame_start() failed\n"); |
636 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); | 642 | s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev); |
637 | wake_up_ctx(ctx, reason, err); | 643 | wake_up_ctx(ctx, reason, err); |
638 | if (test_and_clear_bit(0, &dev->hw_lock) == 0) | 644 | WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0); |
639 | BUG(); | ||
640 | s5p_mfc_clock_off(); | 645 | s5p_mfc_clock_off(); |
641 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 646 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
642 | } else { | 647 | } else { |
@@ -815,7 +820,7 @@ static int s5p_mfc_open(struct file *file) | |||
815 | ret = -ENOENT; | 820 | ret = -ENOENT; |
816 | goto err_queue_init; | 821 | goto err_queue_init; |
817 | } | 822 | } |
818 | q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops; | 823 | q->mem_ops = &vb2_dma_contig_memops; |
819 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 824 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
820 | ret = vb2_queue_init(q); | 825 | ret = vb2_queue_init(q); |
821 | if (ret) { | 826 | if (ret) { |
@@ -837,7 +842,7 @@ static int s5p_mfc_open(struct file *file) | |||
837 | ret = -ENOENT; | 842 | ret = -ENOENT; |
838 | goto err_queue_init; | 843 | goto err_queue_init; |
839 | } | 844 | } |
840 | q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops; | 845 | q->mem_ops = &vb2_dma_contig_memops; |
841 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 846 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
842 | ret = vb2_queue_init(q); | 847 | ret = vb2_queue_init(q); |
843 | if (ret) { | 848 | if (ret) { |
@@ -1284,11 +1289,17 @@ static int s5p_mfc_suspend(struct device *dev) | |||
1284 | m_dev->int_cond, msecs_to_jiffies(MFC_INT_TIMEOUT)); | 1289 | m_dev->int_cond, msecs_to_jiffies(MFC_INT_TIMEOUT)); |
1285 | if (ret == 0) { | 1290 | if (ret == 0) { |
1286 | mfc_err("Waiting for hardware to finish timed out\n"); | 1291 | mfc_err("Waiting for hardware to finish timed out\n"); |
1292 | clear_bit(0, &m_dev->enter_suspend); | ||
1287 | return -EIO; | 1293 | return -EIO; |
1288 | } | 1294 | } |
1289 | } | 1295 | } |
1290 | 1296 | ||
1291 | return s5p_mfc_sleep(m_dev); | 1297 | ret = s5p_mfc_sleep(m_dev); |
1298 | if (ret) { | ||
1299 | clear_bit(0, &m_dev->enter_suspend); | ||
1300 | clear_bit(0, &m_dev->hw_lock); | ||
1301 | } | ||
1302 | return ret; | ||
1292 | } | 1303 | } |
1293 | 1304 | ||
1294 | static int s5p_mfc_resume(struct device *dev) | 1305 | static int s5p_mfc_resume(struct device *dev) |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 3e41ca1293ed..15f7663dd9f5 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h | |||
@@ -237,8 +237,6 @@ struct s5p_mfc_variant { | |||
237 | 237 | ||
238 | /** | 238 | /** |
239 | * struct s5p_mfc_priv_buf - represents internal used buffer | 239 | * struct s5p_mfc_priv_buf - represents internal used buffer |
240 | * @alloc: allocation-specific context for each buffer | ||
241 | * (videobuf2 allocator) | ||
242 | * @ofs: offset of each buffer, will be used for MFC | 240 | * @ofs: offset of each buffer, will be used for MFC |
243 | * @virt: kernel virtual address, only valid when the | 241 | * @virt: kernel virtual address, only valid when the |
244 | * buffer accessed by driver | 242 | * buffer accessed by driver |
@@ -246,7 +244,6 @@ struct s5p_mfc_variant { | |||
246 | * @size: size of the buffer | 244 | * @size: size of the buffer |
247 | */ | 245 | */ |
248 | struct s5p_mfc_priv_buf { | 246 | struct s5p_mfc_priv_buf { |
249 | void *alloc; | ||
250 | unsigned long ofs; | 247 | unsigned long ofs; |
251 | void *virt; | 248 | void *virt; |
252 | dma_addr_t dma; | 249 | dma_addr_t dma; |
@@ -340,6 +337,7 @@ struct s5p_mfc_dev { | |||
340 | struct s5p_mfc_hw_cmds *mfc_cmds; | 337 | struct s5p_mfc_hw_cmds *mfc_cmds; |
341 | const struct s5p_mfc_regs *mfc_regs; | 338 | const struct s5p_mfc_regs *mfc_regs; |
342 | enum s5p_mfc_fw_ver fw_ver; | 339 | enum s5p_mfc_fw_ver fw_ver; |
340 | bool risc_on; /* indicates if RISC is on or off */ | ||
343 | }; | 341 | }; |
344 | 342 | ||
345 | /** | 343 | /** |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c index 0c885a8a0e9f..40d8a03a141d 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c | |||
@@ -129,6 +129,25 @@ int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev) | |||
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
131 | 131 | ||
132 | static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev) | ||
133 | { | ||
134 | unsigned int status; | ||
135 | unsigned long timeout; | ||
136 | |||
137 | /* Reset */ | ||
138 | mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL); | ||
139 | timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT); | ||
140 | /* Check bus status */ | ||
141 | do { | ||
142 | if (time_after(jiffies, timeout)) { | ||
143 | mfc_err("Timeout while resetting MFC.\n"); | ||
144 | return -EIO; | ||
145 | } | ||
146 | status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL); | ||
147 | } while ((status & 0x2) == 0); | ||
148 | return 0; | ||
149 | } | ||
150 | |||
132 | /* Reset the device */ | 151 | /* Reset the device */ |
133 | int s5p_mfc_reset(struct s5p_mfc_dev *dev) | 152 | int s5p_mfc_reset(struct s5p_mfc_dev *dev) |
134 | { | 153 | { |
@@ -139,12 +158,6 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev) | |||
139 | mfc_debug_enter(); | 158 | mfc_debug_enter(); |
140 | 159 | ||
141 | if (IS_MFCV6_PLUS(dev)) { | 160 | if (IS_MFCV6_PLUS(dev)) { |
142 | /* Reset IP */ | ||
143 | /* except RISC, reset */ | ||
144 | mfc_write(dev, 0xFEE, S5P_FIMV_MFC_RESET_V6); | ||
145 | /* reset release */ | ||
146 | mfc_write(dev, 0x0, S5P_FIMV_MFC_RESET_V6); | ||
147 | |||
148 | /* Zero Initialization of MFC registers */ | 161 | /* Zero Initialization of MFC registers */ |
149 | mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6); | 162 | mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6); |
150 | mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6); | 163 | mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6); |
@@ -153,8 +166,17 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev) | |||
153 | for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++) | 166 | for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++) |
154 | mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4)); | 167 | mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4)); |
155 | 168 | ||
156 | /* Reset */ | 169 | /* check bus reset control before reset */ |
157 | mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6); | 170 | if (dev->risc_on) |
171 | if (s5p_mfc_bus_reset(dev)) | ||
172 | return -EIO; | ||
173 | /* Reset | ||
174 | * set RISC_ON to 0 during power_on & wake_up. | ||
175 | * V6 needs RISC_ON set to 0 during reset also. | ||
176 | */ | ||
177 | if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev))) | ||
178 | mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6); | ||
179 | |||
158 | mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6); | 180 | mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6); |
159 | mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6); | 181 | mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6); |
160 | } else { | 182 | } else { |
@@ -226,6 +248,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) | |||
226 | /* 0. MFC reset */ | 248 | /* 0. MFC reset */ |
227 | mfc_debug(2, "MFC reset..\n"); | 249 | mfc_debug(2, "MFC reset..\n"); |
228 | s5p_mfc_clock_on(); | 250 | s5p_mfc_clock_on(); |
251 | dev->risc_on = 0; | ||
229 | ret = s5p_mfc_reset(dev); | 252 | ret = s5p_mfc_reset(dev); |
230 | if (ret) { | 253 | if (ret) { |
231 | mfc_err("Failed to reset MFC - timeout\n"); | 254 | mfc_err("Failed to reset MFC - timeout\n"); |
@@ -238,8 +261,10 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) | |||
238 | s5p_mfc_clear_cmds(dev); | 261 | s5p_mfc_clear_cmds(dev); |
239 | /* 3. Release reset signal to the RISC */ | 262 | /* 3. Release reset signal to the RISC */ |
240 | s5p_mfc_clean_dev_int_flags(dev); | 263 | s5p_mfc_clean_dev_int_flags(dev); |
241 | if (IS_MFCV6_PLUS(dev)) | 264 | if (IS_MFCV6_PLUS(dev)) { |
265 | dev->risc_on = 1; | ||
242 | mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); | 266 | mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); |
267 | } | ||
243 | else | 268 | else |
244 | mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); | 269 | mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); |
245 | mfc_debug(2, "Will now wait for completion of firmware transfer\n"); | 270 | mfc_debug(2, "Will now wait for completion of firmware transfer\n"); |
@@ -328,6 +353,58 @@ int s5p_mfc_sleep(struct s5p_mfc_dev *dev) | |||
328 | return ret; | 353 | return ret; |
329 | } | 354 | } |
330 | 355 | ||
356 | static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev) | ||
357 | { | ||
358 | int ret; | ||
359 | |||
360 | /* Release reset signal to the RISC */ | ||
361 | dev->risc_on = 1; | ||
362 | mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); | ||
363 | |||
364 | if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) { | ||
365 | mfc_err("Failed to reset MFCV8\n"); | ||
366 | return -EIO; | ||
367 | } | ||
368 | mfc_debug(2, "Write command to wakeup MFCV8\n"); | ||
369 | ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); | ||
370 | if (ret) { | ||
371 | mfc_err("Failed to send command to MFCV8 - timeout\n"); | ||
372 | return ret; | ||
373 | } | ||
374 | |||
375 | if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { | ||
376 | mfc_err("Failed to wakeup MFC\n"); | ||
377 | return -EIO; | ||
378 | } | ||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev) | ||
383 | { | ||
384 | int ret; | ||
385 | |||
386 | /* Send MFC wakeup command */ | ||
387 | ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); | ||
388 | if (ret) { | ||
389 | mfc_err("Failed to send command to MFC - timeout\n"); | ||
390 | return ret; | ||
391 | } | ||
392 | |||
393 | /* Release reset signal to the RISC */ | ||
394 | if (IS_MFCV6_PLUS(dev)) { | ||
395 | dev->risc_on = 1; | ||
396 | mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); | ||
397 | } else { | ||
398 | mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); | ||
399 | } | ||
400 | |||
401 | if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { | ||
402 | mfc_err("Failed to wakeup MFC\n"); | ||
403 | return -EIO; | ||
404 | } | ||
405 | return ret; | ||
406 | } | ||
407 | |||
331 | int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) | 408 | int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) |
332 | { | 409 | { |
333 | int ret; | 410 | int ret; |
@@ -336,9 +413,11 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) | |||
336 | /* 0. MFC reset */ | 413 | /* 0. MFC reset */ |
337 | mfc_debug(2, "MFC reset..\n"); | 414 | mfc_debug(2, "MFC reset..\n"); |
338 | s5p_mfc_clock_on(); | 415 | s5p_mfc_clock_on(); |
416 | dev->risc_on = 0; | ||
339 | ret = s5p_mfc_reset(dev); | 417 | ret = s5p_mfc_reset(dev); |
340 | if (ret) { | 418 | if (ret) { |
341 | mfc_err("Failed to reset MFC - timeout\n"); | 419 | mfc_err("Failed to reset MFC - timeout\n"); |
420 | s5p_mfc_clock_off(); | ||
342 | return ret; | 421 | return ret; |
343 | } | 422 | } |
344 | mfc_debug(2, "Done MFC reset..\n"); | 423 | mfc_debug(2, "Done MFC reset..\n"); |
@@ -347,23 +426,16 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev) | |||
347 | /* 2. Initialize registers of channel I/F */ | 426 | /* 2. Initialize registers of channel I/F */ |
348 | s5p_mfc_clear_cmds(dev); | 427 | s5p_mfc_clear_cmds(dev); |
349 | s5p_mfc_clean_dev_int_flags(dev); | 428 | s5p_mfc_clean_dev_int_flags(dev); |
350 | /* 3. Initialize firmware */ | 429 | /* 3. Send MFC wakeup command and wait for completion*/ |
351 | ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev); | 430 | if (IS_MFCV8(dev)) |
352 | if (ret) { | 431 | ret = s5p_mfc_v8_wait_wakeup(dev); |
353 | mfc_err("Failed to send command to MFC - timeout\n"); | ||
354 | return ret; | ||
355 | } | ||
356 | /* 4. Release reset signal to the RISC */ | ||
357 | if (IS_MFCV6_PLUS(dev)) | ||
358 | mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6); | ||
359 | else | 432 | else |
360 | mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET); | 433 | ret = s5p_mfc_wait_wakeup(dev); |
361 | mfc_debug(2, "Ok, now will write a command to wakeup the system\n"); | 434 | |
362 | if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) { | ||
363 | mfc_err("Failed to load firmware\n"); | ||
364 | return -EIO; | ||
365 | } | ||
366 | s5p_mfc_clock_off(); | 435 | s5p_mfc_clock_off(); |
436 | if (ret) | ||
437 | return ret; | ||
438 | |||
367 | dev->int_cond = 0; | 439 | dev->int_cond = 0; |
368 | if (dev->int_err != 0 || dev->int_type != | 440 | if (dev->int_err != 0 || dev->int_type != |
369 | S5P_MFC_R2H_CMD_WAKEUP_RET) { | 441 | S5P_MFC_R2H_CMD_WAKEUP_RET) { |
@@ -396,7 +468,6 @@ int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) | |||
396 | } | 468 | } |
397 | 469 | ||
398 | set_work_bit_irqsave(ctx); | 470 | set_work_bit_irqsave(ctx); |
399 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
400 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 471 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
401 | if (s5p_mfc_wait_for_done_ctx(ctx, | 472 | if (s5p_mfc_wait_for_done_ctx(ctx, |
402 | S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) { | 473 | S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) { |
@@ -422,7 +493,6 @@ void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) | |||
422 | { | 493 | { |
423 | ctx->state = MFCINST_RETURN_INST; | 494 | ctx->state = MFCINST_RETURN_INST; |
424 | set_work_bit_irqsave(ctx); | 495 | set_work_bit_irqsave(ctx); |
425 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
426 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 496 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
427 | /* Wait until instance is returned or timeout occurred */ | 497 | /* Wait until instance is returned or timeout occurred */ |
428 | if (s5p_mfc_wait_for_done_ctx(ctx, | 498 | if (s5p_mfc_wait_for_done_ctx(ctx, |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index a98fe023deaf..c6c3452ccca1 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | |||
@@ -269,15 +269,13 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
269 | strncpy(cap->driver, dev->plat_dev->name, sizeof(cap->driver) - 1); | 269 | strncpy(cap->driver, dev->plat_dev->name, sizeof(cap->driver) - 1); |
270 | strncpy(cap->card, dev->plat_dev->name, sizeof(cap->card) - 1); | 270 | strncpy(cap->card, dev->plat_dev->name, sizeof(cap->card) - 1); |
271 | cap->bus_info[0] = 0; | 271 | cap->bus_info[0] = 0; |
272 | cap->version = KERNEL_VERSION(1, 0, 0); | ||
273 | /* | 272 | /* |
274 | * This is only a mem-to-mem video device. The capture and output | 273 | * This is only a mem-to-mem video device. The capture and output |
275 | * device capability flags are left only for backward compatibility | 274 | * device capability flags are left only for backward compatibility |
276 | * and are scheduled for removal. | 275 | * and are scheduled for removal. |
277 | */ | 276 | */ |
278 | cap->capabilities = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING | | 277 | cap->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; |
279 | V4L2_CAP_VIDEO_CAPTURE_MPLANE | | 278 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
280 | V4L2_CAP_VIDEO_OUTPUT_MPLANE; | ||
281 | return 0; | 279 | return 0; |
282 | } | 280 | } |
283 | 281 | ||
@@ -334,7 +332,6 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) | |||
334 | MFCINST_RES_CHANGE_END)) { | 332 | MFCINST_RES_CHANGE_END)) { |
335 | /* If the MFC is parsing the header, | 333 | /* If the MFC is parsing the header, |
336 | * so wait until it is finished */ | 334 | * so wait until it is finished */ |
337 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
338 | s5p_mfc_wait_for_done_ctx(ctx, S5P_MFC_R2H_CMD_SEQ_DONE_RET, | 335 | s5p_mfc_wait_for_done_ctx(ctx, S5P_MFC_R2H_CMD_SEQ_DONE_RET, |
339 | 0); | 336 | 0); |
340 | } | 337 | } |
@@ -740,12 +737,12 @@ static int s5p_mfc_dec_g_v_ctrl(struct v4l2_ctrl *ctrl) | |||
740 | ctx->state < MFCINST_ABORT) { | 737 | ctx->state < MFCINST_ABORT) { |
741 | ctrl->val = ctx->pb_count; | 738 | ctrl->val = ctx->pb_count; |
742 | break; | 739 | break; |
743 | } else if (ctx->state != MFCINST_INIT) { | 740 | } else if (ctx->state != MFCINST_INIT && |
741 | ctx->state != MFCINST_RES_CHANGE_END) { | ||
744 | v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n"); | 742 | v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n"); |
745 | return -EINVAL; | 743 | return -EINVAL; |
746 | } | 744 | } |
747 | /* Should wait for the header to be parsed */ | 745 | /* Should wait for the header to be parsed */ |
748 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
749 | s5p_mfc_wait_for_done_ctx(ctx, | 746 | s5p_mfc_wait_for_done_ctx(ctx, |
750 | S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0); | 747 | S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0); |
751 | if (ctx->state >= MFCINST_HEAD_PARSED && | 748 | if (ctx->state >= MFCINST_HEAD_PARSED && |
@@ -1057,7 +1054,6 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q) | |||
1057 | if (IS_MFCV6_PLUS(dev) && (ctx->state == MFCINST_RUNNING)) { | 1054 | if (IS_MFCV6_PLUS(dev) && (ctx->state == MFCINST_RUNNING)) { |
1058 | ctx->state = MFCINST_FLUSH; | 1055 | ctx->state = MFCINST_FLUSH; |
1059 | set_work_bit_irqsave(ctx); | 1056 | set_work_bit_irqsave(ctx); |
1060 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1061 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); | 1057 | s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev); |
1062 | if (s5p_mfc_wait_for_done_ctx(ctx, | 1058 | if (s5p_mfc_wait_for_done_ctx(ctx, |
1063 | S5P_MFC_R2H_CMD_DPB_FLUSH_RET, 0)) | 1059 | S5P_MFC_R2H_CMD_DPB_FLUSH_RET, 0)) |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index a904a1c7bb21..bd64f1dcbdb5 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "s5p_mfc_intr.h" | 32 | #include "s5p_mfc_intr.h" |
33 | #include "s5p_mfc_opr.h" | 33 | #include "s5p_mfc_opr.h" |
34 | 34 | ||
35 | #define DEF_SRC_FMT_ENC V4L2_PIX_FMT_NV12MT | 35 | #define DEF_SRC_FMT_ENC V4L2_PIX_FMT_NV12M |
36 | #define DEF_DST_FMT_ENC V4L2_PIX_FMT_H264 | 36 | #define DEF_DST_FMT_ENC V4L2_PIX_FMT_H264 |
37 | 37 | ||
38 | static struct s5p_mfc_fmt formats[] = { | 38 | static struct s5p_mfc_fmt formats[] = { |
@@ -67,8 +67,7 @@ static struct s5p_mfc_fmt formats[] = { | |||
67 | .codec_mode = S5P_MFC_CODEC_NONE, | 67 | .codec_mode = S5P_MFC_CODEC_NONE, |
68 | .type = MFC_FMT_RAW, | 68 | .type = MFC_FMT_RAW, |
69 | .num_planes = 2, | 69 | .num_planes = 2, |
70 | .versions = MFC_V5_BIT | MFC_V6_BIT | MFC_V7_BIT | | 70 | .versions = MFC_V6_BIT | MFC_V7_BIT | MFC_V8_BIT, |
71 | MFC_V8_BIT, | ||
72 | }, | 71 | }, |
73 | { | 72 | { |
74 | .name = "H264 Encoded Stream", | 73 | .name = "H264 Encoded Stream", |
@@ -690,6 +689,16 @@ static struct mfc_control controls[] = { | |||
690 | .step = 1, | 689 | .step = 1, |
691 | .default_value = 0, | 690 | .default_value = 0, |
692 | }, | 691 | }, |
692 | { | ||
693 | .id = V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, | ||
694 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
695 | .name = "Minimum number of output bufs", | ||
696 | .minimum = 1, | ||
697 | .maximum = 32, | ||
698 | .step = 1, | ||
699 | .default_value = 1, | ||
700 | .is_volatile = 1, | ||
701 | }, | ||
693 | }; | 702 | }; |
694 | 703 | ||
695 | #define NUM_CTRLS ARRAY_SIZE(controls) | 704 | #define NUM_CTRLS ARRAY_SIZE(controls) |
@@ -938,15 +947,13 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
938 | strncpy(cap->driver, dev->plat_dev->name, sizeof(cap->driver) - 1); | 947 | strncpy(cap->driver, dev->plat_dev->name, sizeof(cap->driver) - 1); |
939 | strncpy(cap->card, dev->plat_dev->name, sizeof(cap->card) - 1); | 948 | strncpy(cap->card, dev->plat_dev->name, sizeof(cap->card) - 1); |
940 | cap->bus_info[0] = 0; | 949 | cap->bus_info[0] = 0; |
941 | cap->version = KERNEL_VERSION(1, 0, 0); | ||
942 | /* | 950 | /* |
943 | * This is only a mem-to-mem video device. The capture and output | 951 | * This is only a mem-to-mem video device. The capture and output |
944 | * device capability flags are left only for backward compatibility | 952 | * device capability flags are left only for backward compatibility |
945 | * and are scheduled for removal. | 953 | * and are scheduled for removal. |
946 | */ | 954 | */ |
947 | cap->capabilities = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING | | 955 | cap->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; |
948 | V4L2_CAP_VIDEO_CAPTURE_MPLANE | | 956 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
949 | V4L2_CAP_VIDEO_OUTPUT_MPLANE; | ||
950 | return 0; | 957 | return 0; |
951 | } | 958 | } |
952 | 959 | ||
@@ -1137,6 +1144,11 @@ static int vidioc_reqbufs(struct file *file, void *priv, | |||
1137 | (reqbufs->memory != V4L2_MEMORY_USERPTR)) | 1144 | (reqbufs->memory != V4L2_MEMORY_USERPTR)) |
1138 | return -EINVAL; | 1145 | return -EINVAL; |
1139 | if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { | 1146 | if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
1147 | if (reqbufs->count == 0) { | ||
1148 | ret = vb2_reqbufs(&ctx->vq_dst, reqbufs); | ||
1149 | ctx->capture_state = QUEUE_FREE; | ||
1150 | return ret; | ||
1151 | } | ||
1140 | if (ctx->capture_state != QUEUE_FREE) { | 1152 | if (ctx->capture_state != QUEUE_FREE) { |
1141 | mfc_err("invalid capture state: %d\n", | 1153 | mfc_err("invalid capture state: %d\n", |
1142 | ctx->capture_state); | 1154 | ctx->capture_state); |
@@ -1158,6 +1170,14 @@ static int vidioc_reqbufs(struct file *file, void *priv, | |||
1158 | return -ENOMEM; | 1170 | return -ENOMEM; |
1159 | } | 1171 | } |
1160 | } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { | 1172 | } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { |
1173 | if (reqbufs->count == 0) { | ||
1174 | mfc_debug(2, "Freeing buffers\n"); | ||
1175 | ret = vb2_reqbufs(&ctx->vq_src, reqbufs); | ||
1176 | s5p_mfc_hw_call_void(dev->mfc_ops, release_codec_buffers, | ||
1177 | ctx); | ||
1178 | ctx->output_state = QUEUE_FREE; | ||
1179 | return ret; | ||
1180 | } | ||
1161 | if (ctx->output_state != QUEUE_FREE) { | 1181 | if (ctx->output_state != QUEUE_FREE) { |
1162 | mfc_err("invalid output state: %d\n", | 1182 | mfc_err("invalid output state: %d\n", |
1163 | ctx->output_state); | 1183 | ctx->output_state); |
@@ -1624,8 +1644,39 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl) | |||
1624 | return ret; | 1644 | return ret; |
1625 | } | 1645 | } |
1626 | 1646 | ||
1647 | static int s5p_mfc_enc_g_v_ctrl(struct v4l2_ctrl *ctrl) | ||
1648 | { | ||
1649 | struct s5p_mfc_ctx *ctx = ctrl_to_ctx(ctrl); | ||
1650 | struct s5p_mfc_dev *dev = ctx->dev; | ||
1651 | |||
1652 | switch (ctrl->id) { | ||
1653 | case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: | ||
1654 | if (ctx->state >= MFCINST_HEAD_PARSED && | ||
1655 | ctx->state < MFCINST_ABORT) { | ||
1656 | ctrl->val = ctx->pb_count; | ||
1657 | break; | ||
1658 | } else if (ctx->state != MFCINST_INIT) { | ||
1659 | v4l2_err(&dev->v4l2_dev, "Encoding not initialised\n"); | ||
1660 | return -EINVAL; | ||
1661 | } | ||
1662 | /* Should wait for the header to be produced */ | ||
1663 | s5p_mfc_wait_for_done_ctx(ctx, | ||
1664 | S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0); | ||
1665 | if (ctx->state >= MFCINST_HEAD_PARSED && | ||
1666 | ctx->state < MFCINST_ABORT) { | ||
1667 | ctrl->val = ctx->pb_count; | ||
1668 | } else { | ||
1669 | v4l2_err(&dev->v4l2_dev, "Encoding not initialised\n"); | ||
1670 | return -EINVAL; | ||
1671 | } | ||
1672 | break; | ||
1673 | } | ||
1674 | return 0; | ||
1675 | } | ||
1676 | |||
1627 | static const struct v4l2_ctrl_ops s5p_mfc_enc_ctrl_ops = { | 1677 | static const struct v4l2_ctrl_ops s5p_mfc_enc_ctrl_ops = { |
1628 | .s_ctrl = s5p_mfc_enc_s_ctrl, | 1678 | .s_ctrl = s5p_mfc_enc_s_ctrl, |
1679 | .g_volatile_ctrl = s5p_mfc_enc_g_v_ctrl, | ||
1629 | }; | 1680 | }; |
1630 | 1681 | ||
1631 | static int vidioc_s_parm(struct file *file, void *priv, | 1682 | static int vidioc_s_parm(struct file *file, void *priv, |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c index 7cf07963187d..0c4fcf2dfd09 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c | |||
@@ -1178,7 +1178,6 @@ static void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx) | |||
1178 | 1178 | ||
1179 | s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); | 1179 | s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); |
1180 | dev->curr_ctx = ctx->num; | 1180 | dev->curr_ctx = ctx->num; |
1181 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1182 | s5p_mfc_decode_one_frame_v5(ctx, MFC_DEC_RES_CHANGE); | 1181 | s5p_mfc_decode_one_frame_v5(ctx, MFC_DEC_RES_CHANGE); |
1183 | } | 1182 | } |
1184 | 1183 | ||
@@ -1192,7 +1191,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame) | |||
1192 | last_frame = MFC_DEC_LAST_FRAME; | 1191 | last_frame = MFC_DEC_LAST_FRAME; |
1193 | s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); | 1192 | s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); |
1194 | dev->curr_ctx = ctx->num; | 1193 | dev->curr_ctx = ctx->num; |
1195 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1196 | s5p_mfc_decode_one_frame_v5(ctx, last_frame); | 1194 | s5p_mfc_decode_one_frame_v5(ctx, last_frame); |
1197 | return 0; | 1195 | return 0; |
1198 | } | 1196 | } |
@@ -1212,7 +1210,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame) | |||
1212 | ctx->consumed_stream, temp_vb->b->v4l2_planes[0].bytesused); | 1210 | ctx->consumed_stream, temp_vb->b->v4l2_planes[0].bytesused); |
1213 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1211 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1214 | dev->curr_ctx = ctx->num; | 1212 | dev->curr_ctx = ctx->num; |
1215 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1216 | if (temp_vb->b->v4l2_planes[0].bytesused == 0) { | 1213 | if (temp_vb->b->v4l2_planes[0].bytesused == 0) { |
1217 | last_frame = MFC_DEC_LAST_FRAME; | 1214 | last_frame = MFC_DEC_LAST_FRAME; |
1218 | mfc_debug(2, "Setting ctx->state to FINISHING\n"); | 1215 | mfc_debug(2, "Setting ctx->state to FINISHING\n"); |
@@ -1273,7 +1270,6 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx) | |||
1273 | s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); | 1270 | s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); |
1274 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1271 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1275 | dev->curr_ctx = ctx->num; | 1272 | dev->curr_ctx = ctx->num; |
1276 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1277 | mfc_debug(2, "encoding buffer with index=%d state=%d\n", | 1273 | mfc_debug(2, "encoding buffer with index=%d state=%d\n", |
1278 | src_mb ? src_mb->b->v4l2_buf.index : -1, ctx->state); | 1274 | src_mb ? src_mb->b->v4l2_buf.index : -1, ctx->state); |
1279 | s5p_mfc_encode_one_frame_v5(ctx); | 1275 | s5p_mfc_encode_one_frame_v5(ctx); |
@@ -1297,7 +1293,6 @@ static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx) | |||
1297 | 0, temp_vb->b->v4l2_planes[0].bytesused); | 1293 | 0, temp_vb->b->v4l2_planes[0].bytesused); |
1298 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1294 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1299 | dev->curr_ctx = ctx->num; | 1295 | dev->curr_ctx = ctx->num; |
1300 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1301 | s5p_mfc_init_decode_v5(ctx); | 1296 | s5p_mfc_init_decode_v5(ctx); |
1302 | } | 1297 | } |
1303 | 1298 | ||
@@ -1317,7 +1312,6 @@ static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx) | |||
1317 | s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); | 1312 | s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); |
1318 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1313 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1319 | dev->curr_ctx = ctx->num; | 1314 | dev->curr_ctx = ctx->num; |
1320 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1321 | s5p_mfc_init_encode_v5(ctx); | 1315 | s5p_mfc_init_encode_v5(ctx); |
1322 | } | 1316 | } |
1323 | 1317 | ||
@@ -1352,7 +1346,6 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx) | |||
1352 | 0, temp_vb->b->v4l2_planes[0].bytesused); | 1346 | 0, temp_vb->b->v4l2_planes[0].bytesused); |
1353 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1347 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1354 | dev->curr_ctx = ctx->num; | 1348 | dev->curr_ctx = ctx->num; |
1355 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1356 | ret = s5p_mfc_set_dec_frame_buffer_v5(ctx); | 1349 | ret = s5p_mfc_set_dec_frame_buffer_v5(ctx); |
1357 | if (ret) { | 1350 | if (ret) { |
1358 | mfc_err("Failed to alloc frame mem\n"); | 1351 | mfc_err("Failed to alloc frame mem\n"); |
@@ -1396,6 +1389,8 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev) | |||
1396 | * Now obtaining frames from MFC buffer | 1389 | * Now obtaining frames from MFC buffer |
1397 | */ | 1390 | */ |
1398 | s5p_mfc_clock_on(); | 1391 | s5p_mfc_clock_on(); |
1392 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1393 | |||
1399 | if (ctx->type == MFCINST_DECODER) { | 1394 | if (ctx->type == MFCINST_DECODER) { |
1400 | s5p_mfc_set_dec_desc_buffer(ctx); | 1395 | s5p_mfc_set_dec_desc_buffer(ctx); |
1401 | switch (ctx->state) { | 1396 | switch (ctx->state) { |
@@ -1406,12 +1401,10 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev) | |||
1406 | ret = s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME); | 1401 | ret = s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME); |
1407 | break; | 1402 | break; |
1408 | case MFCINST_INIT: | 1403 | case MFCINST_INIT: |
1409 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1410 | ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, | 1404 | ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, |
1411 | ctx); | 1405 | ctx); |
1412 | break; | 1406 | break; |
1413 | case MFCINST_RETURN_INST: | 1407 | case MFCINST_RETURN_INST: |
1414 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1415 | ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, | 1408 | ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, |
1416 | ctx); | 1409 | ctx); |
1417 | break; | 1410 | break; |
@@ -1444,12 +1437,10 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev) | |||
1444 | ret = s5p_mfc_run_enc_frame(ctx); | 1437 | ret = s5p_mfc_run_enc_frame(ctx); |
1445 | break; | 1438 | break; |
1446 | case MFCINST_INIT: | 1439 | case MFCINST_INIT: |
1447 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1448 | ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, | 1440 | ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, |
1449 | ctx); | 1441 | ctx); |
1450 | break; | 1442 | break; |
1451 | case MFCINST_RETURN_INST: | 1443 | case MFCINST_RETURN_INST: |
1452 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1453 | ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, | 1444 | ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, |
1454 | ctx); | 1445 | ctx); |
1455 | break; | 1446 | break; |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c index 8798b14bacce..9aea179943ce 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | |||
@@ -1394,7 +1394,6 @@ static inline void s5p_mfc_set_flush(struct s5p_mfc_ctx *ctx, int flush) | |||
1394 | 1394 | ||
1395 | if (flush) { | 1395 | if (flush) { |
1396 | dev->curr_ctx = ctx->num; | 1396 | dev->curr_ctx = ctx->num; |
1397 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1398 | writel(ctx->inst_no, mfc_regs->instance_id); | 1397 | writel(ctx->inst_no, mfc_regs->instance_id); |
1399 | s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, | 1398 | s5p_mfc_hw_call_void(dev->mfc_cmds, cmd_host2risc, dev, |
1400 | S5P_FIMV_H2R_CMD_FLUSH_V6, NULL); | 1399 | S5P_FIMV_H2R_CMD_FLUSH_V6, NULL); |
@@ -1532,27 +1531,10 @@ static inline int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev) | |||
1532 | static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx) | 1531 | static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx) |
1533 | { | 1532 | { |
1534 | struct s5p_mfc_dev *dev = ctx->dev; | 1533 | struct s5p_mfc_dev *dev = ctx->dev; |
1535 | struct s5p_mfc_buf *temp_vb; | ||
1536 | unsigned long flags; | ||
1537 | |||
1538 | spin_lock_irqsave(&dev->irqlock, flags); | ||
1539 | |||
1540 | /* Frames are being decoded */ | ||
1541 | if (list_empty(&ctx->src_queue)) { | ||
1542 | mfc_debug(2, "No src buffers.\n"); | ||
1543 | spin_unlock_irqrestore(&dev->irqlock, flags); | ||
1544 | return; | ||
1545 | } | ||
1546 | /* Get the next source buffer */ | ||
1547 | temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); | ||
1548 | temp_vb->flags |= MFC_BUF_FLAG_USED; | ||
1549 | s5p_mfc_set_dec_stream_buffer_v6(ctx, | ||
1550 | vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), 0, 0); | ||
1551 | spin_unlock_irqrestore(&dev->irqlock, flags); | ||
1552 | 1534 | ||
1535 | s5p_mfc_set_dec_stream_buffer_v6(ctx, 0, 0, 0); | ||
1553 | dev->curr_ctx = ctx->num; | 1536 | dev->curr_ctx = ctx->num; |
1554 | s5p_mfc_clean_ctx_int_flags(ctx); | 1537 | s5p_mfc_decode_one_frame_v6(ctx, MFC_DEC_LAST_FRAME); |
1555 | s5p_mfc_decode_one_frame_v6(ctx, 1); | ||
1556 | } | 1538 | } |
1557 | 1539 | ||
1558 | static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx) | 1540 | static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx) |
@@ -1588,7 +1570,6 @@ static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx) | |||
1588 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1570 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1589 | 1571 | ||
1590 | dev->curr_ctx = ctx->num; | 1572 | dev->curr_ctx = ctx->num; |
1591 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1592 | if (temp_vb->b->v4l2_planes[0].bytesused == 0) { | 1573 | if (temp_vb->b->v4l2_planes[0].bytesused == 0) { |
1593 | last_frame = 1; | 1574 | last_frame = 1; |
1594 | mfc_debug(2, "Setting ctx->state to FINISHING\n"); | 1575 | mfc_debug(2, "Setting ctx->state to FINISHING\n"); |
@@ -1645,7 +1626,6 @@ static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx) | |||
1645 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1626 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1646 | 1627 | ||
1647 | dev->curr_ctx = ctx->num; | 1628 | dev->curr_ctx = ctx->num; |
1648 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1649 | s5p_mfc_encode_one_frame_v6(ctx); | 1629 | s5p_mfc_encode_one_frame_v6(ctx); |
1650 | 1630 | ||
1651 | return 0; | 1631 | return 0; |
@@ -1667,7 +1647,6 @@ static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx) | |||
1667 | temp_vb->b->v4l2_planes[0].bytesused); | 1647 | temp_vb->b->v4l2_planes[0].bytesused); |
1668 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1648 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1669 | dev->curr_ctx = ctx->num; | 1649 | dev->curr_ctx = ctx->num; |
1670 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1671 | s5p_mfc_init_decode_v6(ctx); | 1650 | s5p_mfc_init_decode_v6(ctx); |
1672 | } | 1651 | } |
1673 | 1652 | ||
@@ -1687,7 +1666,6 @@ static inline void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx) | |||
1687 | s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size); | 1666 | s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size); |
1688 | spin_unlock_irqrestore(&dev->irqlock, flags); | 1667 | spin_unlock_irqrestore(&dev->irqlock, flags); |
1689 | dev->curr_ctx = ctx->num; | 1668 | dev->curr_ctx = ctx->num; |
1690 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1691 | s5p_mfc_init_encode_v6(ctx); | 1669 | s5p_mfc_init_encode_v6(ctx); |
1692 | } | 1670 | } |
1693 | 1671 | ||
@@ -1707,7 +1685,6 @@ static inline int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx) | |||
1707 | } | 1685 | } |
1708 | 1686 | ||
1709 | dev->curr_ctx = ctx->num; | 1687 | dev->curr_ctx = ctx->num; |
1710 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1711 | ret = s5p_mfc_set_dec_frame_buffer_v6(ctx); | 1688 | ret = s5p_mfc_set_dec_frame_buffer_v6(ctx); |
1712 | if (ret) { | 1689 | if (ret) { |
1713 | mfc_err("Failed to alloc frame mem.\n"); | 1690 | mfc_err("Failed to alloc frame mem.\n"); |
@@ -1722,7 +1699,6 @@ static inline int s5p_mfc_run_init_enc_buffers(struct s5p_mfc_ctx *ctx) | |||
1722 | int ret; | 1699 | int ret; |
1723 | 1700 | ||
1724 | dev->curr_ctx = ctx->num; | 1701 | dev->curr_ctx = ctx->num; |
1725 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1726 | ret = s5p_mfc_set_enc_ref_buffer_v6(ctx); | 1702 | ret = s5p_mfc_set_enc_ref_buffer_v6(ctx); |
1727 | if (ret) { | 1703 | if (ret) { |
1728 | mfc_err("Failed to alloc frame mem.\n"); | 1704 | mfc_err("Failed to alloc frame mem.\n"); |
@@ -1771,6 +1747,8 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev) | |||
1771 | * Now obtaining frames from MFC buffer */ | 1747 | * Now obtaining frames from MFC buffer */ |
1772 | 1748 | ||
1773 | s5p_mfc_clock_on(); | 1749 | s5p_mfc_clock_on(); |
1750 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1751 | |||
1774 | if (ctx->type == MFCINST_DECODER) { | 1752 | if (ctx->type == MFCINST_DECODER) { |
1775 | switch (ctx->state) { | 1753 | switch (ctx->state) { |
1776 | case MFCINST_FINISHING: | 1754 | case MFCINST_FINISHING: |
@@ -1780,12 +1758,10 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev) | |||
1780 | ret = s5p_mfc_run_dec_frame(ctx); | 1758 | ret = s5p_mfc_run_dec_frame(ctx); |
1781 | break; | 1759 | break; |
1782 | case MFCINST_INIT: | 1760 | case MFCINST_INIT: |
1783 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1784 | ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, | 1761 | ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, |
1785 | ctx); | 1762 | ctx); |
1786 | break; | 1763 | break; |
1787 | case MFCINST_RETURN_INST: | 1764 | case MFCINST_RETURN_INST: |
1788 | s5p_mfc_clean_ctx_int_flags(ctx); | ||
1789 | ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, | 1765 | ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, |
1790 | ctx); | 1766 | ctx); |
1791 | break; | 1767 | break; |
diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c index 37c8bd694c5f..1d1ef211e113 100644 --- a/drivers/media/platform/s5p-tv/hdmi_drv.c +++ b/drivers/media/platform/s5p-tv/hdmi_drv.c | |||
@@ -660,7 +660,7 @@ static int hdmi_g_mbus_fmt(struct v4l2_subdev *sd, | |||
660 | memset(fmt, 0, sizeof(*fmt)); | 660 | memset(fmt, 0, sizeof(*fmt)); |
661 | fmt->width = t->hact.end - t->hact.beg; | 661 | fmt->width = t->hact.end - t->hact.beg; |
662 | fmt->height = t->vact[0].end - t->vact[0].beg; | 662 | fmt->height = t->vact[0].end - t->vact[0].beg; |
663 | fmt->code = V4L2_MBUS_FMT_FIXED; /* means RGB888 */ | 663 | fmt->code = MEDIA_BUS_FMT_FIXED; /* means RGB888 */ |
664 | fmt->colorspace = V4L2_COLORSPACE_SRGB; | 664 | fmt->colorspace = V4L2_COLORSPACE_SRGB; |
665 | if (t->interlaced) { | 665 | if (t->interlaced) { |
666 | fmt->field = V4L2_FIELD_INTERLACED; | 666 | fmt->field = V4L2_FIELD_INTERLACED; |
diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c index 72cf892dd008..46f4d56aaa1b 100644 --- a/drivers/media/platform/s5p-tv/sdo_drv.c +++ b/drivers/media/platform/s5p-tv/sdo_drv.c | |||
@@ -170,7 +170,7 @@ static int sdo_g_mbus_fmt(struct v4l2_subdev *sd, | |||
170 | /* all modes are 720 pixels wide */ | 170 | /* all modes are 720 pixels wide */ |
171 | fmt->width = 720; | 171 | fmt->width = 720; |
172 | fmt->height = sdev->fmt->height; | 172 | fmt->height = sdev->fmt->height; |
173 | fmt->code = V4L2_MBUS_FMT_FIXED; | 173 | fmt->code = MEDIA_BUS_FMT_FIXED; |
174 | fmt->field = V4L2_FIELD_INTERLACED; | 174 | fmt->field = V4L2_FIELD_INTERLACED; |
175 | fmt->colorspace = V4L2_COLORSPACE_JPEG; | 175 | fmt->colorspace = V4L2_COLORSPACE_JPEG; |
176 | return 0; | 176 | return 0; |
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c index e5f1d4c14f2c..154ef0b6b8ab 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c | |||
@@ -396,7 +396,8 @@ static int sh_vou_querycap(struct file *file, void *priv, | |||
396 | dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); | 396 | dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); |
397 | 397 | ||
398 | strlcpy(cap->card, "SuperH VOU", sizeof(cap->card)); | 398 | strlcpy(cap->card, "SuperH VOU", sizeof(cap->card)); |
399 | cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; | 399 | cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; |
400 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
400 | return 0; | 401 | return 0; |
401 | } | 402 | } |
402 | 403 | ||
@@ -680,7 +681,7 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void *priv, | |||
680 | struct sh_vou_geometry geo; | 681 | struct sh_vou_geometry geo; |
681 | struct v4l2_mbus_framefmt mbfmt = { | 682 | struct v4l2_mbus_framefmt mbfmt = { |
682 | /* Revisit: is this the correct code? */ | 683 | /* Revisit: is this the correct code? */ |
683 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 684 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
684 | .field = V4L2_FIELD_INTERLACED, | 685 | .field = V4L2_FIELD_INTERLACED, |
685 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | 686 | .colorspace = V4L2_COLORSPACE_SMPTE170M, |
686 | }; | 687 | }; |
@@ -733,7 +734,7 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void *priv, | |||
733 | /* Sanity checks */ | 734 | /* Sanity checks */ |
734 | if ((unsigned)mbfmt.width > VOU_MAX_IMAGE_WIDTH || | 735 | if ((unsigned)mbfmt.width > VOU_MAX_IMAGE_WIDTH || |
735 | (unsigned)mbfmt.height > img_height_max || | 736 | (unsigned)mbfmt.height > img_height_max || |
736 | mbfmt.code != V4L2_MBUS_FMT_YUYV8_2X8) | 737 | mbfmt.code != MEDIA_BUS_FMT_YUYV8_2X8) |
737 | return -EIO; | 738 | return -EIO; |
738 | 739 | ||
739 | if (mbfmt.width != geo.output.width || | 740 | if (mbfmt.width != geo.output.width || |
@@ -943,7 +944,7 @@ static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) | |||
943 | struct sh_vou_geometry geo; | 944 | struct sh_vou_geometry geo; |
944 | struct v4l2_mbus_framefmt mbfmt = { | 945 | struct v4l2_mbus_framefmt mbfmt = { |
945 | /* Revisit: is this the correct code? */ | 946 | /* Revisit: is this the correct code? */ |
946 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 947 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
947 | .field = V4L2_FIELD_INTERLACED, | 948 | .field = V4L2_FIELD_INTERLACED, |
948 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | 949 | .colorspace = V4L2_COLORSPACE_SMPTE170M, |
949 | }; | 950 | }; |
@@ -994,7 +995,7 @@ static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) | |||
994 | /* Sanity checks */ | 995 | /* Sanity checks */ |
995 | if ((unsigned)mbfmt.width > VOU_MAX_IMAGE_WIDTH || | 996 | if ((unsigned)mbfmt.width > VOU_MAX_IMAGE_WIDTH || |
996 | (unsigned)mbfmt.height > img_height_max || | 997 | (unsigned)mbfmt.height > img_height_max || |
997 | mbfmt.code != V4L2_MBUS_FMT_YUYV8_2X8) | 998 | mbfmt.code != MEDIA_BUS_FMT_YUYV8_2X8) |
998 | return -EIO; | 999 | return -EIO; |
999 | 1000 | ||
1000 | geo.output.width = mbfmt.width; | 1001 | geo.output.width = mbfmt.width; |
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index c5291b001057..ee5650f4ea2d 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c | |||
@@ -105,25 +105,25 @@ static u32 isi_readl(struct atmel_isi *isi, u32 reg) | |||
105 | } | 105 | } |
106 | 106 | ||
107 | static int configure_geometry(struct atmel_isi *isi, u32 width, | 107 | static int configure_geometry(struct atmel_isi *isi, u32 width, |
108 | u32 height, enum v4l2_mbus_pixelcode code) | 108 | u32 height, u32 code) |
109 | { | 109 | { |
110 | u32 cfg2, cr; | 110 | u32 cfg2, cr; |
111 | 111 | ||
112 | switch (code) { | 112 | switch (code) { |
113 | /* YUV, including grey */ | 113 | /* YUV, including grey */ |
114 | case V4L2_MBUS_FMT_Y8_1X8: | 114 | case MEDIA_BUS_FMT_Y8_1X8: |
115 | cr = ISI_CFG2_GRAYSCALE; | 115 | cr = ISI_CFG2_GRAYSCALE; |
116 | break; | 116 | break; |
117 | case V4L2_MBUS_FMT_VYUY8_2X8: | 117 | case MEDIA_BUS_FMT_VYUY8_2X8: |
118 | cr = ISI_CFG2_YCC_SWAP_MODE_3; | 118 | cr = ISI_CFG2_YCC_SWAP_MODE_3; |
119 | break; | 119 | break; |
120 | case V4L2_MBUS_FMT_UYVY8_2X8: | 120 | case MEDIA_BUS_FMT_UYVY8_2X8: |
121 | cr = ISI_CFG2_YCC_SWAP_MODE_2; | 121 | cr = ISI_CFG2_YCC_SWAP_MODE_2; |
122 | break; | 122 | break; |
123 | case V4L2_MBUS_FMT_YVYU8_2X8: | 123 | case MEDIA_BUS_FMT_YVYU8_2X8: |
124 | cr = ISI_CFG2_YCC_SWAP_MODE_1; | 124 | cr = ISI_CFG2_YCC_SWAP_MODE_1; |
125 | break; | 125 | break; |
126 | case V4L2_MBUS_FMT_YUYV8_2X8: | 126 | case MEDIA_BUS_FMT_YUYV8_2X8: |
127 | cr = ISI_CFG2_YCC_SWAP_DEFAULT; | 127 | cr = ISI_CFG2_YCC_SWAP_DEFAULT; |
128 | break; | 128 | break; |
129 | /* RGB, TODO */ | 129 | /* RGB, TODO */ |
@@ -645,7 +645,7 @@ static int isi_camera_get_formats(struct soc_camera_device *icd, | |||
645 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 645 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
646 | int formats = 0, ret; | 646 | int formats = 0, ret; |
647 | /* sensor format */ | 647 | /* sensor format */ |
648 | enum v4l2_mbus_pixelcode code; | 648 | u32 code; |
649 | /* soc camera host format */ | 649 | /* soc camera host format */ |
650 | const struct soc_mbus_pixelfmt *fmt; | 650 | const struct soc_mbus_pixelfmt *fmt; |
651 | 651 | ||
@@ -670,10 +670,10 @@ static int isi_camera_get_formats(struct soc_camera_device *icd, | |||
670 | } | 670 | } |
671 | 671 | ||
672 | switch (code) { | 672 | switch (code) { |
673 | case V4L2_MBUS_FMT_UYVY8_2X8: | 673 | case MEDIA_BUS_FMT_UYVY8_2X8: |
674 | case V4L2_MBUS_FMT_VYUY8_2X8: | 674 | case MEDIA_BUS_FMT_VYUY8_2X8: |
675 | case V4L2_MBUS_FMT_YUYV8_2X8: | 675 | case MEDIA_BUS_FMT_YUYV8_2X8: |
676 | case V4L2_MBUS_FMT_YVYU8_2X8: | 676 | case MEDIA_BUS_FMT_YVYU8_2X8: |
677 | formats++; | 677 | formats++; |
678 | if (xlate) { | 678 | if (xlate) { |
679 | xlate->host_fmt = &isi_camera_formats[0]; | 679 | xlate->host_fmt = &isi_camera_formats[0]; |
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 2347612a4cc1..ce72bd26a6ac 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c | |||
@@ -211,7 +211,7 @@ struct emma_prp_resize { | |||
211 | 211 | ||
212 | /* prp configuration for a client-host fmt pair */ | 212 | /* prp configuration for a client-host fmt pair */ |
213 | struct mx2_fmt_cfg { | 213 | struct mx2_fmt_cfg { |
214 | enum v4l2_mbus_pixelcode in_fmt; | 214 | u32 in_fmt; |
215 | u32 out_fmt; | 215 | u32 out_fmt; |
216 | struct mx2_prp_cfg cfg; | 216 | struct mx2_prp_cfg cfg; |
217 | }; | 217 | }; |
@@ -309,7 +309,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { | |||
309 | } | 309 | } |
310 | }, | 310 | }, |
311 | { | 311 | { |
312 | .in_fmt = V4L2_MBUS_FMT_UYVY8_2X8, | 312 | .in_fmt = MEDIA_BUS_FMT_UYVY8_2X8, |
313 | .out_fmt = V4L2_PIX_FMT_YUYV, | 313 | .out_fmt = V4L2_PIX_FMT_YUYV, |
314 | .cfg = { | 314 | .cfg = { |
315 | .channel = 1, | 315 | .channel = 1, |
@@ -323,7 +323,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { | |||
323 | } | 323 | } |
324 | }, | 324 | }, |
325 | { | 325 | { |
326 | .in_fmt = V4L2_MBUS_FMT_YUYV8_2X8, | 326 | .in_fmt = MEDIA_BUS_FMT_YUYV8_2X8, |
327 | .out_fmt = V4L2_PIX_FMT_YUYV, | 327 | .out_fmt = V4L2_PIX_FMT_YUYV, |
328 | .cfg = { | 328 | .cfg = { |
329 | .channel = 1, | 329 | .channel = 1, |
@@ -337,7 +337,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { | |||
337 | } | 337 | } |
338 | }, | 338 | }, |
339 | { | 339 | { |
340 | .in_fmt = V4L2_MBUS_FMT_YUYV8_2X8, | 340 | .in_fmt = MEDIA_BUS_FMT_YUYV8_2X8, |
341 | .out_fmt = V4L2_PIX_FMT_YUV420, | 341 | .out_fmt = V4L2_PIX_FMT_YUV420, |
342 | .cfg = { | 342 | .cfg = { |
343 | .channel = 2, | 343 | .channel = 2, |
@@ -351,7 +351,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { | |||
351 | } | 351 | } |
352 | }, | 352 | }, |
353 | { | 353 | { |
354 | .in_fmt = V4L2_MBUS_FMT_UYVY8_2X8, | 354 | .in_fmt = MEDIA_BUS_FMT_UYVY8_2X8, |
355 | .out_fmt = V4L2_PIX_FMT_YUV420, | 355 | .out_fmt = V4L2_PIX_FMT_YUV420, |
356 | .cfg = { | 356 | .cfg = { |
357 | .channel = 2, | 357 | .channel = 2, |
@@ -366,9 +366,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { | |||
366 | }, | 366 | }, |
367 | }; | 367 | }; |
368 | 368 | ||
369 | static struct mx2_fmt_cfg *mx27_emma_prp_get_format( | 369 | static struct mx2_fmt_cfg *mx27_emma_prp_get_format(u32 in_fmt, u32 out_fmt) |
370 | enum v4l2_mbus_pixelcode in_fmt, | ||
371 | u32 out_fmt) | ||
372 | { | 370 | { |
373 | int i; | 371 | int i; |
374 | 372 | ||
@@ -945,7 +943,7 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, | |||
945 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 943 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
946 | const struct soc_mbus_pixelfmt *fmt; | 944 | const struct soc_mbus_pixelfmt *fmt; |
947 | struct device *dev = icd->parent; | 945 | struct device *dev = icd->parent; |
948 | enum v4l2_mbus_pixelcode code; | 946 | u32 code; |
949 | int ret, formats = 0; | 947 | int ret, formats = 0; |
950 | 948 | ||
951 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); | 949 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); |
@@ -959,8 +957,8 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, | |||
959 | return 0; | 957 | return 0; |
960 | } | 958 | } |
961 | 959 | ||
962 | if (code == V4L2_MBUS_FMT_YUYV8_2X8 || | 960 | if (code == MEDIA_BUS_FMT_YUYV8_2X8 || |
963 | code == V4L2_MBUS_FMT_UYVY8_2X8) { | 961 | code == MEDIA_BUS_FMT_UYVY8_2X8) { |
964 | formats++; | 962 | formats++; |
965 | if (xlate) { | 963 | if (xlate) { |
966 | /* | 964 | /* |
@@ -968,7 +966,7 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, | |||
968 | * soc_mediabus.c | 966 | * soc_mediabus.c |
969 | */ | 967 | */ |
970 | xlate->host_fmt = | 968 | xlate->host_fmt = |
971 | soc_mbus_get_fmtdesc(V4L2_MBUS_FMT_YUYV8_1_5X8); | 969 | soc_mbus_get_fmtdesc(MEDIA_BUS_FMT_YUYV8_1_5X8); |
972 | xlate->code = code; | 970 | xlate->code = code; |
973 | dev_dbg(dev, "Providing host format %s for sensor code %d\n", | 971 | dev_dbg(dev, "Providing host format %s for sensor code %d\n", |
974 | xlate->host_fmt->name, code); | 972 | xlate->host_fmt->name, code); |
@@ -976,11 +974,11 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, | |||
976 | } | 974 | } |
977 | } | 975 | } |
978 | 976 | ||
979 | if (code == V4L2_MBUS_FMT_UYVY8_2X8) { | 977 | if (code == MEDIA_BUS_FMT_UYVY8_2X8) { |
980 | formats++; | 978 | formats++; |
981 | if (xlate) { | 979 | if (xlate) { |
982 | xlate->host_fmt = | 980 | xlate->host_fmt = |
983 | soc_mbus_get_fmtdesc(V4L2_MBUS_FMT_YUYV8_2X8); | 981 | soc_mbus_get_fmtdesc(MEDIA_BUS_FMT_YUYV8_2X8); |
984 | xlate->code = code; | 982 | xlate->code = code; |
985 | dev_dbg(dev, "Providing host format %s for sensor code %d\n", | 983 | dev_dbg(dev, "Providing host format %s for sensor code %d\n", |
986 | xlate->host_fmt->name, code); | 984 | xlate->host_fmt->name, code); |
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 7696a873510d..8e52ccce66de 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c | |||
@@ -656,7 +656,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id | |||
656 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 656 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
657 | struct device *dev = icd->parent; | 657 | struct device *dev = icd->parent; |
658 | int formats = 0, ret; | 658 | int formats = 0, ret; |
659 | enum v4l2_mbus_pixelcode code; | 659 | u32 code; |
660 | const struct soc_mbus_pixelfmt *fmt; | 660 | const struct soc_mbus_pixelfmt *fmt; |
661 | 661 | ||
662 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); | 662 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); |
@@ -677,7 +677,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id | |||
677 | return 0; | 677 | return 0; |
678 | 678 | ||
679 | switch (code) { | 679 | switch (code) { |
680 | case V4L2_MBUS_FMT_SBGGR10_1X10: | 680 | case MEDIA_BUS_FMT_SBGGR10_1X10: |
681 | formats++; | 681 | formats++; |
682 | if (xlate) { | 682 | if (xlate) { |
683 | xlate->host_fmt = &mx3_camera_formats[0]; | 683 | xlate->host_fmt = &mx3_camera_formats[0]; |
@@ -687,7 +687,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id | |||
687 | mx3_camera_formats[0].name, code); | 687 | mx3_camera_formats[0].name, code); |
688 | } | 688 | } |
689 | break; | 689 | break; |
690 | case V4L2_MBUS_FMT_Y10_1X10: | 690 | case MEDIA_BUS_FMT_Y10_1X10: |
691 | formats++; | 691 | formats++; |
692 | if (xlate) { | 692 | if (xlate) { |
693 | xlate->host_fmt = &mx3_camera_formats[1]; | 693 | xlate->host_fmt = &mx3_camera_formats[1]; |
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c index 74ce8b6b79fa..e6b93281f246 100644 --- a/drivers/media/platform/soc_camera/omap1_camera.c +++ b/drivers/media/platform/soc_camera/omap1_camera.c | |||
@@ -140,7 +140,7 @@ | |||
140 | /* buffer for one video frame */ | 140 | /* buffer for one video frame */ |
141 | struct omap1_cam_buf { | 141 | struct omap1_cam_buf { |
142 | struct videobuf_buffer vb; | 142 | struct videobuf_buffer vb; |
143 | enum v4l2_mbus_pixelcode code; | 143 | u32 code; |
144 | int inwork; | 144 | int inwork; |
145 | struct scatterlist *sgbuf; | 145 | struct scatterlist *sgbuf; |
146 | int sgcount; | 146 | int sgcount; |
@@ -980,7 +980,7 @@ static void omap1_cam_clock_stop(struct soc_camera_host *ici) | |||
980 | /* Duplicate standard formats based on host capability of byte swapping */ | 980 | /* Duplicate standard formats based on host capability of byte swapping */ |
981 | static const struct soc_mbus_lookup omap1_cam_formats[] = { | 981 | static const struct soc_mbus_lookup omap1_cam_formats[] = { |
982 | { | 982 | { |
983 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 983 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
984 | .fmt = { | 984 | .fmt = { |
985 | .fourcc = V4L2_PIX_FMT_YUYV, | 985 | .fourcc = V4L2_PIX_FMT_YUYV, |
986 | .name = "YUYV", | 986 | .name = "YUYV", |
@@ -990,7 +990,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
990 | .layout = SOC_MBUS_LAYOUT_PACKED, | 990 | .layout = SOC_MBUS_LAYOUT_PACKED, |
991 | }, | 991 | }, |
992 | }, { | 992 | }, { |
993 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 993 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
994 | .fmt = { | 994 | .fmt = { |
995 | .fourcc = V4L2_PIX_FMT_YVYU, | 995 | .fourcc = V4L2_PIX_FMT_YVYU, |
996 | .name = "YVYU", | 996 | .name = "YVYU", |
@@ -1000,7 +1000,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
1000 | .layout = SOC_MBUS_LAYOUT_PACKED, | 1000 | .layout = SOC_MBUS_LAYOUT_PACKED, |
1001 | }, | 1001 | }, |
1002 | }, { | 1002 | }, { |
1003 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 1003 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
1004 | .fmt = { | 1004 | .fmt = { |
1005 | .fourcc = V4L2_PIX_FMT_UYVY, | 1005 | .fourcc = V4L2_PIX_FMT_UYVY, |
1006 | .name = "UYVY", | 1006 | .name = "UYVY", |
@@ -1010,7 +1010,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
1010 | .layout = SOC_MBUS_LAYOUT_PACKED, | 1010 | .layout = SOC_MBUS_LAYOUT_PACKED, |
1011 | }, | 1011 | }, |
1012 | }, { | 1012 | }, { |
1013 | .code = V4L2_MBUS_FMT_YVYU8_2X8, | 1013 | .code = MEDIA_BUS_FMT_YVYU8_2X8, |
1014 | .fmt = { | 1014 | .fmt = { |
1015 | .fourcc = V4L2_PIX_FMT_VYUY, | 1015 | .fourcc = V4L2_PIX_FMT_VYUY, |
1016 | .name = "VYUY", | 1016 | .name = "VYUY", |
@@ -1020,7 +1020,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
1020 | .layout = SOC_MBUS_LAYOUT_PACKED, | 1020 | .layout = SOC_MBUS_LAYOUT_PACKED, |
1021 | }, | 1021 | }, |
1022 | }, { | 1022 | }, { |
1023 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, | 1023 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, |
1024 | .fmt = { | 1024 | .fmt = { |
1025 | .fourcc = V4L2_PIX_FMT_RGB555, | 1025 | .fourcc = V4L2_PIX_FMT_RGB555, |
1026 | .name = "RGB555", | 1026 | .name = "RGB555", |
@@ -1030,7 +1030,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
1030 | .layout = SOC_MBUS_LAYOUT_PACKED, | 1030 | .layout = SOC_MBUS_LAYOUT_PACKED, |
1031 | }, | 1031 | }, |
1032 | }, { | 1032 | }, { |
1033 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, | 1033 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, |
1034 | .fmt = { | 1034 | .fmt = { |
1035 | .fourcc = V4L2_PIX_FMT_RGB555X, | 1035 | .fourcc = V4L2_PIX_FMT_RGB555X, |
1036 | .name = "RGB555X", | 1036 | .name = "RGB555X", |
@@ -1040,7 +1040,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
1040 | .layout = SOC_MBUS_LAYOUT_PACKED, | 1040 | .layout = SOC_MBUS_LAYOUT_PACKED, |
1041 | }, | 1041 | }, |
1042 | }, { | 1042 | }, { |
1043 | .code = V4L2_MBUS_FMT_RGB565_2X8_BE, | 1043 | .code = MEDIA_BUS_FMT_RGB565_2X8_BE, |
1044 | .fmt = { | 1044 | .fmt = { |
1045 | .fourcc = V4L2_PIX_FMT_RGB565, | 1045 | .fourcc = V4L2_PIX_FMT_RGB565, |
1046 | .name = "RGB565", | 1046 | .name = "RGB565", |
@@ -1050,7 +1050,7 @@ static const struct soc_mbus_lookup omap1_cam_formats[] = { | |||
1050 | .layout = SOC_MBUS_LAYOUT_PACKED, | 1050 | .layout = SOC_MBUS_LAYOUT_PACKED, |
1051 | }, | 1051 | }, |
1052 | }, { | 1052 | }, { |
1053 | .code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 1053 | .code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
1054 | .fmt = { | 1054 | .fmt = { |
1055 | .fourcc = V4L2_PIX_FMT_RGB565X, | 1055 | .fourcc = V4L2_PIX_FMT_RGB565X, |
1056 | .name = "RGB565X", | 1056 | .name = "RGB565X", |
@@ -1068,7 +1068,7 @@ static int omap1_cam_get_formats(struct soc_camera_device *icd, | |||
1068 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 1068 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
1069 | struct device *dev = icd->parent; | 1069 | struct device *dev = icd->parent; |
1070 | int formats = 0, ret; | 1070 | int formats = 0, ret; |
1071 | enum v4l2_mbus_pixelcode code; | 1071 | u32 code; |
1072 | const struct soc_mbus_pixelfmt *fmt; | 1072 | const struct soc_mbus_pixelfmt *fmt; |
1073 | 1073 | ||
1074 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); | 1074 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); |
@@ -1088,14 +1088,14 @@ static int omap1_cam_get_formats(struct soc_camera_device *icd, | |||
1088 | return 0; | 1088 | return 0; |
1089 | 1089 | ||
1090 | switch (code) { | 1090 | switch (code) { |
1091 | case V4L2_MBUS_FMT_YUYV8_2X8: | 1091 | case MEDIA_BUS_FMT_YUYV8_2X8: |
1092 | case V4L2_MBUS_FMT_YVYU8_2X8: | 1092 | case MEDIA_BUS_FMT_YVYU8_2X8: |
1093 | case V4L2_MBUS_FMT_UYVY8_2X8: | 1093 | case MEDIA_BUS_FMT_UYVY8_2X8: |
1094 | case V4L2_MBUS_FMT_VYUY8_2X8: | 1094 | case MEDIA_BUS_FMT_VYUY8_2X8: |
1095 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE: | 1095 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE: |
1096 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: | 1096 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE: |
1097 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 1097 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
1098 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 1098 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
1099 | formats++; | 1099 | formats++; |
1100 | if (xlate) { | 1100 | if (xlate) { |
1101 | xlate->host_fmt = soc_mbus_find_fmtdesc(code, | 1101 | xlate->host_fmt = soc_mbus_find_fmtdesc(code, |
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c index 66178fc9f9eb..951226af0eba 100644 --- a/drivers/media/platform/soc_camera/pxa_camera.c +++ b/drivers/media/platform/soc_camera/pxa_camera.c | |||
@@ -187,7 +187,7 @@ struct pxa_cam_dma { | |||
187 | struct pxa_buffer { | 187 | struct pxa_buffer { |
188 | /* common v4l buffer stuff -- must be first */ | 188 | /* common v4l buffer stuff -- must be first */ |
189 | struct videobuf_buffer vb; | 189 | struct videobuf_buffer vb; |
190 | enum v4l2_mbus_pixelcode code; | 190 | u32 code; |
191 | /* our descriptor lists for Y, U and V channels */ | 191 | /* our descriptor lists for Y, U and V channels */ |
192 | struct pxa_cam_dma dmas[3]; | 192 | struct pxa_cam_dma dmas[3]; |
193 | int inwork; | 193 | int inwork; |
@@ -1253,7 +1253,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, unsigned int id | |||
1253 | struct device *dev = icd->parent; | 1253 | struct device *dev = icd->parent; |
1254 | int formats = 0, ret; | 1254 | int formats = 0, ret; |
1255 | struct pxa_cam *cam; | 1255 | struct pxa_cam *cam; |
1256 | enum v4l2_mbus_pixelcode code; | 1256 | u32 code; |
1257 | const struct soc_mbus_pixelfmt *fmt; | 1257 | const struct soc_mbus_pixelfmt *fmt; |
1258 | 1258 | ||
1259 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); | 1259 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); |
@@ -1283,7 +1283,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, unsigned int id | |||
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | switch (code) { | 1285 | switch (code) { |
1286 | case V4L2_MBUS_FMT_UYVY8_2X8: | 1286 | case MEDIA_BUS_FMT_UYVY8_2X8: |
1287 | formats++; | 1287 | formats++; |
1288 | if (xlate) { | 1288 | if (xlate) { |
1289 | xlate->host_fmt = &pxa_camera_formats[0]; | 1289 | xlate->host_fmt = &pxa_camera_formats[0]; |
@@ -1292,11 +1292,11 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, unsigned int id | |||
1292 | dev_dbg(dev, "Providing format %s using code %d\n", | 1292 | dev_dbg(dev, "Providing format %s using code %d\n", |
1293 | pxa_camera_formats[0].name, code); | 1293 | pxa_camera_formats[0].name, code); |
1294 | } | 1294 | } |
1295 | case V4L2_MBUS_FMT_VYUY8_2X8: | 1295 | case MEDIA_BUS_FMT_VYUY8_2X8: |
1296 | case V4L2_MBUS_FMT_YUYV8_2X8: | 1296 | case MEDIA_BUS_FMT_YUYV8_2X8: |
1297 | case V4L2_MBUS_FMT_YVYU8_2X8: | 1297 | case MEDIA_BUS_FMT_YVYU8_2X8: |
1298 | case V4L2_MBUS_FMT_RGB565_2X8_LE: | 1298 | case MEDIA_BUS_FMT_RGB565_2X8_LE: |
1299 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: | 1299 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE: |
1300 | if (xlate) | 1300 | if (xlate) |
1301 | dev_dbg(dev, "Providing format %s packed\n", | 1301 | dev_dbg(dev, "Providing format %s packed\n", |
1302 | fmt->name); | 1302 | fmt->name); |
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 20defcb8b31b..8d8438b10b87 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c | |||
@@ -272,16 +272,16 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv) | |||
272 | 272 | ||
273 | /* input interface */ | 273 | /* input interface */ |
274 | switch (icd->current_fmt->code) { | 274 | switch (icd->current_fmt->code) { |
275 | case V4L2_MBUS_FMT_YUYV8_1X16: | 275 | case MEDIA_BUS_FMT_YUYV8_1X16: |
276 | /* BT.601/BT.1358 16bit YCbCr422 */ | 276 | /* BT.601/BT.1358 16bit YCbCr422 */ |
277 | vnmc |= VNMC_INF_YUV16; | 277 | vnmc |= VNMC_INF_YUV16; |
278 | break; | 278 | break; |
279 | case V4L2_MBUS_FMT_YUYV8_2X8: | 279 | case MEDIA_BUS_FMT_YUYV8_2X8: |
280 | /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ | 280 | /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ |
281 | vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ? | 281 | vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ? |
282 | VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; | 282 | VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; |
283 | break; | 283 | break; |
284 | case V4L2_MBUS_FMT_YUYV10_2X10: | 284 | case MEDIA_BUS_FMT_YUYV10_2X10: |
285 | /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */ | 285 | /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */ |
286 | vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ? | 286 | vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ? |
287 | VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601; | 287 | VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601; |
@@ -921,7 +921,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, | |||
921 | int ret, k, n; | 921 | int ret, k, n; |
922 | int formats = 0; | 922 | int formats = 0; |
923 | struct rcar_vin_cam *cam; | 923 | struct rcar_vin_cam *cam; |
924 | enum v4l2_mbus_pixelcode code; | 924 | u32 code; |
925 | const struct soc_mbus_pixelfmt *fmt; | 925 | const struct soc_mbus_pixelfmt *fmt; |
926 | 926 | ||
927 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); | 927 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); |
@@ -1010,9 +1010,9 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, | |||
1010 | cam->extra_fmt = NULL; | 1010 | cam->extra_fmt = NULL; |
1011 | 1011 | ||
1012 | switch (code) { | 1012 | switch (code) { |
1013 | case V4L2_MBUS_FMT_YUYV8_1X16: | 1013 | case MEDIA_BUS_FMT_YUYV8_1X16: |
1014 | case V4L2_MBUS_FMT_YUYV8_2X8: | 1014 | case MEDIA_BUS_FMT_YUYV8_2X8: |
1015 | case V4L2_MBUS_FMT_YUYV10_2X10: | 1015 | case MEDIA_BUS_FMT_YUYV10_2X10: |
1016 | if (cam->extra_fmt) | 1016 | if (cam->extra_fmt) |
1017 | break; | 1017 | break; |
1018 | 1018 | ||
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index 20ad4a571d37..5f58ed995320 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | |||
@@ -149,7 +149,7 @@ struct sh_mobile_ceu_cam { | |||
149 | /* Camera cropping rectangle */ | 149 | /* Camera cropping rectangle */ |
150 | struct v4l2_rect rect; | 150 | struct v4l2_rect rect; |
151 | const struct soc_mbus_pixelfmt *extra_fmt; | 151 | const struct soc_mbus_pixelfmt *extra_fmt; |
152 | enum v4l2_mbus_pixelcode code; | 152 | u32 code; |
153 | }; | 153 | }; |
154 | 154 | ||
155 | static struct sh_mobile_ceu_buffer *to_ceu_vb(struct vb2_buffer *vb) | 155 | static struct sh_mobile_ceu_buffer *to_ceu_vb(struct vb2_buffer *vb) |
@@ -861,16 +861,16 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) | |||
861 | case V4L2_PIX_FMT_NV16: | 861 | case V4L2_PIX_FMT_NV16: |
862 | case V4L2_PIX_FMT_NV61: | 862 | case V4L2_PIX_FMT_NV61: |
863 | switch (cam->code) { | 863 | switch (cam->code) { |
864 | case V4L2_MBUS_FMT_UYVY8_2X8: | 864 | case MEDIA_BUS_FMT_UYVY8_2X8: |
865 | value = 0x00000000; /* Cb0, Y0, Cr0, Y1 */ | 865 | value = 0x00000000; /* Cb0, Y0, Cr0, Y1 */ |
866 | break; | 866 | break; |
867 | case V4L2_MBUS_FMT_VYUY8_2X8: | 867 | case MEDIA_BUS_FMT_VYUY8_2X8: |
868 | value = 0x00000100; /* Cr0, Y0, Cb0, Y1 */ | 868 | value = 0x00000100; /* Cr0, Y0, Cb0, Y1 */ |
869 | break; | 869 | break; |
870 | case V4L2_MBUS_FMT_YUYV8_2X8: | 870 | case MEDIA_BUS_FMT_YUYV8_2X8: |
871 | value = 0x00000200; /* Y0, Cb0, Y1, Cr0 */ | 871 | value = 0x00000200; /* Y0, Cb0, Y1, Cr0 */ |
872 | break; | 872 | break; |
873 | case V4L2_MBUS_FMT_YVYU8_2X8: | 873 | case MEDIA_BUS_FMT_YVYU8_2X8: |
874 | value = 0x00000300; /* Y0, Cr0, Y1, Cb0 */ | 874 | value = 0x00000300; /* Y0, Cr0, Y1, Cb0 */ |
875 | break; | 875 | break; |
876 | default: | 876 | default: |
@@ -1048,7 +1048,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int | |||
1048 | int ret, k, n; | 1048 | int ret, k, n; |
1049 | int formats = 0; | 1049 | int formats = 0; |
1050 | struct sh_mobile_ceu_cam *cam; | 1050 | struct sh_mobile_ceu_cam *cam; |
1051 | enum v4l2_mbus_pixelcode code; | 1051 | u32 code; |
1052 | const struct soc_mbus_pixelfmt *fmt; | 1052 | const struct soc_mbus_pixelfmt *fmt; |
1053 | 1053 | ||
1054 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); | 1054 | ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); |
@@ -1141,10 +1141,10 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int | |||
1141 | cam->extra_fmt = NULL; | 1141 | cam->extra_fmt = NULL; |
1142 | 1142 | ||
1143 | switch (code) { | 1143 | switch (code) { |
1144 | case V4L2_MBUS_FMT_UYVY8_2X8: | 1144 | case MEDIA_BUS_FMT_UYVY8_2X8: |
1145 | case V4L2_MBUS_FMT_VYUY8_2X8: | 1145 | case MEDIA_BUS_FMT_VYUY8_2X8: |
1146 | case V4L2_MBUS_FMT_YUYV8_2X8: | 1146 | case MEDIA_BUS_FMT_YUYV8_2X8: |
1147 | case V4L2_MBUS_FMT_YVYU8_2X8: | 1147 | case MEDIA_BUS_FMT_YVYU8_2X8: |
1148 | if (cam->extra_fmt) | 1148 | if (cam->extra_fmt) |
1149 | break; | 1149 | break; |
1150 | 1150 | ||
diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c b/drivers/media/platform/soc_camera/sh_mobile_csi2.c index 05dd21a35d63..c738e27a75d7 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c +++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c | |||
@@ -59,28 +59,28 @@ static int sh_csi2_try_fmt(struct v4l2_subdev *sd, | |||
59 | switch (pdata->type) { | 59 | switch (pdata->type) { |
60 | case SH_CSI2C: | 60 | case SH_CSI2C: |
61 | switch (mf->code) { | 61 | switch (mf->code) { |
62 | case V4L2_MBUS_FMT_UYVY8_2X8: /* YUV422 */ | 62 | case MEDIA_BUS_FMT_UYVY8_2X8: /* YUV422 */ |
63 | case V4L2_MBUS_FMT_YUYV8_1_5X8: /* YUV420 */ | 63 | case MEDIA_BUS_FMT_YUYV8_1_5X8: /* YUV420 */ |
64 | case V4L2_MBUS_FMT_Y8_1X8: /* RAW8 */ | 64 | case MEDIA_BUS_FMT_Y8_1X8: /* RAW8 */ |
65 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 65 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
66 | case V4L2_MBUS_FMT_SGRBG8_1X8: | 66 | case MEDIA_BUS_FMT_SGRBG8_1X8: |
67 | break; | 67 | break; |
68 | default: | 68 | default: |
69 | /* All MIPI CSI-2 devices must support one of primary formats */ | 69 | /* All MIPI CSI-2 devices must support one of primary formats */ |
70 | mf->code = V4L2_MBUS_FMT_YUYV8_2X8; | 70 | mf->code = MEDIA_BUS_FMT_YUYV8_2X8; |
71 | } | 71 | } |
72 | break; | 72 | break; |
73 | case SH_CSI2I: | 73 | case SH_CSI2I: |
74 | switch (mf->code) { | 74 | switch (mf->code) { |
75 | case V4L2_MBUS_FMT_Y8_1X8: /* RAW8 */ | 75 | case MEDIA_BUS_FMT_Y8_1X8: /* RAW8 */ |
76 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 76 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
77 | case V4L2_MBUS_FMT_SGRBG8_1X8: | 77 | case MEDIA_BUS_FMT_SGRBG8_1X8: |
78 | case V4L2_MBUS_FMT_SBGGR10_1X10: /* RAW10 */ | 78 | case MEDIA_BUS_FMT_SBGGR10_1X10: /* RAW10 */ |
79 | case V4L2_MBUS_FMT_SBGGR12_1X12: /* RAW12 */ | 79 | case MEDIA_BUS_FMT_SBGGR12_1X12: /* RAW12 */ |
80 | break; | 80 | break; |
81 | default: | 81 | default: |
82 | /* All MIPI CSI-2 devices must support one of primary formats */ | 82 | /* All MIPI CSI-2 devices must support one of primary formats */ |
83 | mf->code = V4L2_MBUS_FMT_SBGGR8_1X8; | 83 | mf->code = MEDIA_BUS_FMT_SBGGR8_1X8; |
84 | } | 84 | } |
85 | break; | 85 | break; |
86 | } | 86 | } |
@@ -104,21 +104,21 @@ static int sh_csi2_s_fmt(struct v4l2_subdev *sd, | |||
104 | return -EINVAL; | 104 | return -EINVAL; |
105 | 105 | ||
106 | switch (mf->code) { | 106 | switch (mf->code) { |
107 | case V4L2_MBUS_FMT_UYVY8_2X8: | 107 | case MEDIA_BUS_FMT_UYVY8_2X8: |
108 | tmp |= 0x1e; /* YUV422 8 bit */ | 108 | tmp |= 0x1e; /* YUV422 8 bit */ |
109 | break; | 109 | break; |
110 | case V4L2_MBUS_FMT_YUYV8_1_5X8: | 110 | case MEDIA_BUS_FMT_YUYV8_1_5X8: |
111 | tmp |= 0x18; /* YUV420 8 bit */ | 111 | tmp |= 0x18; /* YUV420 8 bit */ |
112 | break; | 112 | break; |
113 | case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE: | 113 | case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE: |
114 | tmp |= 0x21; /* RGB555 */ | 114 | tmp |= 0x21; /* RGB555 */ |
115 | break; | 115 | break; |
116 | case V4L2_MBUS_FMT_RGB565_2X8_BE: | 116 | case MEDIA_BUS_FMT_RGB565_2X8_BE: |
117 | tmp |= 0x22; /* RGB565 */ | 117 | tmp |= 0x22; /* RGB565 */ |
118 | break; | 118 | break; |
119 | case V4L2_MBUS_FMT_Y8_1X8: | 119 | case MEDIA_BUS_FMT_Y8_1X8: |
120 | case V4L2_MBUS_FMT_SBGGR8_1X8: | 120 | case MEDIA_BUS_FMT_SBGGR8_1X8: |
121 | case V4L2_MBUS_FMT_SGRBG8_1X8: | 121 | case MEDIA_BUS_FMT_SGRBG8_1X8: |
122 | tmp |= 0x2a; /* RAW8 */ | 122 | tmp |= 0x2a; /* RAW8 */ |
123 | break; | 123 | break; |
124 | default: | 124 | default: |
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 8e61b976da19..f4be2a1c659a 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c | |||
@@ -460,7 +460,7 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd) | |||
460 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 460 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
461 | unsigned int i, fmts = 0, raw_fmts = 0; | 461 | unsigned int i, fmts = 0, raw_fmts = 0; |
462 | int ret; | 462 | int ret; |
463 | enum v4l2_mbus_pixelcode code; | 463 | u32 code; |
464 | 464 | ||
465 | while (!v4l2_subdev_call(sd, video, enum_mbus_fmt, raw_fmts, &code)) | 465 | while (!v4l2_subdev_call(sd, video, enum_mbus_fmt, raw_fmts, &code)) |
466 | raw_fmts++; | 466 | raw_fmts++; |
diff --git a/drivers/media/platform/soc_camera/soc_camera_platform.c b/drivers/media/platform/soc_camera/soc_camera_platform.c index ceaddfb85e49..f2ce1ab06d53 100644 --- a/drivers/media/platform/soc_camera/soc_camera_platform.c +++ b/drivers/media/platform/soc_camera/soc_camera_platform.c | |||
@@ -62,7 +62,7 @@ static struct v4l2_subdev_core_ops platform_subdev_core_ops = { | |||
62 | }; | 62 | }; |
63 | 63 | ||
64 | static int soc_camera_platform_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | 64 | static int soc_camera_platform_enum_fmt(struct v4l2_subdev *sd, unsigned int index, |
65 | enum v4l2_mbus_pixelcode *code) | 65 | u32 *code) |
66 | { | 66 | { |
67 | struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd); | 67 | struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd); |
68 | 68 | ||
diff --git a/drivers/media/platform/soc_camera/soc_mediabus.c b/drivers/media/platform/soc_camera/soc_mediabus.c index dc02deca7563..1dbcd426683c 100644 --- a/drivers/media/platform/soc_camera/soc_mediabus.c +++ b/drivers/media/platform/soc_camera/soc_mediabus.c | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | static const struct soc_mbus_lookup mbus_fmt[] = { | 18 | static const struct soc_mbus_lookup mbus_fmt[] = { |
19 | { | 19 | { |
20 | .code = V4L2_MBUS_FMT_YUYV8_2X8, | 20 | .code = MEDIA_BUS_FMT_YUYV8_2X8, |
21 | .fmt = { | 21 | .fmt = { |
22 | .fourcc = V4L2_PIX_FMT_YUYV, | 22 | .fourcc = V4L2_PIX_FMT_YUYV, |
23 | .name = "YUYV", | 23 | .name = "YUYV", |
@@ -27,7 +27,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
27 | .layout = SOC_MBUS_LAYOUT_PACKED, | 27 | .layout = SOC_MBUS_LAYOUT_PACKED, |
28 | }, | 28 | }, |
29 | }, { | 29 | }, { |
30 | .code = V4L2_MBUS_FMT_YVYU8_2X8, | 30 | .code = MEDIA_BUS_FMT_YVYU8_2X8, |
31 | .fmt = { | 31 | .fmt = { |
32 | .fourcc = V4L2_PIX_FMT_YVYU, | 32 | .fourcc = V4L2_PIX_FMT_YVYU, |
33 | .name = "YVYU", | 33 | .name = "YVYU", |
@@ -37,7 +37,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
37 | .layout = SOC_MBUS_LAYOUT_PACKED, | 37 | .layout = SOC_MBUS_LAYOUT_PACKED, |
38 | }, | 38 | }, |
39 | }, { | 39 | }, { |
40 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | 40 | .code = MEDIA_BUS_FMT_UYVY8_2X8, |
41 | .fmt = { | 41 | .fmt = { |
42 | .fourcc = V4L2_PIX_FMT_UYVY, | 42 | .fourcc = V4L2_PIX_FMT_UYVY, |
43 | .name = "UYVY", | 43 | .name = "UYVY", |
@@ -47,7 +47,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
47 | .layout = SOC_MBUS_LAYOUT_PACKED, | 47 | .layout = SOC_MBUS_LAYOUT_PACKED, |
48 | }, | 48 | }, |
49 | }, { | 49 | }, { |
50 | .code = V4L2_MBUS_FMT_VYUY8_2X8, | 50 | .code = MEDIA_BUS_FMT_VYUY8_2X8, |
51 | .fmt = { | 51 | .fmt = { |
52 | .fourcc = V4L2_PIX_FMT_VYUY, | 52 | .fourcc = V4L2_PIX_FMT_VYUY, |
53 | .name = "VYUY", | 53 | .name = "VYUY", |
@@ -57,7 +57,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
57 | .layout = SOC_MBUS_LAYOUT_PACKED, | 57 | .layout = SOC_MBUS_LAYOUT_PACKED, |
58 | }, | 58 | }, |
59 | }, { | 59 | }, { |
60 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, | 60 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, |
61 | .fmt = { | 61 | .fmt = { |
62 | .fourcc = V4L2_PIX_FMT_RGB555, | 62 | .fourcc = V4L2_PIX_FMT_RGB555, |
63 | .name = "RGB555", | 63 | .name = "RGB555", |
@@ -67,7 +67,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
67 | .layout = SOC_MBUS_LAYOUT_PACKED, | 67 | .layout = SOC_MBUS_LAYOUT_PACKED, |
68 | }, | 68 | }, |
69 | }, { | 69 | }, { |
70 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, | 70 | .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, |
71 | .fmt = { | 71 | .fmt = { |
72 | .fourcc = V4L2_PIX_FMT_RGB555X, | 72 | .fourcc = V4L2_PIX_FMT_RGB555X, |
73 | .name = "RGB555X", | 73 | .name = "RGB555X", |
@@ -77,7 +77,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
77 | .layout = SOC_MBUS_LAYOUT_PACKED, | 77 | .layout = SOC_MBUS_LAYOUT_PACKED, |
78 | }, | 78 | }, |
79 | }, { | 79 | }, { |
80 | .code = V4L2_MBUS_FMT_RGB565_2X8_LE, | 80 | .code = MEDIA_BUS_FMT_RGB565_2X8_LE, |
81 | .fmt = { | 81 | .fmt = { |
82 | .fourcc = V4L2_PIX_FMT_RGB565, | 82 | .fourcc = V4L2_PIX_FMT_RGB565, |
83 | .name = "RGB565", | 83 | .name = "RGB565", |
@@ -87,7 +87,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
87 | .layout = SOC_MBUS_LAYOUT_PACKED, | 87 | .layout = SOC_MBUS_LAYOUT_PACKED, |
88 | }, | 88 | }, |
89 | }, { | 89 | }, { |
90 | .code = V4L2_MBUS_FMT_RGB565_2X8_BE, | 90 | .code = MEDIA_BUS_FMT_RGB565_2X8_BE, |
91 | .fmt = { | 91 | .fmt = { |
92 | .fourcc = V4L2_PIX_FMT_RGB565X, | 92 | .fourcc = V4L2_PIX_FMT_RGB565X, |
93 | .name = "RGB565X", | 93 | .name = "RGB565X", |
@@ -97,7 +97,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
97 | .layout = SOC_MBUS_LAYOUT_PACKED, | 97 | .layout = SOC_MBUS_LAYOUT_PACKED, |
98 | }, | 98 | }, |
99 | }, { | 99 | }, { |
100 | .code = V4L2_MBUS_FMT_RGB666_1X18, | 100 | .code = MEDIA_BUS_FMT_RGB666_1X18, |
101 | .fmt = { | 101 | .fmt = { |
102 | .fourcc = V4L2_PIX_FMT_RGB32, | 102 | .fourcc = V4L2_PIX_FMT_RGB32, |
103 | .name = "RGB666/32bpp", | 103 | .name = "RGB666/32bpp", |
@@ -106,7 +106,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
106 | .order = SOC_MBUS_ORDER_LE, | 106 | .order = SOC_MBUS_ORDER_LE, |
107 | }, | 107 | }, |
108 | }, { | 108 | }, { |
109 | .code = V4L2_MBUS_FMT_RGB888_1X24, | 109 | .code = MEDIA_BUS_FMT_RGB888_1X24, |
110 | .fmt = { | 110 | .fmt = { |
111 | .fourcc = V4L2_PIX_FMT_RGB32, | 111 | .fourcc = V4L2_PIX_FMT_RGB32, |
112 | .name = "RGB888/32bpp", | 112 | .name = "RGB888/32bpp", |
@@ -115,7 +115,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
115 | .order = SOC_MBUS_ORDER_LE, | 115 | .order = SOC_MBUS_ORDER_LE, |
116 | }, | 116 | }, |
117 | }, { | 117 | }, { |
118 | .code = V4L2_MBUS_FMT_RGB888_2X12_BE, | 118 | .code = MEDIA_BUS_FMT_RGB888_2X12_BE, |
119 | .fmt = { | 119 | .fmt = { |
120 | .fourcc = V4L2_PIX_FMT_RGB32, | 120 | .fourcc = V4L2_PIX_FMT_RGB32, |
121 | .name = "RGB888/32bpp", | 121 | .name = "RGB888/32bpp", |
@@ -124,7 +124,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
124 | .order = SOC_MBUS_ORDER_BE, | 124 | .order = SOC_MBUS_ORDER_BE, |
125 | }, | 125 | }, |
126 | }, { | 126 | }, { |
127 | .code = V4L2_MBUS_FMT_RGB888_2X12_LE, | 127 | .code = MEDIA_BUS_FMT_RGB888_2X12_LE, |
128 | .fmt = { | 128 | .fmt = { |
129 | .fourcc = V4L2_PIX_FMT_RGB32, | 129 | .fourcc = V4L2_PIX_FMT_RGB32, |
130 | .name = "RGB888/32bpp", | 130 | .name = "RGB888/32bpp", |
@@ -133,7 +133,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
133 | .order = SOC_MBUS_ORDER_LE, | 133 | .order = SOC_MBUS_ORDER_LE, |
134 | }, | 134 | }, |
135 | }, { | 135 | }, { |
136 | .code = V4L2_MBUS_FMT_SBGGR8_1X8, | 136 | .code = MEDIA_BUS_FMT_SBGGR8_1X8, |
137 | .fmt = { | 137 | .fmt = { |
138 | .fourcc = V4L2_PIX_FMT_SBGGR8, | 138 | .fourcc = V4L2_PIX_FMT_SBGGR8, |
139 | .name = "Bayer 8 BGGR", | 139 | .name = "Bayer 8 BGGR", |
@@ -143,7 +143,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
143 | .layout = SOC_MBUS_LAYOUT_PACKED, | 143 | .layout = SOC_MBUS_LAYOUT_PACKED, |
144 | }, | 144 | }, |
145 | }, { | 145 | }, { |
146 | .code = V4L2_MBUS_FMT_SBGGR10_1X10, | 146 | .code = MEDIA_BUS_FMT_SBGGR10_1X10, |
147 | .fmt = { | 147 | .fmt = { |
148 | .fourcc = V4L2_PIX_FMT_SBGGR10, | 148 | .fourcc = V4L2_PIX_FMT_SBGGR10, |
149 | .name = "Bayer 10 BGGR", | 149 | .name = "Bayer 10 BGGR", |
@@ -153,7 +153,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
153 | .layout = SOC_MBUS_LAYOUT_PACKED, | 153 | .layout = SOC_MBUS_LAYOUT_PACKED, |
154 | }, | 154 | }, |
155 | }, { | 155 | }, { |
156 | .code = V4L2_MBUS_FMT_Y8_1X8, | 156 | .code = MEDIA_BUS_FMT_Y8_1X8, |
157 | .fmt = { | 157 | .fmt = { |
158 | .fourcc = V4L2_PIX_FMT_GREY, | 158 | .fourcc = V4L2_PIX_FMT_GREY, |
159 | .name = "Grey", | 159 | .name = "Grey", |
@@ -163,7 +163,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
163 | .layout = SOC_MBUS_LAYOUT_PACKED, | 163 | .layout = SOC_MBUS_LAYOUT_PACKED, |
164 | }, | 164 | }, |
165 | }, { | 165 | }, { |
166 | .code = V4L2_MBUS_FMT_Y10_1X10, | 166 | .code = MEDIA_BUS_FMT_Y10_1X10, |
167 | .fmt = { | 167 | .fmt = { |
168 | .fourcc = V4L2_PIX_FMT_Y10, | 168 | .fourcc = V4L2_PIX_FMT_Y10, |
169 | .name = "Grey 10bit", | 169 | .name = "Grey 10bit", |
@@ -173,7 +173,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
173 | .layout = SOC_MBUS_LAYOUT_PACKED, | 173 | .layout = SOC_MBUS_LAYOUT_PACKED, |
174 | }, | 174 | }, |
175 | }, { | 175 | }, { |
176 | .code = V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, | 176 | .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, |
177 | .fmt = { | 177 | .fmt = { |
178 | .fourcc = V4L2_PIX_FMT_SBGGR10, | 178 | .fourcc = V4L2_PIX_FMT_SBGGR10, |
179 | .name = "Bayer 10 BGGR", | 179 | .name = "Bayer 10 BGGR", |
@@ -183,7 +183,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
183 | .layout = SOC_MBUS_LAYOUT_PACKED, | 183 | .layout = SOC_MBUS_LAYOUT_PACKED, |
184 | }, | 184 | }, |
185 | }, { | 185 | }, { |
186 | .code = V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, | 186 | .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, |
187 | .fmt = { | 187 | .fmt = { |
188 | .fourcc = V4L2_PIX_FMT_SBGGR10, | 188 | .fourcc = V4L2_PIX_FMT_SBGGR10, |
189 | .name = "Bayer 10 BGGR", | 189 | .name = "Bayer 10 BGGR", |
@@ -193,7 +193,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
193 | .layout = SOC_MBUS_LAYOUT_PACKED, | 193 | .layout = SOC_MBUS_LAYOUT_PACKED, |
194 | }, | 194 | }, |
195 | }, { | 195 | }, { |
196 | .code = V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, | 196 | .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, |
197 | .fmt = { | 197 | .fmt = { |
198 | .fourcc = V4L2_PIX_FMT_SBGGR10, | 198 | .fourcc = V4L2_PIX_FMT_SBGGR10, |
199 | .name = "Bayer 10 BGGR", | 199 | .name = "Bayer 10 BGGR", |
@@ -203,7 +203,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
203 | .layout = SOC_MBUS_LAYOUT_PACKED, | 203 | .layout = SOC_MBUS_LAYOUT_PACKED, |
204 | }, | 204 | }, |
205 | }, { | 205 | }, { |
206 | .code = V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, | 206 | .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, |
207 | .fmt = { | 207 | .fmt = { |
208 | .fourcc = V4L2_PIX_FMT_SBGGR10, | 208 | .fourcc = V4L2_PIX_FMT_SBGGR10, |
209 | .name = "Bayer 10 BGGR", | 209 | .name = "Bayer 10 BGGR", |
@@ -213,7 +213,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
213 | .layout = SOC_MBUS_LAYOUT_PACKED, | 213 | .layout = SOC_MBUS_LAYOUT_PACKED, |
214 | }, | 214 | }, |
215 | }, { | 215 | }, { |
216 | .code = V4L2_MBUS_FMT_JPEG_1X8, | 216 | .code = MEDIA_BUS_FMT_JPEG_1X8, |
217 | .fmt = { | 217 | .fmt = { |
218 | .fourcc = V4L2_PIX_FMT_JPEG, | 218 | .fourcc = V4L2_PIX_FMT_JPEG, |
219 | .name = "JPEG", | 219 | .name = "JPEG", |
@@ -223,7 +223,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
223 | .layout = SOC_MBUS_LAYOUT_PACKED, | 223 | .layout = SOC_MBUS_LAYOUT_PACKED, |
224 | }, | 224 | }, |
225 | }, { | 225 | }, { |
226 | .code = V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE, | 226 | .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, |
227 | .fmt = { | 227 | .fmt = { |
228 | .fourcc = V4L2_PIX_FMT_RGB444, | 228 | .fourcc = V4L2_PIX_FMT_RGB444, |
229 | .name = "RGB444", | 229 | .name = "RGB444", |
@@ -233,7 +233,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
233 | .layout = SOC_MBUS_LAYOUT_PACKED, | 233 | .layout = SOC_MBUS_LAYOUT_PACKED, |
234 | }, | 234 | }, |
235 | }, { | 235 | }, { |
236 | .code = V4L2_MBUS_FMT_YUYV8_1_5X8, | 236 | .code = MEDIA_BUS_FMT_YUYV8_1_5X8, |
237 | .fmt = { | 237 | .fmt = { |
238 | .fourcc = V4L2_PIX_FMT_YUV420, | 238 | .fourcc = V4L2_PIX_FMT_YUV420, |
239 | .name = "YUYV 4:2:0", | 239 | .name = "YUYV 4:2:0", |
@@ -243,7 +243,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
243 | .layout = SOC_MBUS_LAYOUT_PACKED, | 243 | .layout = SOC_MBUS_LAYOUT_PACKED, |
244 | }, | 244 | }, |
245 | }, { | 245 | }, { |
246 | .code = V4L2_MBUS_FMT_YVYU8_1_5X8, | 246 | .code = MEDIA_BUS_FMT_YVYU8_1_5X8, |
247 | .fmt = { | 247 | .fmt = { |
248 | .fourcc = V4L2_PIX_FMT_YVU420, | 248 | .fourcc = V4L2_PIX_FMT_YVU420, |
249 | .name = "YVYU 4:2:0", | 249 | .name = "YVYU 4:2:0", |
@@ -253,7 +253,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
253 | .layout = SOC_MBUS_LAYOUT_PACKED, | 253 | .layout = SOC_MBUS_LAYOUT_PACKED, |
254 | }, | 254 | }, |
255 | }, { | 255 | }, { |
256 | .code = V4L2_MBUS_FMT_UYVY8_1X16, | 256 | .code = MEDIA_BUS_FMT_UYVY8_1X16, |
257 | .fmt = { | 257 | .fmt = { |
258 | .fourcc = V4L2_PIX_FMT_UYVY, | 258 | .fourcc = V4L2_PIX_FMT_UYVY, |
259 | .name = "UYVY 16bit", | 259 | .name = "UYVY 16bit", |
@@ -263,7 +263,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
263 | .layout = SOC_MBUS_LAYOUT_PACKED, | 263 | .layout = SOC_MBUS_LAYOUT_PACKED, |
264 | }, | 264 | }, |
265 | }, { | 265 | }, { |
266 | .code = V4L2_MBUS_FMT_VYUY8_1X16, | 266 | .code = MEDIA_BUS_FMT_VYUY8_1X16, |
267 | .fmt = { | 267 | .fmt = { |
268 | .fourcc = V4L2_PIX_FMT_VYUY, | 268 | .fourcc = V4L2_PIX_FMT_VYUY, |
269 | .name = "VYUY 16bit", | 269 | .name = "VYUY 16bit", |
@@ -273,7 +273,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
273 | .layout = SOC_MBUS_LAYOUT_PACKED, | 273 | .layout = SOC_MBUS_LAYOUT_PACKED, |
274 | }, | 274 | }, |
275 | }, { | 275 | }, { |
276 | .code = V4L2_MBUS_FMT_YUYV8_1X16, | 276 | .code = MEDIA_BUS_FMT_YUYV8_1X16, |
277 | .fmt = { | 277 | .fmt = { |
278 | .fourcc = V4L2_PIX_FMT_YUYV, | 278 | .fourcc = V4L2_PIX_FMT_YUYV, |
279 | .name = "YUYV 16bit", | 279 | .name = "YUYV 16bit", |
@@ -283,7 +283,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
283 | .layout = SOC_MBUS_LAYOUT_PACKED, | 283 | .layout = SOC_MBUS_LAYOUT_PACKED, |
284 | }, | 284 | }, |
285 | }, { | 285 | }, { |
286 | .code = V4L2_MBUS_FMT_YVYU8_1X16, | 286 | .code = MEDIA_BUS_FMT_YVYU8_1X16, |
287 | .fmt = { | 287 | .fmt = { |
288 | .fourcc = V4L2_PIX_FMT_YVYU, | 288 | .fourcc = V4L2_PIX_FMT_YVYU, |
289 | .name = "YVYU 16bit", | 289 | .name = "YVYU 16bit", |
@@ -293,7 +293,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
293 | .layout = SOC_MBUS_LAYOUT_PACKED, | 293 | .layout = SOC_MBUS_LAYOUT_PACKED, |
294 | }, | 294 | }, |
295 | }, { | 295 | }, { |
296 | .code = V4L2_MBUS_FMT_SGRBG8_1X8, | 296 | .code = MEDIA_BUS_FMT_SGRBG8_1X8, |
297 | .fmt = { | 297 | .fmt = { |
298 | .fourcc = V4L2_PIX_FMT_SGRBG8, | 298 | .fourcc = V4L2_PIX_FMT_SGRBG8, |
299 | .name = "Bayer 8 GRBG", | 299 | .name = "Bayer 8 GRBG", |
@@ -303,7 +303,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
303 | .layout = SOC_MBUS_LAYOUT_PACKED, | 303 | .layout = SOC_MBUS_LAYOUT_PACKED, |
304 | }, | 304 | }, |
305 | }, { | 305 | }, { |
306 | .code = V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, | 306 | .code = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, |
307 | .fmt = { | 307 | .fmt = { |
308 | .fourcc = V4L2_PIX_FMT_SGRBG10DPCM8, | 308 | .fourcc = V4L2_PIX_FMT_SGRBG10DPCM8, |
309 | .name = "Bayer 10 BGGR DPCM 8", | 309 | .name = "Bayer 10 BGGR DPCM 8", |
@@ -313,7 +313,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
313 | .layout = SOC_MBUS_LAYOUT_PACKED, | 313 | .layout = SOC_MBUS_LAYOUT_PACKED, |
314 | }, | 314 | }, |
315 | }, { | 315 | }, { |
316 | .code = V4L2_MBUS_FMT_SGBRG10_1X10, | 316 | .code = MEDIA_BUS_FMT_SGBRG10_1X10, |
317 | .fmt = { | 317 | .fmt = { |
318 | .fourcc = V4L2_PIX_FMT_SGBRG10, | 318 | .fourcc = V4L2_PIX_FMT_SGBRG10, |
319 | .name = "Bayer 10 GBRG", | 319 | .name = "Bayer 10 GBRG", |
@@ -323,7 +323,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
323 | .layout = SOC_MBUS_LAYOUT_PACKED, | 323 | .layout = SOC_MBUS_LAYOUT_PACKED, |
324 | }, | 324 | }, |
325 | }, { | 325 | }, { |
326 | .code = V4L2_MBUS_FMT_SGRBG10_1X10, | 326 | .code = MEDIA_BUS_FMT_SGRBG10_1X10, |
327 | .fmt = { | 327 | .fmt = { |
328 | .fourcc = V4L2_PIX_FMT_SGRBG10, | 328 | .fourcc = V4L2_PIX_FMT_SGRBG10, |
329 | .name = "Bayer 10 GRBG", | 329 | .name = "Bayer 10 GRBG", |
@@ -333,7 +333,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
333 | .layout = SOC_MBUS_LAYOUT_PACKED, | 333 | .layout = SOC_MBUS_LAYOUT_PACKED, |
334 | }, | 334 | }, |
335 | }, { | 335 | }, { |
336 | .code = V4L2_MBUS_FMT_SRGGB10_1X10, | 336 | .code = MEDIA_BUS_FMT_SRGGB10_1X10, |
337 | .fmt = { | 337 | .fmt = { |
338 | .fourcc = V4L2_PIX_FMT_SRGGB10, | 338 | .fourcc = V4L2_PIX_FMT_SRGGB10, |
339 | .name = "Bayer 10 RGGB", | 339 | .name = "Bayer 10 RGGB", |
@@ -343,7 +343,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
343 | .layout = SOC_MBUS_LAYOUT_PACKED, | 343 | .layout = SOC_MBUS_LAYOUT_PACKED, |
344 | }, | 344 | }, |
345 | }, { | 345 | }, { |
346 | .code = V4L2_MBUS_FMT_SBGGR12_1X12, | 346 | .code = MEDIA_BUS_FMT_SBGGR12_1X12, |
347 | .fmt = { | 347 | .fmt = { |
348 | .fourcc = V4L2_PIX_FMT_SBGGR12, | 348 | .fourcc = V4L2_PIX_FMT_SBGGR12, |
349 | .name = "Bayer 12 BGGR", | 349 | .name = "Bayer 12 BGGR", |
@@ -353,7 +353,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
353 | .layout = SOC_MBUS_LAYOUT_PACKED, | 353 | .layout = SOC_MBUS_LAYOUT_PACKED, |
354 | }, | 354 | }, |
355 | }, { | 355 | }, { |
356 | .code = V4L2_MBUS_FMT_SGBRG12_1X12, | 356 | .code = MEDIA_BUS_FMT_SGBRG12_1X12, |
357 | .fmt = { | 357 | .fmt = { |
358 | .fourcc = V4L2_PIX_FMT_SGBRG12, | 358 | .fourcc = V4L2_PIX_FMT_SGBRG12, |
359 | .name = "Bayer 12 GBRG", | 359 | .name = "Bayer 12 GBRG", |
@@ -363,7 +363,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
363 | .layout = SOC_MBUS_LAYOUT_PACKED, | 363 | .layout = SOC_MBUS_LAYOUT_PACKED, |
364 | }, | 364 | }, |
365 | }, { | 365 | }, { |
366 | .code = V4L2_MBUS_FMT_SGRBG12_1X12, | 366 | .code = MEDIA_BUS_FMT_SGRBG12_1X12, |
367 | .fmt = { | 367 | .fmt = { |
368 | .fourcc = V4L2_PIX_FMT_SGRBG12, | 368 | .fourcc = V4L2_PIX_FMT_SGRBG12, |
369 | .name = "Bayer 12 GRBG", | 369 | .name = "Bayer 12 GRBG", |
@@ -373,7 +373,7 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
373 | .layout = SOC_MBUS_LAYOUT_PACKED, | 373 | .layout = SOC_MBUS_LAYOUT_PACKED, |
374 | }, | 374 | }, |
375 | }, { | 375 | }, { |
376 | .code = V4L2_MBUS_FMT_SRGGB12_1X12, | 376 | .code = MEDIA_BUS_FMT_SRGGB12_1X12, |
377 | .fmt = { | 377 | .fmt = { |
378 | .fourcc = V4L2_PIX_FMT_SRGGB12, | 378 | .fourcc = V4L2_PIX_FMT_SRGGB12, |
379 | .name = "Bayer 12 RGGB", | 379 | .name = "Bayer 12 RGGB", |
@@ -458,7 +458,7 @@ s32 soc_mbus_image_size(const struct soc_mbus_pixelfmt *mf, | |||
458 | EXPORT_SYMBOL(soc_mbus_image_size); | 458 | EXPORT_SYMBOL(soc_mbus_image_size); |
459 | 459 | ||
460 | const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc( | 460 | const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc( |
461 | enum v4l2_mbus_pixelcode code, | 461 | u32 code, |
462 | const struct soc_mbus_lookup *lookup, | 462 | const struct soc_mbus_lookup *lookup, |
463 | int n) | 463 | int n) |
464 | { | 464 | { |
@@ -473,7 +473,7 @@ const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc( | |||
473 | EXPORT_SYMBOL(soc_mbus_find_fmtdesc); | 473 | EXPORT_SYMBOL(soc_mbus_find_fmtdesc); |
474 | 474 | ||
475 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( | 475 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( |
476 | enum v4l2_mbus_pixelcode code) | 476 | u32 code) |
477 | { | 477 | { |
478 | return soc_mbus_find_fmtdesc(code, mbus_fmt, ARRAY_SIZE(mbus_fmt)); | 478 | return soc_mbus_find_fmtdesc(code, mbus_fmt, ARRAY_SIZE(mbus_fmt)); |
479 | } | 479 | } |
diff --git a/drivers/media/platform/ti-vpe/csc.c b/drivers/media/platform/ti-vpe/csc.c index 940df4000c42..bec674994752 100644 --- a/drivers/media/platform/ti-vpe/csc.c +++ b/drivers/media/platform/ti-vpe/csc.c | |||
@@ -93,12 +93,8 @@ void csc_dump_regs(struct csc_data *csc) | |||
93 | { | 93 | { |
94 | struct device *dev = &csc->pdev->dev; | 94 | struct device *dev = &csc->pdev->dev; |
95 | 95 | ||
96 | u32 read_reg(struct csc_data *csc, int offset) | 96 | #define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \ |
97 | { | 97 | ioread32(csc->base + CSC_##r)) |
98 | return ioread32(csc->base + offset); | ||
99 | } | ||
100 | |||
101 | #define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(csc, CSC_##r)) | ||
102 | 98 | ||
103 | DUMPREG(CSC00); | 99 | DUMPREG(CSC00); |
104 | DUMPREG(CSC01); | 100 | DUMPREG(CSC01); |
@@ -189,7 +185,7 @@ struct csc_data *csc_create(struct platform_device *pdev) | |||
189 | csc->base = devm_ioremap_resource(&pdev->dev, csc->res); | 185 | csc->base = devm_ioremap_resource(&pdev->dev, csc->res); |
190 | if (IS_ERR(csc->base)) { | 186 | if (IS_ERR(csc->base)) { |
191 | dev_err(&pdev->dev, "failed to ioremap\n"); | 187 | dev_err(&pdev->dev, "failed to ioremap\n"); |
192 | return csc->base; | 188 | return ERR_CAST(csc->base); |
193 | } | 189 | } |
194 | 190 | ||
195 | return csc; | 191 | return csc; |
diff --git a/drivers/media/platform/ti-vpe/sc.c b/drivers/media/platform/ti-vpe/sc.c index 6314171ffe9b..f82d1c7f667f 100644 --- a/drivers/media/platform/ti-vpe/sc.c +++ b/drivers/media/platform/ti-vpe/sc.c | |||
@@ -24,12 +24,8 @@ void sc_dump_regs(struct sc_data *sc) | |||
24 | { | 24 | { |
25 | struct device *dev = &sc->pdev->dev; | 25 | struct device *dev = &sc->pdev->dev; |
26 | 26 | ||
27 | u32 read_reg(struct sc_data *sc, int offset) | 27 | #define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \ |
28 | { | 28 | ioread32(sc->base + CFG_##r)) |
29 | return ioread32(sc->base + offset); | ||
30 | } | ||
31 | |||
32 | #define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(sc, CFG_##r)) | ||
33 | 29 | ||
34 | DUMPREG(SC0); | 30 | DUMPREG(SC0); |
35 | DUMPREG(SC1); | 31 | DUMPREG(SC1); |
@@ -304,7 +300,7 @@ struct sc_data *sc_create(struct platform_device *pdev) | |||
304 | sc->base = devm_ioremap_resource(&pdev->dev, sc->res); | 300 | sc->base = devm_ioremap_resource(&pdev->dev, sc->res); |
305 | if (IS_ERR(sc->base)) { | 301 | if (IS_ERR(sc->base)) { |
306 | dev_err(&pdev->dev, "failed to ioremap\n"); | 302 | dev_err(&pdev->dev, "failed to ioremap\n"); |
307 | return sc->base; | 303 | return ERR_CAST(sc->base); |
308 | } | 304 | } |
309 | 305 | ||
310 | return sc; | 306 | return sc; |
diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c index ae6870cb8339..86989d86abfa 100644 --- a/drivers/media/platform/via-camera.c +++ b/drivers/media/platform/via-camera.c | |||
@@ -101,7 +101,7 @@ struct via_camera { | |||
101 | */ | 101 | */ |
102 | struct v4l2_pix_format sensor_format; | 102 | struct v4l2_pix_format sensor_format; |
103 | struct v4l2_pix_format user_format; | 103 | struct v4l2_pix_format user_format; |
104 | enum v4l2_mbus_pixelcode mbus_code; | 104 | u32 mbus_code; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | /* | 107 | /* |
@@ -143,12 +143,12 @@ static struct via_format { | |||
143 | __u8 *desc; | 143 | __u8 *desc; |
144 | __u32 pixelformat; | 144 | __u32 pixelformat; |
145 | int bpp; /* Bytes per pixel */ | 145 | int bpp; /* Bytes per pixel */ |
146 | enum v4l2_mbus_pixelcode mbus_code; | 146 | u32 mbus_code; |
147 | } via_formats[] = { | 147 | } via_formats[] = { |
148 | { | 148 | { |
149 | .desc = "YUYV 4:2:2", | 149 | .desc = "YUYV 4:2:2", |
150 | .pixelformat = V4L2_PIX_FMT_YUYV, | 150 | .pixelformat = V4L2_PIX_FMT_YUYV, |
151 | .mbus_code = V4L2_MBUS_FMT_YUYV8_2X8, | 151 | .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, |
152 | .bpp = 2, | 152 | .bpp = 2, |
153 | }, | 153 | }, |
154 | /* RGB444 and Bayer should be doable, but have never been | 154 | /* RGB444 and Bayer should be doable, but have never been |
@@ -849,7 +849,7 @@ static const struct v4l2_pix_format viacam_def_pix_format = { | |||
849 | .sizeimage = VGA_WIDTH * VGA_HEIGHT * 2, | 849 | .sizeimage = VGA_WIDTH * VGA_HEIGHT * 2, |
850 | }; | 850 | }; |
851 | 851 | ||
852 | static const enum v4l2_mbus_pixelcode via_def_mbus_code = V4L2_MBUS_FMT_YUYV8_2X8; | 852 | static const u32 via_def_mbus_code = MEDIA_BUS_FMT_YUYV8_2X8; |
853 | 853 | ||
854 | static int viacam_enum_fmt_vid_cap(struct file *filp, void *priv, | 854 | static int viacam_enum_fmt_vid_cap(struct file *filp, void *priv, |
855 | struct v4l2_fmtdesc *fmt) | 855 | struct v4l2_fmtdesc *fmt) |
@@ -985,9 +985,9 @@ static int viacam_querycap(struct file *filp, void *priv, | |||
985 | { | 985 | { |
986 | strcpy(cap->driver, "via-camera"); | 986 | strcpy(cap->driver, "via-camera"); |
987 | strcpy(cap->card, "via-camera"); | 987 | strcpy(cap->card, "via-camera"); |
988 | cap->version = 1; | 988 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | |
989 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | | ||
990 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; | 989 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; |
990 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
991 | return 0; | 991 | return 0; |
992 | } | 992 | } |
993 | 993 | ||
diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/vim2m.c index c1b03cfd6ded..1105c111cc10 100644 --- a/drivers/media/platform/mem2mem_testdev.c +++ b/drivers/media/platform/vim2m.c | |||
@@ -31,12 +31,11 @@ | |||
31 | #include <media/v4l2-event.h> | 31 | #include <media/v4l2-event.h> |
32 | #include <media/videobuf2-vmalloc.h> | 32 | #include <media/videobuf2-vmalloc.h> |
33 | 33 | ||
34 | #define MEM2MEM_TEST_MODULE_NAME "mem2mem-testdev" | ||
35 | |||
36 | MODULE_DESCRIPTION("Virtual device for mem2mem framework testing"); | 34 | MODULE_DESCRIPTION("Virtual device for mem2mem framework testing"); |
37 | MODULE_AUTHOR("Pawel Osciak, <pawel@osciak.com>"); | 35 | MODULE_AUTHOR("Pawel Osciak, <pawel@osciak.com>"); |
38 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
39 | MODULE_VERSION("0.1.1"); | 37 | MODULE_VERSION("0.1.1"); |
38 | MODULE_ALIAS("mem2mem_testdev"); | ||
40 | 39 | ||
41 | static unsigned debug; | 40 | static unsigned debug; |
42 | module_param(debug, uint, 0644); | 41 | module_param(debug, uint, 0644); |
@@ -52,7 +51,7 @@ MODULE_PARM_DESC(debug, "activates debug info"); | |||
52 | #define MEM2MEM_CAPTURE (1 << 0) | 51 | #define MEM2MEM_CAPTURE (1 << 0) |
53 | #define MEM2MEM_OUTPUT (1 << 1) | 52 | #define MEM2MEM_OUTPUT (1 << 1) |
54 | 53 | ||
55 | #define MEM2MEM_NAME "m2m-testdev" | 54 | #define MEM2MEM_NAME "vim2m" |
56 | 55 | ||
57 | /* Per queue */ | 56 | /* Per queue */ |
58 | #define MEM2MEM_DEF_NUM_BUFS VIDEO_MAX_FRAME | 57 | #define MEM2MEM_DEF_NUM_BUFS VIDEO_MAX_FRAME |
@@ -72,15 +71,15 @@ MODULE_PARM_DESC(debug, "activates debug info"); | |||
72 | v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg) | 71 | v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg) |
73 | 72 | ||
74 | 73 | ||
75 | static void m2mtest_dev_release(struct device *dev) | 74 | static void vim2m_dev_release(struct device *dev) |
76 | {} | 75 | {} |
77 | 76 | ||
78 | static struct platform_device m2mtest_pdev = { | 77 | static struct platform_device vim2m_pdev = { |
79 | .name = MEM2MEM_NAME, | 78 | .name = MEM2MEM_NAME, |
80 | .dev.release = m2mtest_dev_release, | 79 | .dev.release = vim2m_dev_release, |
81 | }; | 80 | }; |
82 | 81 | ||
83 | struct m2mtest_fmt { | 82 | struct vim2m_fmt { |
84 | char *name; | 83 | char *name; |
85 | u32 fourcc; | 84 | u32 fourcc; |
86 | int depth; | 85 | int depth; |
@@ -88,7 +87,7 @@ struct m2mtest_fmt { | |||
88 | u32 types; | 87 | u32 types; |
89 | }; | 88 | }; |
90 | 89 | ||
91 | static struct m2mtest_fmt formats[] = { | 90 | static struct vim2m_fmt formats[] = { |
92 | { | 91 | { |
93 | .name = "RGB565 (BE)", | 92 | .name = "RGB565 (BE)", |
94 | .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ | 93 | .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ |
@@ -108,12 +107,12 @@ static struct m2mtest_fmt formats[] = { | |||
108 | #define NUM_FORMATS ARRAY_SIZE(formats) | 107 | #define NUM_FORMATS ARRAY_SIZE(formats) |
109 | 108 | ||
110 | /* Per-queue, driver-specific private data */ | 109 | /* Per-queue, driver-specific private data */ |
111 | struct m2mtest_q_data { | 110 | struct vim2m_q_data { |
112 | unsigned int width; | 111 | unsigned int width; |
113 | unsigned int height; | 112 | unsigned int height; |
114 | unsigned int sizeimage; | 113 | unsigned int sizeimage; |
115 | unsigned int sequence; | 114 | unsigned int sequence; |
116 | struct m2mtest_fmt *fmt; | 115 | struct vim2m_fmt *fmt; |
117 | }; | 116 | }; |
118 | 117 | ||
119 | enum { | 118 | enum { |
@@ -124,9 +123,9 @@ enum { | |||
124 | #define V4L2_CID_TRANS_TIME_MSEC (V4L2_CID_USER_BASE + 0x1000) | 123 | #define V4L2_CID_TRANS_TIME_MSEC (V4L2_CID_USER_BASE + 0x1000) |
125 | #define V4L2_CID_TRANS_NUM_BUFS (V4L2_CID_USER_BASE + 0x1001) | 124 | #define V4L2_CID_TRANS_NUM_BUFS (V4L2_CID_USER_BASE + 0x1001) |
126 | 125 | ||
127 | static struct m2mtest_fmt *find_format(struct v4l2_format *f) | 126 | static struct vim2m_fmt *find_format(struct v4l2_format *f) |
128 | { | 127 | { |
129 | struct m2mtest_fmt *fmt; | 128 | struct vim2m_fmt *fmt; |
130 | unsigned int k; | 129 | unsigned int k; |
131 | 130 | ||
132 | for (k = 0; k < NUM_FORMATS; k++) { | 131 | for (k = 0; k < NUM_FORMATS; k++) { |
@@ -141,7 +140,7 @@ static struct m2mtest_fmt *find_format(struct v4l2_format *f) | |||
141 | return &formats[k]; | 140 | return &formats[k]; |
142 | } | 141 | } |
143 | 142 | ||
144 | struct m2mtest_dev { | 143 | struct vim2m_dev { |
145 | struct v4l2_device v4l2_dev; | 144 | struct v4l2_device v4l2_dev; |
146 | struct video_device *vfd; | 145 | struct video_device *vfd; |
147 | 146 | ||
@@ -154,9 +153,9 @@ struct m2mtest_dev { | |||
154 | struct v4l2_m2m_dev *m2m_dev; | 153 | struct v4l2_m2m_dev *m2m_dev; |
155 | }; | 154 | }; |
156 | 155 | ||
157 | struct m2mtest_ctx { | 156 | struct vim2m_ctx { |
158 | struct v4l2_fh fh; | 157 | struct v4l2_fh fh; |
159 | struct m2mtest_dev *dev; | 158 | struct vim2m_dev *dev; |
160 | 159 | ||
161 | struct v4l2_ctrl_handler hdl; | 160 | struct v4l2_ctrl_handler hdl; |
162 | 161 | ||
@@ -177,15 +176,15 @@ struct m2mtest_ctx { | |||
177 | enum v4l2_colorspace colorspace; | 176 | enum v4l2_colorspace colorspace; |
178 | 177 | ||
179 | /* Source and destination queue data */ | 178 | /* Source and destination queue data */ |
180 | struct m2mtest_q_data q_data[2]; | 179 | struct vim2m_q_data q_data[2]; |
181 | }; | 180 | }; |
182 | 181 | ||
183 | static inline struct m2mtest_ctx *file2ctx(struct file *file) | 182 | static inline struct vim2m_ctx *file2ctx(struct file *file) |
184 | { | 183 | { |
185 | return container_of(file->private_data, struct m2mtest_ctx, fh); | 184 | return container_of(file->private_data, struct vim2m_ctx, fh); |
186 | } | 185 | } |
187 | 186 | ||
188 | static struct m2mtest_q_data *get_q_data(struct m2mtest_ctx *ctx, | 187 | static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx, |
189 | enum v4l2_buf_type type) | 188 | enum v4l2_buf_type type) |
190 | { | 189 | { |
191 | switch (type) { | 190 | switch (type) { |
@@ -200,12 +199,12 @@ static struct m2mtest_q_data *get_q_data(struct m2mtest_ctx *ctx, | |||
200 | } | 199 | } |
201 | 200 | ||
202 | 201 | ||
203 | static int device_process(struct m2mtest_ctx *ctx, | 202 | static int device_process(struct vim2m_ctx *ctx, |
204 | struct vb2_buffer *in_vb, | 203 | struct vb2_buffer *in_vb, |
205 | struct vb2_buffer *out_vb) | 204 | struct vb2_buffer *out_vb) |
206 | { | 205 | { |
207 | struct m2mtest_dev *dev = ctx->dev; | 206 | struct vim2m_dev *dev = ctx->dev; |
208 | struct m2mtest_q_data *q_data; | 207 | struct vim2m_q_data *q_data; |
209 | u8 *p_in, *p_out; | 208 | u8 *p_in, *p_out; |
210 | int x, y, t, w; | 209 | int x, y, t, w; |
211 | int tile_w, bytes_left; | 210 | int tile_w, bytes_left; |
@@ -334,7 +333,7 @@ static int device_process(struct m2mtest_ctx *ctx, | |||
334 | return 0; | 333 | return 0; |
335 | } | 334 | } |
336 | 335 | ||
337 | static void schedule_irq(struct m2mtest_dev *dev, int msec_timeout) | 336 | static void schedule_irq(struct vim2m_dev *dev, int msec_timeout) |
338 | { | 337 | { |
339 | dprintk(dev, "Scheduling a simulated irq\n"); | 338 | dprintk(dev, "Scheduling a simulated irq\n"); |
340 | mod_timer(&dev->timer, jiffies + msecs_to_jiffies(msec_timeout)); | 339 | mod_timer(&dev->timer, jiffies + msecs_to_jiffies(msec_timeout)); |
@@ -349,7 +348,7 @@ static void schedule_irq(struct m2mtest_dev *dev, int msec_timeout) | |||
349 | */ | 348 | */ |
350 | static int job_ready(void *priv) | 349 | static int job_ready(void *priv) |
351 | { | 350 | { |
352 | struct m2mtest_ctx *ctx = priv; | 351 | struct vim2m_ctx *ctx = priv; |
353 | 352 | ||
354 | if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen | 353 | if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen |
355 | || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen) { | 354 | || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen) { |
@@ -362,7 +361,7 @@ static int job_ready(void *priv) | |||
362 | 361 | ||
363 | static void job_abort(void *priv) | 362 | static void job_abort(void *priv) |
364 | { | 363 | { |
365 | struct m2mtest_ctx *ctx = priv; | 364 | struct vim2m_ctx *ctx = priv; |
366 | 365 | ||
367 | /* Will cancel the transaction in the next interrupt handler */ | 366 | /* Will cancel the transaction in the next interrupt handler */ |
368 | ctx->aborting = 1; | 367 | ctx->aborting = 1; |
@@ -376,8 +375,8 @@ static void job_abort(void *priv) | |||
376 | */ | 375 | */ |
377 | static void device_run(void *priv) | 376 | static void device_run(void *priv) |
378 | { | 377 | { |
379 | struct m2mtest_ctx *ctx = priv; | 378 | struct vim2m_ctx *ctx = priv; |
380 | struct m2mtest_dev *dev = ctx->dev; | 379 | struct vim2m_dev *dev = ctx->dev; |
381 | struct vb2_buffer *src_buf, *dst_buf; | 380 | struct vb2_buffer *src_buf, *dst_buf; |
382 | 381 | ||
383 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); | 382 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); |
@@ -391,12 +390,12 @@ static void device_run(void *priv) | |||
391 | 390 | ||
392 | static void device_isr(unsigned long priv) | 391 | static void device_isr(unsigned long priv) |
393 | { | 392 | { |
394 | struct m2mtest_dev *m2mtest_dev = (struct m2mtest_dev *)priv; | 393 | struct vim2m_dev *vim2m_dev = (struct vim2m_dev *)priv; |
395 | struct m2mtest_ctx *curr_ctx; | 394 | struct vim2m_ctx *curr_ctx; |
396 | struct vb2_buffer *src_vb, *dst_vb; | 395 | struct vb2_buffer *src_vb, *dst_vb; |
397 | unsigned long flags; | 396 | unsigned long flags; |
398 | 397 | ||
399 | curr_ctx = v4l2_m2m_get_curr_priv(m2mtest_dev->m2m_dev); | 398 | curr_ctx = v4l2_m2m_get_curr_priv(vim2m_dev->m2m_dev); |
400 | 399 | ||
401 | if (NULL == curr_ctx) { | 400 | if (NULL == curr_ctx) { |
402 | pr_err("Instance released before the end of transaction\n"); | 401 | pr_err("Instance released before the end of transaction\n"); |
@@ -408,16 +407,16 @@ static void device_isr(unsigned long priv) | |||
408 | 407 | ||
409 | curr_ctx->num_processed++; | 408 | curr_ctx->num_processed++; |
410 | 409 | ||
411 | spin_lock_irqsave(&m2mtest_dev->irqlock, flags); | 410 | spin_lock_irqsave(&vim2m_dev->irqlock, flags); |
412 | v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE); | 411 | v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE); |
413 | v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE); | 412 | v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE); |
414 | spin_unlock_irqrestore(&m2mtest_dev->irqlock, flags); | 413 | spin_unlock_irqrestore(&vim2m_dev->irqlock, flags); |
415 | 414 | ||
416 | if (curr_ctx->num_processed == curr_ctx->translen | 415 | if (curr_ctx->num_processed == curr_ctx->translen |
417 | || curr_ctx->aborting) { | 416 | || curr_ctx->aborting) { |
418 | dprintk(curr_ctx->dev, "Finishing transaction\n"); | 417 | dprintk(curr_ctx->dev, "Finishing transaction\n"); |
419 | curr_ctx->num_processed = 0; | 418 | curr_ctx->num_processed = 0; |
420 | v4l2_m2m_job_finish(m2mtest_dev->m2m_dev, curr_ctx->fh.m2m_ctx); | 419 | v4l2_m2m_job_finish(vim2m_dev->m2m_dev, curr_ctx->fh.m2m_ctx); |
421 | } else { | 420 | } else { |
422 | device_run(curr_ctx); | 421 | device_run(curr_ctx); |
423 | } | 422 | } |
@@ -441,7 +440,7 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
441 | static int enum_fmt(struct v4l2_fmtdesc *f, u32 type) | 440 | static int enum_fmt(struct v4l2_fmtdesc *f, u32 type) |
442 | { | 441 | { |
443 | int i, num; | 442 | int i, num; |
444 | struct m2mtest_fmt *fmt; | 443 | struct vim2m_fmt *fmt; |
445 | 444 | ||
446 | num = 0; | 445 | num = 0; |
447 | 446 | ||
@@ -480,10 +479,10 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *priv, | |||
480 | return enum_fmt(f, MEM2MEM_OUTPUT); | 479 | return enum_fmt(f, MEM2MEM_OUTPUT); |
481 | } | 480 | } |
482 | 481 | ||
483 | static int vidioc_g_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f) | 482 | static int vidioc_g_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f) |
484 | { | 483 | { |
485 | struct vb2_queue *vq; | 484 | struct vb2_queue *vq; |
486 | struct m2mtest_q_data *q_data; | 485 | struct vim2m_q_data *q_data; |
487 | 486 | ||
488 | vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); | 487 | vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); |
489 | if (!vq) | 488 | if (!vq) |
@@ -514,7 +513,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
514 | return vidioc_g_fmt(file2ctx(file), f); | 513 | return vidioc_g_fmt(file2ctx(file), f); |
515 | } | 514 | } |
516 | 515 | ||
517 | static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt) | 516 | static int vidioc_try_fmt(struct v4l2_format *f, struct vim2m_fmt *fmt) |
518 | { | 517 | { |
519 | /* V4L2 specification suggests the driver corrects the format struct | 518 | /* V4L2 specification suggests the driver corrects the format struct |
520 | * if any of the dimensions is unsupported */ | 519 | * if any of the dimensions is unsupported */ |
@@ -539,8 +538,8 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt) | |||
539 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | 538 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
540 | struct v4l2_format *f) | 539 | struct v4l2_format *f) |
541 | { | 540 | { |
542 | struct m2mtest_fmt *fmt; | 541 | struct vim2m_fmt *fmt; |
543 | struct m2mtest_ctx *ctx = file2ctx(file); | 542 | struct vim2m_ctx *ctx = file2ctx(file); |
544 | 543 | ||
545 | fmt = find_format(f); | 544 | fmt = find_format(f); |
546 | if (!fmt) { | 545 | if (!fmt) { |
@@ -561,8 +560,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
561 | static int vidioc_try_fmt_vid_out(struct file *file, void *priv, | 560 | static int vidioc_try_fmt_vid_out(struct file *file, void *priv, |
562 | struct v4l2_format *f) | 561 | struct v4l2_format *f) |
563 | { | 562 | { |
564 | struct m2mtest_fmt *fmt; | 563 | struct vim2m_fmt *fmt; |
565 | struct m2mtest_ctx *ctx = file2ctx(file); | 564 | struct vim2m_ctx *ctx = file2ctx(file); |
566 | 565 | ||
567 | fmt = find_format(f); | 566 | fmt = find_format(f); |
568 | if (!fmt) { | 567 | if (!fmt) { |
@@ -581,9 +580,9 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *priv, | |||
581 | return vidioc_try_fmt(f, fmt); | 580 | return vidioc_try_fmt(f, fmt); |
582 | } | 581 | } |
583 | 582 | ||
584 | static int vidioc_s_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f) | 583 | static int vidioc_s_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f) |
585 | { | 584 | { |
586 | struct m2mtest_q_data *q_data; | 585 | struct vim2m_q_data *q_data; |
587 | struct vb2_queue *vq; | 586 | struct vb2_queue *vq; |
588 | 587 | ||
589 | vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); | 588 | vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); |
@@ -627,7 +626,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
627 | static int vidioc_s_fmt_vid_out(struct file *file, void *priv, | 626 | static int vidioc_s_fmt_vid_out(struct file *file, void *priv, |
628 | struct v4l2_format *f) | 627 | struct v4l2_format *f) |
629 | { | 628 | { |
630 | struct m2mtest_ctx *ctx = file2ctx(file); | 629 | struct vim2m_ctx *ctx = file2ctx(file); |
631 | int ret; | 630 | int ret; |
632 | 631 | ||
633 | ret = vidioc_try_fmt_vid_out(file, priv, f); | 632 | ret = vidioc_try_fmt_vid_out(file, priv, f); |
@@ -640,10 +639,10 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, | |||
640 | return ret; | 639 | return ret; |
641 | } | 640 | } |
642 | 641 | ||
643 | static int m2mtest_s_ctrl(struct v4l2_ctrl *ctrl) | 642 | static int vim2m_s_ctrl(struct v4l2_ctrl *ctrl) |
644 | { | 643 | { |
645 | struct m2mtest_ctx *ctx = | 644 | struct vim2m_ctx *ctx = |
646 | container_of(ctrl->handler, struct m2mtest_ctx, hdl); | 645 | container_of(ctrl->handler, struct vim2m_ctx, hdl); |
647 | 646 | ||
648 | switch (ctrl->id) { | 647 | switch (ctrl->id) { |
649 | case V4L2_CID_HFLIP: | 648 | case V4L2_CID_HFLIP: |
@@ -676,12 +675,12 @@ static int m2mtest_s_ctrl(struct v4l2_ctrl *ctrl) | |||
676 | return 0; | 675 | return 0; |
677 | } | 676 | } |
678 | 677 | ||
679 | static const struct v4l2_ctrl_ops m2mtest_ctrl_ops = { | 678 | static const struct v4l2_ctrl_ops vim2m_ctrl_ops = { |
680 | .s_ctrl = m2mtest_s_ctrl, | 679 | .s_ctrl = vim2m_s_ctrl, |
681 | }; | 680 | }; |
682 | 681 | ||
683 | 682 | ||
684 | static const struct v4l2_ioctl_ops m2mtest_ioctl_ops = { | 683 | static const struct v4l2_ioctl_ops vim2m_ioctl_ops = { |
685 | .vidioc_querycap = vidioc_querycap, | 684 | .vidioc_querycap = vidioc_querycap, |
686 | 685 | ||
687 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, | 686 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, |
@@ -698,6 +697,7 @@ static const struct v4l2_ioctl_ops m2mtest_ioctl_ops = { | |||
698 | .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, | 697 | .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, |
699 | .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, | 698 | .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, |
700 | .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, | 699 | .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, |
700 | .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, | ||
701 | 701 | ||
702 | .vidioc_streamon = v4l2_m2m_ioctl_streamon, | 702 | .vidioc_streamon = v4l2_m2m_ioctl_streamon, |
703 | .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, | 703 | .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, |
@@ -711,13 +711,13 @@ static const struct v4l2_ioctl_ops m2mtest_ioctl_ops = { | |||
711 | * Queue operations | 711 | * Queue operations |
712 | */ | 712 | */ |
713 | 713 | ||
714 | static int m2mtest_queue_setup(struct vb2_queue *vq, | 714 | static int vim2m_queue_setup(struct vb2_queue *vq, |
715 | const struct v4l2_format *fmt, | 715 | const struct v4l2_format *fmt, |
716 | unsigned int *nbuffers, unsigned int *nplanes, | 716 | unsigned int *nbuffers, unsigned int *nplanes, |
717 | unsigned int sizes[], void *alloc_ctxs[]) | 717 | unsigned int sizes[], void *alloc_ctxs[]) |
718 | { | 718 | { |
719 | struct m2mtest_ctx *ctx = vb2_get_drv_priv(vq); | 719 | struct vim2m_ctx *ctx = vb2_get_drv_priv(vq); |
720 | struct m2mtest_q_data *q_data; | 720 | struct vim2m_q_data *q_data; |
721 | unsigned int size, count = *nbuffers; | 721 | unsigned int size, count = *nbuffers; |
722 | 722 | ||
723 | q_data = get_q_data(ctx, vq->type); | 723 | q_data = get_q_data(ctx, vq->type); |
@@ -741,10 +741,10 @@ static int m2mtest_queue_setup(struct vb2_queue *vq, | |||
741 | return 0; | 741 | return 0; |
742 | } | 742 | } |
743 | 743 | ||
744 | static int m2mtest_buf_prepare(struct vb2_buffer *vb) | 744 | static int vim2m_buf_prepare(struct vb2_buffer *vb) |
745 | { | 745 | { |
746 | struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); | 746 | struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); |
747 | struct m2mtest_q_data *q_data; | 747 | struct vim2m_q_data *q_data; |
748 | 748 | ||
749 | dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); | 749 | dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); |
750 | 750 | ||
@@ -770,25 +770,25 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb) | |||
770 | return 0; | 770 | return 0; |
771 | } | 771 | } |
772 | 772 | ||
773 | static void m2mtest_buf_queue(struct vb2_buffer *vb) | 773 | static void vim2m_buf_queue(struct vb2_buffer *vb) |
774 | { | 774 | { |
775 | struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); | 775 | struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); |
776 | 776 | ||
777 | v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); | 777 | v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); |
778 | } | 778 | } |
779 | 779 | ||
780 | static int m2mtest_start_streaming(struct vb2_queue *q, unsigned count) | 780 | static int vim2m_start_streaming(struct vb2_queue *q, unsigned count) |
781 | { | 781 | { |
782 | struct m2mtest_ctx *ctx = vb2_get_drv_priv(q); | 782 | struct vim2m_ctx *ctx = vb2_get_drv_priv(q); |
783 | struct m2mtest_q_data *q_data = get_q_data(ctx, q->type); | 783 | struct vim2m_q_data *q_data = get_q_data(ctx, q->type); |
784 | 784 | ||
785 | q_data->sequence = 0; | 785 | q_data->sequence = 0; |
786 | return 0; | 786 | return 0; |
787 | } | 787 | } |
788 | 788 | ||
789 | static void m2mtest_stop_streaming(struct vb2_queue *q) | 789 | static void vim2m_stop_streaming(struct vb2_queue *q) |
790 | { | 790 | { |
791 | struct m2mtest_ctx *ctx = vb2_get_drv_priv(q); | 791 | struct vim2m_ctx *ctx = vb2_get_drv_priv(q); |
792 | struct vb2_buffer *vb; | 792 | struct vb2_buffer *vb; |
793 | unsigned long flags; | 793 | unsigned long flags; |
794 | 794 | ||
@@ -805,26 +805,26 @@ static void m2mtest_stop_streaming(struct vb2_queue *q) | |||
805 | } | 805 | } |
806 | } | 806 | } |
807 | 807 | ||
808 | static struct vb2_ops m2mtest_qops = { | 808 | static struct vb2_ops vim2m_qops = { |
809 | .queue_setup = m2mtest_queue_setup, | 809 | .queue_setup = vim2m_queue_setup, |
810 | .buf_prepare = m2mtest_buf_prepare, | 810 | .buf_prepare = vim2m_buf_prepare, |
811 | .buf_queue = m2mtest_buf_queue, | 811 | .buf_queue = vim2m_buf_queue, |
812 | .start_streaming = m2mtest_start_streaming, | 812 | .start_streaming = vim2m_start_streaming, |
813 | .stop_streaming = m2mtest_stop_streaming, | 813 | .stop_streaming = vim2m_stop_streaming, |
814 | .wait_prepare = vb2_ops_wait_prepare, | 814 | .wait_prepare = vb2_ops_wait_prepare, |
815 | .wait_finish = vb2_ops_wait_finish, | 815 | .wait_finish = vb2_ops_wait_finish, |
816 | }; | 816 | }; |
817 | 817 | ||
818 | static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) | 818 | static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) |
819 | { | 819 | { |
820 | struct m2mtest_ctx *ctx = priv; | 820 | struct vim2m_ctx *ctx = priv; |
821 | int ret; | 821 | int ret; |
822 | 822 | ||
823 | src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | 823 | src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; |
824 | src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; | 824 | src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; |
825 | src_vq->drv_priv = ctx; | 825 | src_vq->drv_priv = ctx; |
826 | src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); | 826 | src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); |
827 | src_vq->ops = &m2mtest_qops; | 827 | src_vq->ops = &vim2m_qops; |
828 | src_vq->mem_ops = &vb2_vmalloc_memops; | 828 | src_vq->mem_ops = &vb2_vmalloc_memops; |
829 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 829 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
830 | src_vq->lock = &ctx->dev->dev_mutex; | 830 | src_vq->lock = &ctx->dev->dev_mutex; |
@@ -837,7 +837,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds | |||
837 | dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; | 837 | dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; |
838 | dst_vq->drv_priv = ctx; | 838 | dst_vq->drv_priv = ctx; |
839 | dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); | 839 | dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); |
840 | dst_vq->ops = &m2mtest_qops; | 840 | dst_vq->ops = &vim2m_qops; |
841 | dst_vq->mem_ops = &vb2_vmalloc_memops; | 841 | dst_vq->mem_ops = &vb2_vmalloc_memops; |
842 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 842 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
843 | dst_vq->lock = &ctx->dev->dev_mutex; | 843 | dst_vq->lock = &ctx->dev->dev_mutex; |
@@ -845,8 +845,8 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds | |||
845 | return vb2_queue_init(dst_vq); | 845 | return vb2_queue_init(dst_vq); |
846 | } | 846 | } |
847 | 847 | ||
848 | static const struct v4l2_ctrl_config m2mtest_ctrl_trans_time_msec = { | 848 | static const struct v4l2_ctrl_config vim2m_ctrl_trans_time_msec = { |
849 | .ops = &m2mtest_ctrl_ops, | 849 | .ops = &vim2m_ctrl_ops, |
850 | .id = V4L2_CID_TRANS_TIME_MSEC, | 850 | .id = V4L2_CID_TRANS_TIME_MSEC, |
851 | .name = "Transaction Time (msec)", | 851 | .name = "Transaction Time (msec)", |
852 | .type = V4L2_CTRL_TYPE_INTEGER, | 852 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -856,8 +856,8 @@ static const struct v4l2_ctrl_config m2mtest_ctrl_trans_time_msec = { | |||
856 | .step = 1, | 856 | .step = 1, |
857 | }; | 857 | }; |
858 | 858 | ||
859 | static const struct v4l2_ctrl_config m2mtest_ctrl_trans_num_bufs = { | 859 | static const struct v4l2_ctrl_config vim2m_ctrl_trans_num_bufs = { |
860 | .ops = &m2mtest_ctrl_ops, | 860 | .ops = &vim2m_ctrl_ops, |
861 | .id = V4L2_CID_TRANS_NUM_BUFS, | 861 | .id = V4L2_CID_TRANS_NUM_BUFS, |
862 | .name = "Buffers Per Transaction", | 862 | .name = "Buffers Per Transaction", |
863 | .type = V4L2_CTRL_TYPE_INTEGER, | 863 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -870,10 +870,10 @@ static const struct v4l2_ctrl_config m2mtest_ctrl_trans_num_bufs = { | |||
870 | /* | 870 | /* |
871 | * File operations | 871 | * File operations |
872 | */ | 872 | */ |
873 | static int m2mtest_open(struct file *file) | 873 | static int vim2m_open(struct file *file) |
874 | { | 874 | { |
875 | struct m2mtest_dev *dev = video_drvdata(file); | 875 | struct vim2m_dev *dev = video_drvdata(file); |
876 | struct m2mtest_ctx *ctx = NULL; | 876 | struct vim2m_ctx *ctx = NULL; |
877 | struct v4l2_ctrl_handler *hdl; | 877 | struct v4l2_ctrl_handler *hdl; |
878 | int rc = 0; | 878 | int rc = 0; |
879 | 879 | ||
@@ -890,10 +890,10 @@ static int m2mtest_open(struct file *file) | |||
890 | ctx->dev = dev; | 890 | ctx->dev = dev; |
891 | hdl = &ctx->hdl; | 891 | hdl = &ctx->hdl; |
892 | v4l2_ctrl_handler_init(hdl, 4); | 892 | v4l2_ctrl_handler_init(hdl, 4); |
893 | v4l2_ctrl_new_std(hdl, &m2mtest_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); | 893 | v4l2_ctrl_new_std(hdl, &vim2m_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); |
894 | v4l2_ctrl_new_std(hdl, &m2mtest_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); | 894 | v4l2_ctrl_new_std(hdl, &vim2m_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); |
895 | v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_time_msec, NULL); | 895 | v4l2_ctrl_new_custom(hdl, &vim2m_ctrl_trans_time_msec, NULL); |
896 | v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_num_bufs, NULL); | 896 | v4l2_ctrl_new_custom(hdl, &vim2m_ctrl_trans_num_bufs, NULL); |
897 | if (hdl->error) { | 897 | if (hdl->error) { |
898 | rc = hdl->error; | 898 | rc = hdl->error; |
899 | v4l2_ctrl_handler_free(hdl); | 899 | v4l2_ctrl_handler_free(hdl); |
@@ -933,10 +933,10 @@ open_unlock: | |||
933 | return rc; | 933 | return rc; |
934 | } | 934 | } |
935 | 935 | ||
936 | static int m2mtest_release(struct file *file) | 936 | static int vim2m_release(struct file *file) |
937 | { | 937 | { |
938 | struct m2mtest_dev *dev = video_drvdata(file); | 938 | struct vim2m_dev *dev = video_drvdata(file); |
939 | struct m2mtest_ctx *ctx = file2ctx(file); | 939 | struct vim2m_ctx *ctx = file2ctx(file); |
940 | 940 | ||
941 | dprintk(dev, "Releasing instance %p\n", ctx); | 941 | dprintk(dev, "Releasing instance %p\n", ctx); |
942 | 942 | ||
@@ -953,20 +953,20 @@ static int m2mtest_release(struct file *file) | |||
953 | return 0; | 953 | return 0; |
954 | } | 954 | } |
955 | 955 | ||
956 | static const struct v4l2_file_operations m2mtest_fops = { | 956 | static const struct v4l2_file_operations vim2m_fops = { |
957 | .owner = THIS_MODULE, | 957 | .owner = THIS_MODULE, |
958 | .open = m2mtest_open, | 958 | .open = vim2m_open, |
959 | .release = m2mtest_release, | 959 | .release = vim2m_release, |
960 | .poll = v4l2_m2m_fop_poll, | 960 | .poll = v4l2_m2m_fop_poll, |
961 | .unlocked_ioctl = video_ioctl2, | 961 | .unlocked_ioctl = video_ioctl2, |
962 | .mmap = v4l2_m2m_fop_mmap, | 962 | .mmap = v4l2_m2m_fop_mmap, |
963 | }; | 963 | }; |
964 | 964 | ||
965 | static struct video_device m2mtest_videodev = { | 965 | static struct video_device vim2m_videodev = { |
966 | .name = MEM2MEM_NAME, | 966 | .name = MEM2MEM_NAME, |
967 | .vfl_dir = VFL_DIR_M2M, | 967 | .vfl_dir = VFL_DIR_M2M, |
968 | .fops = &m2mtest_fops, | 968 | .fops = &vim2m_fops, |
969 | .ioctl_ops = &m2mtest_ioctl_ops, | 969 | .ioctl_ops = &vim2m_ioctl_ops, |
970 | .minor = -1, | 970 | .minor = -1, |
971 | .release = video_device_release, | 971 | .release = video_device_release, |
972 | }; | 972 | }; |
@@ -977,9 +977,9 @@ static struct v4l2_m2m_ops m2m_ops = { | |||
977 | .job_abort = job_abort, | 977 | .job_abort = job_abort, |
978 | }; | 978 | }; |
979 | 979 | ||
980 | static int m2mtest_probe(struct platform_device *pdev) | 980 | static int vim2m_probe(struct platform_device *pdev) |
981 | { | 981 | { |
982 | struct m2mtest_dev *dev; | 982 | struct vim2m_dev *dev; |
983 | struct video_device *vfd; | 983 | struct video_device *vfd; |
984 | int ret; | 984 | int ret; |
985 | 985 | ||
@@ -1003,7 +1003,7 @@ static int m2mtest_probe(struct platform_device *pdev) | |||
1003 | goto unreg_dev; | 1003 | goto unreg_dev; |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | *vfd = m2mtest_videodev; | 1006 | *vfd = vim2m_videodev; |
1007 | vfd->lock = &dev->dev_mutex; | 1007 | vfd->lock = &dev->dev_mutex; |
1008 | vfd->v4l2_dev = &dev->v4l2_dev; | 1008 | vfd->v4l2_dev = &dev->v4l2_dev; |
1009 | 1009 | ||
@@ -1014,7 +1014,7 @@ static int m2mtest_probe(struct platform_device *pdev) | |||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | video_set_drvdata(vfd, dev); | 1016 | video_set_drvdata(vfd, dev); |
1017 | snprintf(vfd->name, sizeof(vfd->name), "%s", m2mtest_videodev.name); | 1017 | snprintf(vfd->name, sizeof(vfd->name), "%s", vim2m_videodev.name); |
1018 | dev->vfd = vfd; | 1018 | dev->vfd = vfd; |
1019 | v4l2_info(&dev->v4l2_dev, | 1019 | v4l2_info(&dev->v4l2_dev, |
1020 | "Device registered as /dev/video%d\n", vfd->num); | 1020 | "Device registered as /dev/video%d\n", vfd->num); |
@@ -1042,11 +1042,11 @@ unreg_dev: | |||
1042 | return ret; | 1042 | return ret; |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | static int m2mtest_remove(struct platform_device *pdev) | 1045 | static int vim2m_remove(struct platform_device *pdev) |
1046 | { | 1046 | { |
1047 | struct m2mtest_dev *dev = platform_get_drvdata(pdev); | 1047 | struct vim2m_dev *dev = platform_get_drvdata(pdev); |
1048 | 1048 | ||
1049 | v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_TEST_MODULE_NAME); | 1049 | v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME); |
1050 | v4l2_m2m_release(dev->m2m_dev); | 1050 | v4l2_m2m_release(dev->m2m_dev); |
1051 | del_timer_sync(&dev->timer); | 1051 | del_timer_sync(&dev->timer); |
1052 | video_unregister_device(dev->vfd); | 1052 | video_unregister_device(dev->vfd); |
@@ -1055,35 +1055,35 @@ static int m2mtest_remove(struct platform_device *pdev) | |||
1055 | return 0; | 1055 | return 0; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | static struct platform_driver m2mtest_pdrv = { | 1058 | static struct platform_driver vim2m_pdrv = { |
1059 | .probe = m2mtest_probe, | 1059 | .probe = vim2m_probe, |
1060 | .remove = m2mtest_remove, | 1060 | .remove = vim2m_remove, |
1061 | .driver = { | 1061 | .driver = { |
1062 | .name = MEM2MEM_NAME, | 1062 | .name = MEM2MEM_NAME, |
1063 | .owner = THIS_MODULE, | 1063 | .owner = THIS_MODULE, |
1064 | }, | 1064 | }, |
1065 | }; | 1065 | }; |
1066 | 1066 | ||
1067 | static void __exit m2mtest_exit(void) | 1067 | static void __exit vim2m_exit(void) |
1068 | { | 1068 | { |
1069 | platform_driver_unregister(&m2mtest_pdrv); | 1069 | platform_driver_unregister(&vim2m_pdrv); |
1070 | platform_device_unregister(&m2mtest_pdev); | 1070 | platform_device_unregister(&vim2m_pdev); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static int __init m2mtest_init(void) | 1073 | static int __init vim2m_init(void) |
1074 | { | 1074 | { |
1075 | int ret; | 1075 | int ret; |
1076 | 1076 | ||
1077 | ret = platform_device_register(&m2mtest_pdev); | 1077 | ret = platform_device_register(&vim2m_pdev); |
1078 | if (ret) | 1078 | if (ret) |
1079 | return ret; | 1079 | return ret; |
1080 | 1080 | ||
1081 | ret = platform_driver_register(&m2mtest_pdrv); | 1081 | ret = platform_driver_register(&vim2m_pdrv); |
1082 | if (ret) | 1082 | if (ret) |
1083 | platform_device_unregister(&m2mtest_pdev); | 1083 | platform_device_unregister(&vim2m_pdev); |
1084 | 1084 | ||
1085 | return 0; | 1085 | return 0; |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | module_init(m2mtest_init); | 1088 | module_init(vim2m_init); |
1089 | module_exit(m2mtest_exit); | 1089 | module_exit(vim2m_exit); |
diff --git a/drivers/media/platform/vino.c b/drivers/media/platform/vino.c index 91d44ea16f27..2c85357f774d 100644 --- a/drivers/media/platform/vino.c +++ b/drivers/media/platform/vino.c | |||
@@ -2932,10 +2932,8 @@ static int vino_querycap(struct file *file, void *__fh, | |||
2932 | strcpy(cap->driver, vino_driver_name); | 2932 | strcpy(cap->driver, vino_driver_name); |
2933 | strcpy(cap->card, vino_driver_description); | 2933 | strcpy(cap->card, vino_driver_description); |
2934 | strcpy(cap->bus_info, vino_bus_name); | 2934 | strcpy(cap->bus_info, vino_bus_name); |
2935 | cap->capabilities = | 2935 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; |
2936 | V4L2_CAP_VIDEO_CAPTURE | | 2936 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
2937 | V4L2_CAP_STREAMING; | ||
2938 | // V4L2_CAP_OVERLAY, V4L2_CAP_READWRITE | ||
2939 | return 0; | 2937 | return 0; |
2940 | } | 2938 | } |
2941 | 2939 | ||
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c index 686c3c2ad05b..a7e033a5d291 100644 --- a/drivers/media/platform/vivid/vivid-core.c +++ b/drivers/media/platform/vivid/vivid-core.c | |||
@@ -195,20 +195,6 @@ static const u8 vivid_hdmi_edid[256] = { | |||
195 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7 | 195 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7 |
196 | }; | 196 | }; |
197 | 197 | ||
198 | void vivid_lock(struct vb2_queue *vq) | ||
199 | { | ||
200 | struct vivid_dev *dev = vb2_get_drv_priv(vq); | ||
201 | |||
202 | mutex_lock(&dev->mutex); | ||
203 | } | ||
204 | |||
205 | void vivid_unlock(struct vb2_queue *vq) | ||
206 | { | ||
207 | struct vivid_dev *dev = vb2_get_drv_priv(vq); | ||
208 | |||
209 | mutex_unlock(&dev->mutex); | ||
210 | } | ||
211 | |||
212 | static int vidioc_querycap(struct file *file, void *priv, | 198 | static int vidioc_querycap(struct file *file, void *priv, |
213 | struct v4l2_capability *cap) | 199 | struct v4l2_capability *cap) |
214 | { | 200 | { |
@@ -586,7 +572,7 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { | |||
586 | .vidioc_querybuf = vb2_ioctl_querybuf, | 572 | .vidioc_querybuf = vb2_ioctl_querybuf, |
587 | .vidioc_qbuf = vb2_ioctl_qbuf, | 573 | .vidioc_qbuf = vb2_ioctl_qbuf, |
588 | .vidioc_dqbuf = vb2_ioctl_dqbuf, | 574 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
589 | /* Not yet .vidioc_expbuf = vb2_ioctl_expbuf,*/ | 575 | .vidioc_expbuf = vb2_ioctl_expbuf, |
590 | .vidioc_streamon = vb2_ioctl_streamon, | 576 | .vidioc_streamon = vb2_ioctl_streamon, |
591 | .vidioc_streamoff = vb2_ioctl_streamoff, | 577 | .vidioc_streamoff = vb2_ioctl_streamoff, |
592 | 578 | ||
@@ -1018,6 +1004,7 @@ static int __init vivid_create_instance(int inst) | |||
1018 | q->mem_ops = &vb2_vmalloc_memops; | 1004 | q->mem_ops = &vb2_vmalloc_memops; |
1019 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1005 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1020 | q->min_buffers_needed = 2; | 1006 | q->min_buffers_needed = 2; |
1007 | q->lock = &dev->mutex; | ||
1021 | 1008 | ||
1022 | ret = vb2_queue_init(q); | 1009 | ret = vb2_queue_init(q); |
1023 | if (ret) | 1010 | if (ret) |
@@ -1036,6 +1023,7 @@ static int __init vivid_create_instance(int inst) | |||
1036 | q->mem_ops = &vb2_vmalloc_memops; | 1023 | q->mem_ops = &vb2_vmalloc_memops; |
1037 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1024 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1038 | q->min_buffers_needed = 2; | 1025 | q->min_buffers_needed = 2; |
1026 | q->lock = &dev->mutex; | ||
1039 | 1027 | ||
1040 | ret = vb2_queue_init(q); | 1028 | ret = vb2_queue_init(q); |
1041 | if (ret) | 1029 | if (ret) |
@@ -1054,6 +1042,7 @@ static int __init vivid_create_instance(int inst) | |||
1054 | q->mem_ops = &vb2_vmalloc_memops; | 1042 | q->mem_ops = &vb2_vmalloc_memops; |
1055 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1043 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1056 | q->min_buffers_needed = 2; | 1044 | q->min_buffers_needed = 2; |
1045 | q->lock = &dev->mutex; | ||
1057 | 1046 | ||
1058 | ret = vb2_queue_init(q); | 1047 | ret = vb2_queue_init(q); |
1059 | if (ret) | 1048 | if (ret) |
@@ -1072,6 +1061,7 @@ static int __init vivid_create_instance(int inst) | |||
1072 | q->mem_ops = &vb2_vmalloc_memops; | 1061 | q->mem_ops = &vb2_vmalloc_memops; |
1073 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1062 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1074 | q->min_buffers_needed = 2; | 1063 | q->min_buffers_needed = 2; |
1064 | q->lock = &dev->mutex; | ||
1075 | 1065 | ||
1076 | ret = vb2_queue_init(q); | 1066 | ret = vb2_queue_init(q); |
1077 | if (ret) | 1067 | if (ret) |
@@ -1089,6 +1079,7 @@ static int __init vivid_create_instance(int inst) | |||
1089 | q->mem_ops = &vb2_vmalloc_memops; | 1079 | q->mem_ops = &vb2_vmalloc_memops; |
1090 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1080 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1091 | q->min_buffers_needed = 8; | 1081 | q->min_buffers_needed = 8; |
1082 | q->lock = &dev->mutex; | ||
1092 | 1083 | ||
1093 | ret = vb2_queue_init(q); | 1084 | ret = vb2_queue_init(q); |
1094 | if (ret) | 1085 | if (ret) |
diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h index 811c286491a5..4b497df4b6a4 100644 --- a/drivers/media/platform/vivid/vivid-core.h +++ b/drivers/media/platform/vivid/vivid-core.h | |||
@@ -116,6 +116,17 @@ enum vivid_signal_mode { | |||
116 | CUSTOM_DV_TIMINGS, | 116 | CUSTOM_DV_TIMINGS, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | enum vivid_colorspace { | ||
120 | VIVID_CS_170M, | ||
121 | VIVID_CS_709, | ||
122 | VIVID_CS_SRGB, | ||
123 | VIVID_CS_ADOBERGB, | ||
124 | VIVID_CS_2020, | ||
125 | VIVID_CS_240M, | ||
126 | VIVID_CS_SYS_M, | ||
127 | VIVID_CS_SYS_BG, | ||
128 | }; | ||
129 | |||
119 | #define VIVID_INVALID_SIGNAL(mode) \ | 130 | #define VIVID_INVALID_SIGNAL(mode) \ |
120 | ((mode) == NO_SIGNAL || (mode) == NO_LOCK || (mode) == OUT_OF_RANGE) | 131 | ((mode) == NO_SIGNAL || (mode) == NO_LOCK || (mode) == OUT_OF_RANGE) |
121 | 132 | ||
@@ -318,6 +329,8 @@ struct vivid_dev { | |||
318 | v4l2_std_id std_out; | 329 | v4l2_std_id std_out; |
319 | struct v4l2_dv_timings dv_timings_out; | 330 | struct v4l2_dv_timings dv_timings_out; |
320 | u32 colorspace_out; | 331 | u32 colorspace_out; |
332 | u32 ycbcr_enc_out; | ||
333 | u32 quantization_out; | ||
321 | u32 service_set_out; | 334 | u32 service_set_out; |
322 | u32 bytesperline_out[2]; | 335 | u32 bytesperline_out[2]; |
323 | unsigned tv_field_out; | 336 | unsigned tv_field_out; |
@@ -514,7 +527,4 @@ static inline bool vivid_is_hdmi_out(const struct vivid_dev *dev) | |||
514 | return dev->output_type[dev->output] == HDMI; | 527 | return dev->output_type[dev->output] == HDMI; |
515 | } | 528 | } |
516 | 529 | ||
517 | void vivid_lock(struct vb2_queue *vq); | ||
518 | void vivid_unlock(struct vb2_queue *vq); | ||
519 | |||
520 | #endif | 530 | #endif |
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c index d5cbf0038f24..857e7866e8bc 100644 --- a/drivers/media/platform/vivid/vivid-ctrls.c +++ b/drivers/media/platform/vivid/vivid-ctrls.c | |||
@@ -40,6 +40,9 @@ | |||
40 | #define VIVID_CID_STRING (VIVID_CID_CUSTOM_BASE + 5) | 40 | #define VIVID_CID_STRING (VIVID_CID_CUSTOM_BASE + 5) |
41 | #define VIVID_CID_BITMASK (VIVID_CID_CUSTOM_BASE + 6) | 41 | #define VIVID_CID_BITMASK (VIVID_CID_CUSTOM_BASE + 6) |
42 | #define VIVID_CID_INTMENU (VIVID_CID_CUSTOM_BASE + 7) | 42 | #define VIVID_CID_INTMENU (VIVID_CID_CUSTOM_BASE + 7) |
43 | #define VIVID_CID_U32_ARRAY (VIVID_CID_CUSTOM_BASE + 8) | ||
44 | #define VIVID_CID_U16_MATRIX (VIVID_CID_CUSTOM_BASE + 9) | ||
45 | #define VIVID_CID_U8_4D_ARRAY (VIVID_CID_CUSTOM_BASE + 10) | ||
43 | 46 | ||
44 | #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) | 47 | #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000) |
45 | #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) | 48 | #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1) |
@@ -59,19 +62,21 @@ | |||
59 | #define VIVID_CID_DV_TIMINGS_ASPECT_RATIO (VIVID_CID_VIVID_BASE + 23) | 62 | #define VIVID_CID_DV_TIMINGS_ASPECT_RATIO (VIVID_CID_VIVID_BASE + 23) |
60 | #define VIVID_CID_TSTAMP_SRC (VIVID_CID_VIVID_BASE + 24) | 63 | #define VIVID_CID_TSTAMP_SRC (VIVID_CID_VIVID_BASE + 24) |
61 | #define VIVID_CID_COLORSPACE (VIVID_CID_VIVID_BASE + 25) | 64 | #define VIVID_CID_COLORSPACE (VIVID_CID_VIVID_BASE + 25) |
62 | #define VIVID_CID_LIMITED_RGB_RANGE (VIVID_CID_VIVID_BASE + 26) | 65 | #define VIVID_CID_YCBCR_ENC (VIVID_CID_VIVID_BASE + 26) |
63 | #define VIVID_CID_ALPHA_MODE (VIVID_CID_VIVID_BASE + 27) | 66 | #define VIVID_CID_QUANTIZATION (VIVID_CID_VIVID_BASE + 27) |
64 | #define VIVID_CID_HAS_CROP_CAP (VIVID_CID_VIVID_BASE + 28) | 67 | #define VIVID_CID_LIMITED_RGB_RANGE (VIVID_CID_VIVID_BASE + 28) |
65 | #define VIVID_CID_HAS_COMPOSE_CAP (VIVID_CID_VIVID_BASE + 29) | 68 | #define VIVID_CID_ALPHA_MODE (VIVID_CID_VIVID_BASE + 29) |
66 | #define VIVID_CID_HAS_SCALER_CAP (VIVID_CID_VIVID_BASE + 30) | 69 | #define VIVID_CID_HAS_CROP_CAP (VIVID_CID_VIVID_BASE + 30) |
67 | #define VIVID_CID_HAS_CROP_OUT (VIVID_CID_VIVID_BASE + 31) | 70 | #define VIVID_CID_HAS_COMPOSE_CAP (VIVID_CID_VIVID_BASE + 31) |
68 | #define VIVID_CID_HAS_COMPOSE_OUT (VIVID_CID_VIVID_BASE + 32) | 71 | #define VIVID_CID_HAS_SCALER_CAP (VIVID_CID_VIVID_BASE + 32) |
69 | #define VIVID_CID_HAS_SCALER_OUT (VIVID_CID_VIVID_BASE + 33) | 72 | #define VIVID_CID_HAS_CROP_OUT (VIVID_CID_VIVID_BASE + 33) |
70 | #define VIVID_CID_LOOP_VIDEO (VIVID_CID_VIVID_BASE + 34) | 73 | #define VIVID_CID_HAS_COMPOSE_OUT (VIVID_CID_VIVID_BASE + 34) |
71 | #define VIVID_CID_SEQ_WRAP (VIVID_CID_VIVID_BASE + 35) | 74 | #define VIVID_CID_HAS_SCALER_OUT (VIVID_CID_VIVID_BASE + 35) |
72 | #define VIVID_CID_TIME_WRAP (VIVID_CID_VIVID_BASE + 36) | 75 | #define VIVID_CID_LOOP_VIDEO (VIVID_CID_VIVID_BASE + 36) |
73 | #define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 37) | 76 | #define VIVID_CID_SEQ_WRAP (VIVID_CID_VIVID_BASE + 37) |
74 | #define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 38) | 77 | #define VIVID_CID_TIME_WRAP (VIVID_CID_VIVID_BASE + 38) |
78 | #define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 39) | ||
79 | #define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 40) | ||
75 | 80 | ||
76 | #define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60) | 81 | #define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60) |
77 | #define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61) | 82 | #define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61) |
@@ -163,6 +168,42 @@ static const struct v4l2_ctrl_config vivid_ctrl_int64 = { | |||
163 | .step = 1, | 168 | .step = 1, |
164 | }; | 169 | }; |
165 | 170 | ||
171 | static const struct v4l2_ctrl_config vivid_ctrl_u32_array = { | ||
172 | .ops = &vivid_user_gen_ctrl_ops, | ||
173 | .id = VIVID_CID_U32_ARRAY, | ||
174 | .name = "U32 1 Element Array", | ||
175 | .type = V4L2_CTRL_TYPE_U32, | ||
176 | .def = 0x18, | ||
177 | .min = 0x10, | ||
178 | .max = 0x20000, | ||
179 | .step = 1, | ||
180 | .dims = { 1 }, | ||
181 | }; | ||
182 | |||
183 | static const struct v4l2_ctrl_config vivid_ctrl_u16_matrix = { | ||
184 | .ops = &vivid_user_gen_ctrl_ops, | ||
185 | .id = VIVID_CID_U16_MATRIX, | ||
186 | .name = "U16 8x16 Matrix", | ||
187 | .type = V4L2_CTRL_TYPE_U16, | ||
188 | .def = 0x18, | ||
189 | .min = 0x10, | ||
190 | .max = 0x2000, | ||
191 | .step = 1, | ||
192 | .dims = { 8, 16 }, | ||
193 | }; | ||
194 | |||
195 | static const struct v4l2_ctrl_config vivid_ctrl_u8_4d_array = { | ||
196 | .ops = &vivid_user_gen_ctrl_ops, | ||
197 | .id = VIVID_CID_U8_4D_ARRAY, | ||
198 | .name = "U8 2x3x4x5 Array", | ||
199 | .type = V4L2_CTRL_TYPE_U8, | ||
200 | .def = 0x18, | ||
201 | .min = 0x10, | ||
202 | .max = 0x20, | ||
203 | .step = 1, | ||
204 | .dims = { 2, 3, 4, 5 }, | ||
205 | }; | ||
206 | |||
166 | static const char * const vivid_ctrl_menu_strings[] = { | 207 | static const char * const vivid_ctrl_menu_strings[] = { |
167 | "Menu Item 0 (Skipped)", | 208 | "Menu Item 0 (Skipped)", |
168 | "Menu Item 1", | 209 | "Menu Item 1", |
@@ -294,6 +335,16 @@ static const struct v4l2_ctrl_ops vivid_user_vid_ctrl_ops = { | |||
294 | 335 | ||
295 | static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl) | 336 | static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl) |
296 | { | 337 | { |
338 | static const u32 colorspaces[] = { | ||
339 | V4L2_COLORSPACE_SMPTE170M, | ||
340 | V4L2_COLORSPACE_REC709, | ||
341 | V4L2_COLORSPACE_SRGB, | ||
342 | V4L2_COLORSPACE_ADOBERGB, | ||
343 | V4L2_COLORSPACE_BT2020, | ||
344 | V4L2_COLORSPACE_SMPTE240M, | ||
345 | V4L2_COLORSPACE_470_SYSTEM_M, | ||
346 | V4L2_COLORSPACE_470_SYSTEM_BG, | ||
347 | }; | ||
297 | struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_cap); | 348 | struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_cap); |
298 | unsigned i; | 349 | unsigned i; |
299 | 350 | ||
@@ -303,7 +354,21 @@ static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl) | |||
303 | tpg_s_pattern(&dev->tpg, ctrl->val); | 354 | tpg_s_pattern(&dev->tpg, ctrl->val); |
304 | break; | 355 | break; |
305 | case VIVID_CID_COLORSPACE: | 356 | case VIVID_CID_COLORSPACE: |
306 | tpg_s_colorspace(&dev->tpg, ctrl->val); | 357 | tpg_s_colorspace(&dev->tpg, colorspaces[ctrl->val]); |
358 | vivid_send_source_change(dev, TV); | ||
359 | vivid_send_source_change(dev, SVID); | ||
360 | vivid_send_source_change(dev, HDMI); | ||
361 | vivid_send_source_change(dev, WEBCAM); | ||
362 | break; | ||
363 | case VIVID_CID_YCBCR_ENC: | ||
364 | tpg_s_ycbcr_enc(&dev->tpg, ctrl->val); | ||
365 | vivid_send_source_change(dev, TV); | ||
366 | vivid_send_source_change(dev, SVID); | ||
367 | vivid_send_source_change(dev, HDMI); | ||
368 | vivid_send_source_change(dev, WEBCAM); | ||
369 | break; | ||
370 | case VIVID_CID_QUANTIZATION: | ||
371 | tpg_s_quantization(&dev->tpg, ctrl->val); | ||
307 | vivid_send_source_change(dev, TV); | 372 | vivid_send_source_change(dev, TV); |
308 | vivid_send_source_change(dev, SVID); | 373 | vivid_send_source_change(dev, SVID); |
309 | vivid_send_source_change(dev, HDMI); | 374 | vivid_send_source_change(dev, HDMI); |
@@ -623,15 +688,14 @@ static const struct v4l2_ctrl_config vivid_ctrl_max_edid_blocks = { | |||
623 | }; | 688 | }; |
624 | 689 | ||
625 | static const char * const vivid_ctrl_colorspace_strings[] = { | 690 | static const char * const vivid_ctrl_colorspace_strings[] = { |
626 | "", | ||
627 | "SMPTE 170M", | 691 | "SMPTE 170M", |
628 | "SMPTE 240M", | ||
629 | "REC 709", | 692 | "REC 709", |
630 | "", /* Skip Bt878 entry */ | 693 | "sRGB", |
694 | "AdobeRGB", | ||
695 | "BT.2020", | ||
696 | "SMPTE 240M", | ||
631 | "470 System M", | 697 | "470 System M", |
632 | "470 System BG", | 698 | "470 System BG", |
633 | "", /* Skip JPEG entry */ | ||
634 | "sRGB", | ||
635 | NULL, | 699 | NULL, |
636 | }; | 700 | }; |
637 | 701 | ||
@@ -640,13 +704,49 @@ static const struct v4l2_ctrl_config vivid_ctrl_colorspace = { | |||
640 | .id = VIVID_CID_COLORSPACE, | 704 | .id = VIVID_CID_COLORSPACE, |
641 | .name = "Colorspace", | 705 | .name = "Colorspace", |
642 | .type = V4L2_CTRL_TYPE_MENU, | 706 | .type = V4L2_CTRL_TYPE_MENU, |
643 | .min = 1, | 707 | .max = 7, |
644 | .max = 8, | 708 | .def = 2, |
645 | .menu_skip_mask = (1 << 4) | (1 << 7), | ||
646 | .def = 8, | ||
647 | .qmenu = vivid_ctrl_colorspace_strings, | 709 | .qmenu = vivid_ctrl_colorspace_strings, |
648 | }; | 710 | }; |
649 | 711 | ||
712 | static const char * const vivid_ctrl_ycbcr_enc_strings[] = { | ||
713 | "Default", | ||
714 | "ITU-R 601", | ||
715 | "Rec. 709", | ||
716 | "xvYCC 601", | ||
717 | "xvYCC 709", | ||
718 | "sYCC", | ||
719 | "BT.2020 Non-Constant Luminance", | ||
720 | "BT.2020 Constant Luminance", | ||
721 | "SMPTE 240M", | ||
722 | NULL, | ||
723 | }; | ||
724 | |||
725 | static const struct v4l2_ctrl_config vivid_ctrl_ycbcr_enc = { | ||
726 | .ops = &vivid_vid_cap_ctrl_ops, | ||
727 | .id = VIVID_CID_YCBCR_ENC, | ||
728 | .name = "Y'CbCr Encoding", | ||
729 | .type = V4L2_CTRL_TYPE_MENU, | ||
730 | .max = 8, | ||
731 | .qmenu = vivid_ctrl_ycbcr_enc_strings, | ||
732 | }; | ||
733 | |||
734 | static const char * const vivid_ctrl_quantization_strings[] = { | ||
735 | "Default", | ||
736 | "Full Range", | ||
737 | "Limited Range", | ||
738 | NULL, | ||
739 | }; | ||
740 | |||
741 | static const struct v4l2_ctrl_config vivid_ctrl_quantization = { | ||
742 | .ops = &vivid_vid_cap_ctrl_ops, | ||
743 | .id = VIVID_CID_QUANTIZATION, | ||
744 | .name = "Quantization", | ||
745 | .type = V4L2_CTRL_TYPE_MENU, | ||
746 | .max = 2, | ||
747 | .qmenu = vivid_ctrl_quantization_strings, | ||
748 | }; | ||
749 | |||
650 | static const struct v4l2_ctrl_config vivid_ctrl_alpha_mode = { | 750 | static const struct v4l2_ctrl_config vivid_ctrl_alpha_mode = { |
651 | .ops = &vivid_vid_cap_ctrl_ops, | 751 | .ops = &vivid_vid_cap_ctrl_ops, |
652 | .id = VIVID_CID_ALPHA_MODE, | 752 | .id = VIVID_CID_ALPHA_MODE, |
@@ -723,8 +823,12 @@ static int vivid_vid_out_s_ctrl(struct v4l2_ctrl *ctrl) | |||
723 | dev->colorspace_out = V4L2_COLORSPACE_SMPTE170M; | 823 | dev->colorspace_out = V4L2_COLORSPACE_SMPTE170M; |
724 | else | 824 | else |
725 | dev->colorspace_out = V4L2_COLORSPACE_REC709; | 825 | dev->colorspace_out = V4L2_COLORSPACE_REC709; |
826 | dev->quantization_out = V4L2_QUANTIZATION_DEFAULT; | ||
726 | } else { | 827 | } else { |
727 | dev->colorspace_out = V4L2_COLORSPACE_SRGB; | 828 | dev->colorspace_out = V4L2_COLORSPACE_SRGB; |
829 | dev->quantization_out = dev->dvi_d_out ? | ||
830 | V4L2_QUANTIZATION_LIM_RANGE : | ||
831 | V4L2_QUANTIZATION_DEFAULT; | ||
728 | } | 832 | } |
729 | if (dev->loop_video) | 833 | if (dev->loop_video) |
730 | vivid_send_source_change(dev, HDMI); | 834 | vivid_send_source_change(dev, HDMI); |
@@ -792,15 +896,15 @@ static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl) | |||
792 | dev->start_streaming_error = true; | 896 | dev->start_streaming_error = true; |
793 | break; | 897 | break; |
794 | case VIVID_CID_QUEUE_ERROR: | 898 | case VIVID_CID_QUEUE_ERROR: |
795 | if (dev->vb_vid_cap_q.start_streaming_called) | 899 | if (vb2_start_streaming_called(&dev->vb_vid_cap_q)) |
796 | vb2_queue_error(&dev->vb_vid_cap_q); | 900 | vb2_queue_error(&dev->vb_vid_cap_q); |
797 | if (dev->vb_vbi_cap_q.start_streaming_called) | 901 | if (vb2_start_streaming_called(&dev->vb_vbi_cap_q)) |
798 | vb2_queue_error(&dev->vb_vbi_cap_q); | 902 | vb2_queue_error(&dev->vb_vbi_cap_q); |
799 | if (dev->vb_vid_out_q.start_streaming_called) | 903 | if (vb2_start_streaming_called(&dev->vb_vid_out_q)) |
800 | vb2_queue_error(&dev->vb_vid_out_q); | 904 | vb2_queue_error(&dev->vb_vid_out_q); |
801 | if (dev->vb_vbi_out_q.start_streaming_called) | 905 | if (vb2_start_streaming_called(&dev->vb_vbi_out_q)) |
802 | vb2_queue_error(&dev->vb_vbi_out_q); | 906 | vb2_queue_error(&dev->vb_vbi_out_q); |
803 | if (dev->vb_sdr_cap_q.start_streaming_called) | 907 | if (vb2_start_streaming_called(&dev->vb_sdr_cap_q)) |
804 | vb2_queue_error(&dev->vb_sdr_cap_q); | 908 | vb2_queue_error(&dev->vb_sdr_cap_q); |
805 | break; | 909 | break; |
806 | case VIVID_CID_SEQ_WRAP: | 910 | case VIVID_CID_SEQ_WRAP: |
@@ -1222,6 +1326,9 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap, | |||
1222 | dev->string = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_string, NULL); | 1326 | dev->string = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_string, NULL); |
1223 | dev->bitmask = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_bitmask, NULL); | 1327 | dev->bitmask = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_bitmask, NULL); |
1224 | dev->int_menu = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu, NULL); | 1328 | dev->int_menu = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu, NULL); |
1329 | v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL); | ||
1330 | v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL); | ||
1331 | v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u8_4d_array, NULL); | ||
1225 | 1332 | ||
1226 | if (dev->has_vid_cap) { | 1333 | if (dev->has_vid_cap) { |
1227 | /* Image Processing Controls */ | 1334 | /* Image Processing Controls */ |
@@ -1258,6 +1365,8 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap, | |||
1258 | v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_tstamp_src, NULL); | 1365 | v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_tstamp_src, NULL); |
1259 | dev->colorspace = v4l2_ctrl_new_custom(hdl_vid_cap, | 1366 | dev->colorspace = v4l2_ctrl_new_custom(hdl_vid_cap, |
1260 | &vivid_ctrl_colorspace, NULL); | 1367 | &vivid_ctrl_colorspace, NULL); |
1368 | v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_ycbcr_enc, NULL); | ||
1369 | v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_quantization, NULL); | ||
1261 | v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_alpha_mode, NULL); | 1370 | v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_alpha_mode, NULL); |
1262 | } | 1371 | } |
1263 | 1372 | ||
diff --git a/drivers/media/platform/vivid/vivid-sdr-cap.c b/drivers/media/platform/vivid/vivid-sdr-cap.c index 8c5d661cfc49..4af55f18829f 100644 --- a/drivers/media/platform/vivid/vivid-sdr-cap.c +++ b/drivers/media/platform/vivid/vivid-sdr-cap.c | |||
@@ -297,8 +297,8 @@ const struct vb2_ops vivid_sdr_cap_qops = { | |||
297 | .buf_queue = sdr_cap_buf_queue, | 297 | .buf_queue = sdr_cap_buf_queue, |
298 | .start_streaming = sdr_cap_start_streaming, | 298 | .start_streaming = sdr_cap_start_streaming, |
299 | .stop_streaming = sdr_cap_stop_streaming, | 299 | .stop_streaming = sdr_cap_stop_streaming, |
300 | .wait_prepare = vivid_unlock, | 300 | .wait_prepare = vb2_ops_wait_prepare, |
301 | .wait_finish = vivid_lock, | 301 | .wait_finish = vb2_ops_wait_finish, |
302 | }; | 302 | }; |
303 | 303 | ||
304 | int vivid_sdr_enum_freq_bands(struct file *file, void *fh, struct v4l2_frequency_band *band) | 304 | int vivid_sdr_enum_freq_bands(struct file *file, void *fh, struct v4l2_frequency_band *band) |
diff --git a/drivers/media/platform/vivid/vivid-tpg-colors.c b/drivers/media/platform/vivid/vivid-tpg-colors.c index 2adddc0ca662..424aa7abc723 100644 --- a/drivers/media/platform/vivid/vivid-tpg-colors.c +++ b/drivers/media/platform/vivid/vivid-tpg-colors.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * This source also contains the code used to generate the tpg_csc_colors | 12 | * This source also contains the code used to generate the tpg_csc_colors |
13 | * table. Run the following command to compile it: | 13 | * table. Run the following command to compile it: |
14 | * | 14 | * |
15 | * gcc vivid-colors.c -DCOMPILE_APP -o gen-colors -lm | 15 | * gcc vivid-tpg-colors.c -DCOMPILE_APP -o gen-colors -lm |
16 | * | 16 | * |
17 | * and run the utility. | 17 | * and run the utility. |
18 | * | 18 | * |
@@ -78,22 +78,542 @@ const struct color tpg_colors[TPG_COLOR_MAX] = { | |||
78 | #ifndef COMPILE_APP | 78 | #ifndef COMPILE_APP |
79 | 79 | ||
80 | /* Generated table */ | 80 | /* Generated table */ |
81 | const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLACK + 1] = { | 81 | const unsigned short tpg_rec709_to_linear[255 * 16 + 1] = { |
82 | [V4L2_COLORSPACE_SMPTE170M][0] = { 2953, 2939, 2939 }, | 82 | 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
83 | [V4L2_COLORSPACE_SMPTE170M][1] = { 2954, 2963, 585 }, | 83 | 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, |
84 | [V4L2_COLORSPACE_SMPTE170M][2] = { 84, 2967, 2937 }, | 84 | 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, |
85 | [V4L2_COLORSPACE_SMPTE170M][3] = { 93, 2990, 575 }, | 85 | 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, |
86 | [V4L2_COLORSPACE_SMPTE170M][4] = { 3030, 259, 2933 }, | 86 | 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, |
87 | [V4L2_COLORSPACE_SMPTE170M][5] = { 3031, 406, 557 }, | 87 | 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, |
88 | [V4L2_COLORSPACE_SMPTE170M][6] = { 544, 428, 2931 }, | 88 | 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, |
89 | [V4L2_COLORSPACE_SMPTE170M][7] = { 551, 547, 547 }, | 89 | 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, |
90 | 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31, 31, 32, 32, | ||
91 | 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, | ||
92 | 36, 36, 36, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39, 39, | ||
93 | 39, 39, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 42, | ||
94 | 43, 43, 43, 43, 44, 44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, | ||
95 | 46, 46, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 49, 49, 49, 50, | ||
96 | 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, | ||
97 | 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 56, 57, | ||
98 | 57, 57, 57, 58, 58, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 60, | ||
99 | 60, 61, 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, | ||
100 | 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 67, 67, 67, | ||
101 | 68, 68, 68, 68, 68, 69, 69, 69, 69, 70, 70, 70, 70, 70, 71, 71, | ||
102 | 71, 71, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 74, 74, 74, 74, | ||
103 | 74, 75, 75, 75, 75, 76, 76, 76, 76, 76, 77, 77, 77, 77, 78, 78, | ||
104 | 78, 78, 79, 79, 79, 79, 79, 80, 80, 80, 80, 81, 81, 81, 81, 82, | ||
105 | 82, 82, 82, 82, 83, 83, 83, 83, 84, 84, 84, 84, 85, 85, 85, 85, | ||
106 | 86, 86, 86, 86, 87, 87, 87, 87, 88, 88, 88, 88, 89, 89, 89, 89, | ||
107 | 90, 90, 90, 90, 91, 91, 91, 91, 92, 92, 92, 92, 93, 93, 93, 93, | ||
108 | 94, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, | ||
109 | 98, 98, 98, 98, 99, 99, 99, 99, 100, 100, 100, 101, 101, 101, 101, 102, | ||
110 | 102, 102, 102, 103, 103, 103, 103, 104, 104, 104, 105, 105, 105, 105, 106, 106, | ||
111 | 106, 106, 107, 107, 107, 107, 108, 108, 108, 109, 109, 109, 109, 110, 110, 110, | ||
112 | 111, 111, 111, 111, 112, 112, 112, 112, 113, 113, 113, 114, 114, 114, 114, 115, | ||
113 | 115, 115, 116, 116, 116, 116, 117, 117, 117, 118, 118, 118, 118, 119, 119, 119, | ||
114 | 120, 120, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, | ||
115 | 124, 125, 125, 125, 125, 126, 126, 126, 127, 127, 127, 128, 128, 128, 128, 129, | ||
116 | 129, 129, 130, 130, 130, 131, 131, 131, 132, 132, 132, 132, 133, 133, 133, 134, | ||
117 | 134, 134, 135, 135, 135, 136, 136, 136, 136, 137, 137, 137, 138, 138, 138, 139, | ||
118 | 139, 139, 140, 140, 140, 141, 141, 141, 142, 142, 142, 142, 143, 143, 143, 144, | ||
119 | 144, 144, 145, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, | ||
120 | 149, 150, 150, 150, 151, 151, 151, 152, 152, 152, 153, 153, 153, 154, 154, 154, | ||
121 | 155, 155, 155, 156, 156, 156, 157, 157, 157, 158, 158, 158, 159, 159, 159, 160, | ||
122 | 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, | ||
123 | 165, 166, 166, 167, 167, 167, 168, 168, 168, 169, 169, 169, 170, 170, 170, 171, | ||
124 | 171, 171, 172, 172, 172, 173, 173, 174, 174, 174, 175, 175, 175, 176, 176, 176, | ||
125 | 177, 177, 177, 178, 178, 179, 179, 179, 180, 180, 180, 181, 181, 181, 182, 182, | ||
126 | 183, 183, 183, 184, 184, 184, 185, 185, 186, 186, 186, 187, 187, 187, 188, 188, | ||
127 | 188, 189, 189, 190, 190, 190, 191, 191, 191, 192, 192, 193, 193, 193, 194, 194, | ||
128 | 194, 195, 195, 196, 196, 196, 197, 197, 198, 198, 198, 199, 199, 199, 200, 200, | ||
129 | 201, 201, 201, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 206, 206, 206, | ||
130 | 207, 207, 208, 208, 208, 209, 209, 210, 210, 210, 211, 211, 212, 212, 212, 213, | ||
131 | 213, 214, 214, 214, 215, 215, 216, 216, 216, 217, 217, 218, 218, 218, 219, 219, | ||
132 | 220, 220, 220, 221, 221, 222, 222, 222, 223, 223, 224, 224, 224, 225, 225, 226, | ||
133 | 226, 227, 227, 227, 228, 228, 229, 229, 229, 230, 230, 231, 231, 232, 232, 232, | ||
134 | 233, 233, 234, 234, 234, 235, 235, 236, 236, 237, 237, 237, 238, 238, 239, 239, | ||
135 | 240, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244, 245, 245, 246, 246, | ||
136 | 246, 247, 247, 248, 248, 249, 249, 249, 250, 250, 251, 251, 252, 252, 252, 253, | ||
137 | 253, 254, 254, 255, 255, 256, 256, 256, 257, 257, 258, 258, 259, 259, 260, 260, | ||
138 | 260, 261, 261, 262, 262, 263, 263, 264, 264, 264, 265, 265, 266, 266, 267, 267, | ||
139 | 268, 268, 269, 269, 269, 270, 270, 271, 271, 272, 272, 273, 273, 274, 274, 274, | ||
140 | 275, 275, 276, 276, 277, 277, 278, 278, 279, 279, 279, 280, 280, 281, 281, 282, | ||
141 | 282, 283, 283, 284, 284, 285, 285, 286, 286, 286, 287, 287, 288, 288, 289, 289, | ||
142 | 290, 290, 291, 291, 292, 292, 293, 293, 294, 294, 295, 295, 295, 296, 296, 297, | ||
143 | 297, 298, 298, 299, 299, 300, 300, 301, 301, 302, 302, 303, 303, 304, 304, 305, | ||
144 | 305, 306, 306, 307, 307, 308, 308, 309, 309, 309, 310, 310, 311, 311, 312, 312, | ||
145 | 313, 313, 314, 314, 315, 315, 316, 316, 317, 317, 318, 318, 319, 319, 320, 320, | ||
146 | 321, 321, 322, 322, 323, 323, 324, 324, 325, 325, 326, 326, 327, 327, 328, 328, | ||
147 | 329, 329, 330, 330, 331, 331, 332, 332, 333, 333, 334, 335, 335, 336, 336, 337, | ||
148 | 337, 338, 338, 339, 339, 340, 340, 341, 341, 342, 342, 343, 343, 344, 344, 345, | ||
149 | 345, 346, 346, 347, 347, 348, 348, 349, 349, 350, 351, 351, 352, 352, 353, 353, | ||
150 | 354, 354, 355, 355, 356, 356, 357, 357, 358, 358, 359, 360, 360, 361, 361, 362, | ||
151 | 362, 363, 363, 364, 364, 365, 365, 366, 366, 367, 368, 368, 369, 369, 370, 370, | ||
152 | 371, 371, 372, 372, 373, 373, 374, 375, 375, 376, 376, 377, 377, 378, 378, 379, | ||
153 | 379, 380, 381, 381, 382, 382, 383, 383, 384, 384, 385, 386, 386, 387, 387, 388, | ||
154 | 388, 389, 389, 390, 391, 391, 392, 392, 393, 393, 394, 394, 395, 396, 396, 397, | ||
155 | 397, 398, 398, 399, 399, 400, 401, 401, 402, 402, 403, 403, 404, 405, 405, 406, | ||
156 | 406, 407, 407, 408, 409, 409, 410, 410, 411, 411, 412, 413, 413, 414, 414, 415, | ||
157 | 415, 416, 417, 417, 418, 418, 419, 419, 420, 421, 421, 422, 422, 423, 424, 424, | ||
158 | 425, 425, 426, 426, 427, 428, 428, 429, 429, 430, 431, 431, 432, 432, 433, 433, | ||
159 | 434, 435, 435, 436, 436, 437, 438, 438, 439, 439, 440, 441, 441, 442, 442, 443, | ||
160 | 444, 444, 445, 445, 446, 447, 447, 448, 448, 449, 450, 450, 451, 451, 452, 453, | ||
161 | 453, 454, 454, 455, 456, 456, 457, 457, 458, 459, 459, 460, 460, 461, 462, 462, | ||
162 | 463, 463, 464, 465, 465, 466, 467, 467, 468, 468, 469, 470, 470, 471, 471, 472, | ||
163 | 473, 473, 474, 475, 475, 476, 476, 477, 478, 478, 479, 480, 480, 481, 481, 482, | ||
164 | 483, 483, 484, 485, 485, 486, 486, 487, 488, 488, 489, 490, 490, 491, 491, 492, | ||
165 | 493, 493, 494, 495, 495, 496, 497, 497, 498, 498, 499, 500, 500, 501, 502, 502, | ||
166 | 503, 504, 504, 505, 505, 506, 507, 507, 508, 509, 509, 510, 511, 511, 512, 513, | ||
167 | 513, 514, 514, 515, 516, 516, 517, 518, 518, 519, 520, 520, 521, 522, 522, 523, | ||
168 | 524, 524, 525, 526, 526, 527, 528, 528, 529, 529, 530, 531, 531, 532, 533, 533, | ||
169 | 534, 535, 535, 536, 537, 537, 538, 539, 539, 540, 541, 541, 542, 543, 543, 544, | ||
170 | 545, 545, 546, 547, 547, 548, 549, 549, 550, 551, 551, 552, 553, 553, 554, 555, | ||
171 | 555, 556, 557, 557, 558, 559, 560, 560, 561, 562, 562, 563, 564, 564, 565, 566, | ||
172 | 566, 567, 568, 568, 569, 570, 570, 571, 572, 572, 573, 574, 575, 575, 576, 577, | ||
173 | 577, 578, 579, 579, 580, 581, 581, 582, 583, 584, 584, 585, 586, 586, 587, 588, | ||
174 | 588, 589, 590, 590, 591, 592, 593, 593, 594, 595, 595, 596, 597, 598, 598, 599, | ||
175 | 600, 600, 601, 602, 602, 603, 604, 605, 605, 606, 607, 607, 608, 609, 610, 610, | ||
176 | 611, 612, 612, 613, 614, 615, 615, 616, 617, 617, 618, 619, 620, 620, 621, 622, | ||
177 | 622, 623, 624, 625, 625, 626, 627, 627, 628, 629, 630, 630, 631, 632, 632, 633, | ||
178 | 634, 635, 635, 636, 637, 638, 638, 639, 640, 640, 641, 642, 643, 643, 644, 645, | ||
179 | 646, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 654, 655, 656, 657, | ||
180 | 657, 658, 659, 660, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, | ||
181 | 669, 670, 671, 672, 672, 673, 674, 675, 675, 676, 677, 678, 678, 679, 680, 681, | ||
182 | 681, 682, 683, 684, 684, 685, 686, 687, 687, 688, 689, 690, 690, 691, 692, 693, | ||
183 | 694, 694, 695, 696, 697, 697, 698, 699, 700, 700, 701, 702, 703, 703, 704, 705, | ||
184 | 706, 707, 707, 708, 709, 710, 710, 711, 712, 713, 714, 714, 715, 716, 717, 717, | ||
185 | 718, 719, 720, 720, 721, 722, 723, 724, 724, 725, 726, 727, 728, 728, 729, 730, | ||
186 | 731, 731, 732, 733, 734, 735, 735, 736, 737, 738, 739, 739, 740, 741, 742, 742, | ||
187 | 743, 744, 745, 746, 746, 747, 748, 749, 750, 750, 751, 752, 753, 754, 754, 755, | ||
188 | 756, 757, 758, 758, 759, 760, 761, 762, 762, 763, 764, 765, 766, 766, 767, 768, | ||
189 | 769, 770, 771, 771, 772, 773, 774, 775, 775, 776, 777, 778, 779, 779, 780, 781, | ||
190 | 782, 783, 783, 784, 785, 786, 787, 788, 788, 789, 790, 791, 792, 793, 793, 794, | ||
191 | 795, 796, 797, 797, 798, 799, 800, 801, 802, 802, 803, 804, 805, 806, 807, 807, | ||
192 | 808, 809, 810, 811, 812, 812, 813, 814, 815, 816, 817, 817, 818, 819, 820, 821, | ||
193 | 822, 822, 823, 824, 825, 826, 827, 827, 828, 829, 830, 831, 832, 832, 833, 834, | ||
194 | 835, 836, 837, 838, 838, 839, 840, 841, 842, 843, 843, 844, 845, 846, 847, 848, | ||
195 | 849, 849, 850, 851, 852, 853, 854, 855, 855, 856, 857, 858, 859, 860, 861, 861, | ||
196 | 862, 863, 864, 865, 866, 867, 867, 868, 869, 870, 871, 872, 873, 873, 874, 875, | ||
197 | 876, 877, 878, 879, 880, 880, 881, 882, 883, 884, 885, 886, 887, 887, 888, 889, | ||
198 | 890, 891, 892, 893, 894, 894, 895, 896, 897, 898, 899, 900, 901, 901, 902, 903, | ||
199 | 904, 905, 906, 907, 908, 909, 909, 910, 911, 912, 913, 914, 915, 916, 916, 917, | ||
200 | 918, 919, 920, 921, 922, 923, 924, 925, 925, 926, 927, 928, 929, 930, 931, 932, | ||
201 | 933, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 942, 943, 944, 945, 946, | ||
202 | 947, 948, 949, 950, 951, 952, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, | ||
203 | 962, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 973, 974, 975, | ||
204 | 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 985, 986, 987, 988, 989, 990, | ||
205 | 991, 992, 993, 994, 995, 996, 997, 998, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, | ||
206 | 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, | ||
207 | 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1030, 1031, 1032, 1033, 1034, 1035, | ||
208 | 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1050, | ||
209 | 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, | ||
210 | 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1078, 1079, 1080, 1081, | ||
211 | 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, | ||
212 | 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, | ||
213 | 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, | ||
214 | 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, | ||
215 | 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, | ||
216 | 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, | ||
217 | 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1193, 1194, | ||
218 | 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, | ||
219 | 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1223, 1224, 1225, 1226, 1227, | ||
220 | 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, | ||
221 | 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, | ||
222 | 1261, 1262, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, | ||
223 | 1278, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1295, | ||
224 | 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1309, 1310, 1311, 1312, | ||
225 | 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, | ||
226 | 1330, 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1345, 1346, 1347, | ||
227 | 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, | ||
228 | 1365, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1377, 1378, 1379, 1380, 1381, 1382, | ||
229 | 1383, 1384, 1385, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1396, 1397, 1398, 1399, 1400, | ||
230 | 1401, 1402, 1403, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1414, 1415, 1416, 1417, 1418, | ||
231 | 1419, 1420, 1421, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1431, 1432, 1433, 1434, 1435, 1436, | ||
232 | 1437, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1448, 1449, 1450, 1451, 1452, 1453, 1455, | ||
233 | 1456, 1457, 1458, 1459, 1460, 1461, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1471, 1472, 1473, | ||
234 | 1474, 1475, 1476, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1486, 1487, 1488, 1489, 1490, 1491, | ||
235 | 1493, 1494, 1495, 1496, 1497, 1498, 1500, 1501, 1502, 1503, 1504, 1505, 1507, 1508, 1509, 1510, | ||
236 | 1511, 1512, 1514, 1515, 1516, 1517, 1518, 1519, 1521, 1522, 1523, 1524, 1525, 1527, 1528, 1529, | ||
237 | 1530, 1531, 1532, 1534, 1535, 1536, 1537, 1538, 1540, 1541, 1542, 1543, 1544, 1545, 1547, 1548, | ||
238 | 1549, 1550, 1551, 1553, 1554, 1555, 1556, 1557, 1559, 1560, 1561, 1562, 1563, 1564, 1566, 1567, | ||
239 | 1568, 1569, 1570, 1572, 1573, 1574, 1575, 1576, 1578, 1579, 1580, 1581, 1582, 1584, 1585, 1586, | ||
240 | 1587, 1588, 1590, 1591, 1592, 1593, 1594, 1596, 1597, 1598, 1599, 1601, 1602, 1603, 1604, 1605, | ||
241 | 1607, 1608, 1609, 1610, 1611, 1613, 1614, 1615, 1616, 1617, 1619, 1620, 1621, 1622, 1624, 1625, | ||
242 | 1626, 1627, 1628, 1630, 1631, 1632, 1633, 1635, 1636, 1637, 1638, 1639, 1641, 1642, 1643, 1644, | ||
243 | 1646, 1647, 1648, 1649, 1650, 1652, 1653, 1654, 1655, 1657, 1658, 1659, 1660, 1662, 1663, 1664, | ||
244 | 1665, 1667, 1668, 1669, 1670, 1671, 1673, 1674, 1675, 1676, 1678, 1679, 1680, 1681, 1683, 1684, | ||
245 | 1685, 1686, 1688, 1689, 1690, 1691, 1693, 1694, 1695, 1696, 1698, 1699, 1700, 1701, 1703, 1704, | ||
246 | 1705, 1706, 1708, 1709, 1710, 1711, 1713, 1714, 1715, 1716, 1718, 1719, 1720, 1721, 1723, 1724, | ||
247 | 1725, 1726, 1728, 1729, 1730, 1731, 1733, 1734, 1735, 1737, 1738, 1739, 1740, 1742, 1743, 1744, | ||
248 | 1745, 1747, 1748, 1749, 1750, 1752, 1753, 1754, 1756, 1757, 1758, 1759, 1761, 1762, 1763, 1764, | ||
249 | 1766, 1767, 1768, 1770, 1771, 1772, 1773, 1775, 1776, 1777, 1778, 1780, 1781, 1782, 1784, 1785, | ||
250 | 1786, 1787, 1789, 1790, 1791, 1793, 1794, 1795, 1796, 1798, 1799, 1800, 1802, 1803, 1804, 1806, | ||
251 | 1807, 1808, 1809, 1811, 1812, 1813, 1815, 1816, 1817, 1818, 1820, 1821, 1822, 1824, 1825, 1826, | ||
252 | 1828, 1829, 1830, 1831, 1833, 1834, 1835, 1837, 1838, 1839, 1841, 1842, 1843, 1844, 1846, 1847, | ||
253 | 1848, 1850, 1851, 1852, 1854, 1855, 1856, 1858, 1859, 1860, 1862, 1863, 1864, 1865, 1867, 1868, | ||
254 | 1869, 1871, 1872, 1873, 1875, 1876, 1877, 1879, 1880, 1881, 1883, 1884, 1885, 1887, 1888, 1889, | ||
255 | 1891, 1892, 1893, 1894, 1896, 1897, 1898, 1900, 1901, 1902, 1904, 1905, 1906, 1908, 1909, 1910, | ||
256 | 1912, 1913, 1914, 1916, 1917, 1918, 1920, 1921, 1922, 1924, 1925, 1926, 1928, 1929, 1930, 1932, | ||
257 | 1933, 1935, 1936, 1937, 1939, 1940, 1941, 1943, 1944, 1945, 1947, 1948, 1949, 1951, 1952, 1953, | ||
258 | 1955, 1956, 1957, 1959, 1960, 1961, 1963, 1964, 1965, 1967, 1968, 1970, 1971, 1972, 1974, 1975, | ||
259 | 1976, 1978, 1979, 1980, 1982, 1983, 1984, 1986, 1987, 1989, 1990, 1991, 1993, 1994, 1995, 1997, | ||
260 | 1998, 1999, 2001, 2002, 2004, 2005, 2006, 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017, 2019, | ||
261 | 2020, 2021, 2023, 2024, 2026, 2027, 2028, 2030, 2031, 2032, 2034, 2035, 2037, 2038, 2039, 2041, | ||
262 | 2042, 2043, 2045, 2046, 2048, 2049, 2050, 2052, 2053, 2055, 2056, 2057, 2059, 2060, 2061, 2063, | ||
263 | 2064, 2066, 2067, 2068, 2070, 2071, 2073, 2074, 2075, 2077, 2078, 2080, 2081, 2082, 2084, 2085, | ||
264 | 2087, 2088, 2089, 2091, 2092, 2094, 2095, 2096, 2098, 2099, 2101, 2102, 2103, 2105, 2106, 2108, | ||
265 | 2109, 2110, 2112, 2113, 2115, 2116, 2117, 2119, 2120, 2122, 2123, 2124, 2126, 2127, 2129, 2130, | ||
266 | 2132, 2133, 2134, 2136, 2137, 2139, 2140, 2141, 2143, 2144, 2146, 2147, 2149, 2150, 2151, 2153, | ||
267 | 2154, 2156, 2157, 2159, 2160, 2161, 2163, 2164, 2166, 2167, 2169, 2170, 2171, 2173, 2174, 2176, | ||
268 | 2177, 2179, 2180, 2181, 2183, 2184, 2186, 2187, 2189, 2190, 2191, 2193, 2194, 2196, 2197, 2199, | ||
269 | 2200, 2202, 2203, 2204, 2206, 2207, 2209, 2210, 2212, 2213, 2214, 2216, 2217, 2219, 2220, 2222, | ||
270 | 2223, 2225, 2226, 2228, 2229, 2230, 2232, 2233, 2235, 2236, 2238, 2239, 2241, 2242, 2243, 2245, | ||
271 | 2246, 2248, 2249, 2251, 2252, 2254, 2255, 2257, 2258, 2260, 2261, 2262, 2264, 2265, 2267, 2268, | ||
272 | 2270, 2271, 2273, 2274, 2276, 2277, 2279, 2280, 2282, 2283, 2284, 2286, 2287, 2289, 2290, 2292, | ||
273 | 2293, 2295, 2296, 2298, 2299, 2301, 2302, 2304, 2305, 2307, 2308, 2310, 2311, 2312, 2314, 2315, | ||
274 | 2317, 2318, 2320, 2321, 2323, 2324, 2326, 2327, 2329, 2330, 2332, 2333, 2335, 2336, 2338, 2339, | ||
275 | 2341, 2342, 2344, 2345, 2347, 2348, 2350, 2351, 2353, 2354, 2356, 2357, 2359, 2360, 2362, 2363, | ||
276 | 2365, 2366, 2368, 2369, 2371, 2372, 2374, 2375, 2377, 2378, 2380, 2381, 2383, 2384, 2386, 2387, | ||
277 | 2389, 2390, 2392, 2393, 2395, 2396, 2398, 2399, 2401, 2402, 2404, 2405, 2407, 2408, 2410, 2411, | ||
278 | 2413, 2414, 2416, 2417, 2419, 2420, 2422, 2423, 2425, 2426, 2428, 2429, 2431, 2433, 2434, 2436, | ||
279 | 2437, 2439, 2440, 2442, 2443, 2445, 2446, 2448, 2449, 2451, 2452, 2454, 2455, 2457, 2458, 2460, | ||
280 | 2462, 2463, 2465, 2466, 2468, 2469, 2471, 2472, 2474, 2475, 2477, 2478, 2480, 2481, 2483, 2485, | ||
281 | 2486, 2488, 2489, 2491, 2492, 2494, 2495, 2497, 2498, 2500, 2502, 2503, 2505, 2506, 2508, 2509, | ||
282 | 2511, 2512, 2514, 2515, 2517, 2519, 2520, 2522, 2523, 2525, 2526, 2528, 2529, 2531, 2533, 2534, | ||
283 | 2536, 2537, 2539, 2540, 2542, 2543, 2545, 2547, 2548, 2550, 2551, 2553, 2554, 2556, 2557, 2559, | ||
284 | 2561, 2562, 2564, 2565, 2567, 2568, 2570, 2572, 2573, 2575, 2576, 2578, 2579, 2581, 2583, 2584, | ||
285 | 2586, 2587, 2589, 2590, 2592, 2594, 2595, 2597, 2598, 2600, 2601, 2603, 2605, 2606, 2608, 2609, | ||
286 | 2611, 2613, 2614, 2616, 2617, 2619, 2620, 2622, 2624, 2625, 2627, 2628, 2630, 2632, 2633, 2635, | ||
287 | 2636, 2638, 2640, 2641, 2643, 2644, 2646, 2647, 2649, 2651, 2652, 2654, 2655, 2657, 2659, 2660, | ||
288 | 2662, 2663, 2665, 2667, 2668, 2670, 2671, 2673, 2675, 2676, 2678, 2679, 2681, 2683, 2684, 2686, | ||
289 | 2687, 2689, 2691, 2692, 2694, 2696, 2697, 2699, 2700, 2702, 2704, 2705, 2707, 2708, 2710, 2712, | ||
290 | 2713, 2715, 2716, 2718, 2720, 2721, 2723, 2725, 2726, 2728, 2729, 2731, 2733, 2734, 2736, 2738, | ||
291 | 2739, 2741, 2742, 2744, 2746, 2747, 2749, 2751, 2752, 2754, 2755, 2757, 2759, 2760, 2762, 2764, | ||
292 | 2765, 2767, 2769, 2770, 2772, 2773, 2775, 2777, 2778, 2780, 2782, 2783, 2785, 2787, 2788, 2790, | ||
293 | 2791, 2793, 2795, 2796, 2798, 2800, 2801, 2803, 2805, 2806, 2808, 2810, 2811, 2813, 2814, 2816, | ||
294 | 2818, 2819, 2821, 2823, 2824, 2826, 2828, 2829, 2831, 2833, 2834, 2836, 2838, 2839, 2841, 2843, | ||
295 | 2844, 2846, 2848, 2849, 2851, 2853, 2854, 2856, 2857, 2859, 2861, 2862, 2864, 2866, 2867, 2869, | ||
296 | 2871, 2872, 2874, 2876, 2877, 2879, 2881, 2882, 2884, 2886, 2888, 2889, 2891, 2893, 2894, 2896, | ||
297 | 2898, 2899, 2901, 2903, 2904, 2906, 2908, 2909, 2911, 2913, 2914, 2916, 2918, 2919, 2921, 2923, | ||
298 | 2924, 2926, 2928, 2929, 2931, 2933, 2935, 2936, 2938, 2940, 2941, 2943, 2945, 2946, 2948, 2950, | ||
299 | 2951, 2953, 2955, 2956, 2958, 2960, 2962, 2963, 2965, 2967, 2968, 2970, 2972, 2973, 2975, 2977, | ||
300 | 2979, 2980, 2982, 2984, 2985, 2987, 2989, 2990, 2992, 2994, 2996, 2997, 2999, 3001, 3002, 3004, | ||
301 | 3006, 3008, 3009, 3011, 3013, 3014, 3016, 3018, 3020, 3021, 3023, 3025, 3026, 3028, 3030, 3032, | ||
302 | 3033, 3035, 3037, 3038, 3040, 3042, 3044, 3045, 3047, 3049, 3050, 3052, 3054, 3056, 3057, 3059, | ||
303 | 3061, 3063, 3064, 3066, 3068, 3069, 3071, 3073, 3075, 3076, 3078, 3080, 3082, 3083, 3085, 3087, | ||
304 | 3089, 3090, 3092, 3094, 3095, 3097, 3099, 3101, 3102, 3104, 3106, 3108, 3109, 3111, 3113, 3115, | ||
305 | 3116, 3118, 3120, 3122, 3123, 3125, 3127, 3129, 3130, 3132, 3134, 3136, 3137, 3139, 3141, 3143, | ||
306 | 3144, 3146, 3148, 3150, 3151, 3153, 3155, 3157, 3158, 3160, 3162, 3164, 3165, 3167, 3169, 3171, | ||
307 | 3172, 3174, 3176, 3178, 3179, 3181, 3183, 3185, 3187, 3188, 3190, 3192, 3194, 3195, 3197, 3199, | ||
308 | 3201, 3202, 3204, 3206, 3208, 3209, 3211, 3213, 3215, 3217, 3218, 3220, 3222, 3224, 3225, 3227, | ||
309 | 3229, 3231, 3233, 3234, 3236, 3238, 3240, 3241, 3243, 3245, 3247, 3249, 3250, 3252, 3254, 3256, | ||
310 | 3258, 3259, 3261, 3263, 3265, 3266, 3268, 3270, 3272, 3274, 3275, 3277, 3279, 3281, 3283, 3284, | ||
311 | 3286, 3288, 3290, 3292, 3293, 3295, 3297, 3299, 3301, 3302, 3304, 3306, 3308, 3310, 3311, 3313, | ||
312 | 3315, 3317, 3319, 3320, 3322, 3324, 3326, 3328, 3329, 3331, 3333, 3335, 3337, 3338, 3340, 3342, | ||
313 | 3344, 3346, 3348, 3349, 3351, 3353, 3355, 3357, 3358, 3360, 3362, 3364, 3366, 3368, 3369, 3371, | ||
314 | 3373, 3375, 3377, 3378, 3380, 3382, 3384, 3386, 3388, 3389, 3391, 3393, 3395, 3397, 3399, 3400, | ||
315 | 3402, 3404, 3406, 3408, 3410, 3411, 3413, 3415, 3417, 3419, 3421, 3422, 3424, 3426, 3428, 3430, | ||
316 | 3432, 3433, 3435, 3437, 3439, 3441, 3443, 3444, 3446, 3448, 3450, 3452, 3454, 3455, 3457, 3459, | ||
317 | 3461, 3463, 3465, 3467, 3468, 3470, 3472, 3474, 3476, 3478, 3480, 3481, 3483, 3485, 3487, 3489, | ||
318 | 3491, 3492, 3494, 3496, 3498, 3500, 3502, 3504, 3506, 3507, 3509, 3511, 3513, 3515, 3517, 3519, | ||
319 | 3520, 3522, 3524, 3526, 3528, 3530, 3532, 3533, 3535, 3537, 3539, 3541, 3543, 3545, 3547, 3548, | ||
320 | 3550, 3552, 3554, 3556, 3558, 3560, 3562, 3563, 3565, 3567, 3569, 3571, 3573, 3575, 3577, 3578, | ||
321 | 3580, 3582, 3584, 3586, 3588, 3590, 3592, 3594, 3595, 3597, 3599, 3601, 3603, 3605, 3607, 3609, | ||
322 | 3611, 3612, 3614, 3616, 3618, 3620, 3622, 3624, 3626, 3628, 3629, 3631, 3633, 3635, 3637, 3639, | ||
323 | 3641, 3643, 3645, 3647, 3648, 3650, 3652, 3654, 3656, 3658, 3660, 3662, 3664, 3666, 3667, 3669, | ||
324 | 3671, 3673, 3675, 3677, 3679, 3681, 3683, 3685, 3687, 3688, 3690, 3692, 3694, 3696, 3698, 3700, | ||
325 | 3702, 3704, 3706, 3708, 3710, 3711, 3713, 3715, 3717, 3719, 3721, 3723, 3725, 3727, 3729, 3731, | ||
326 | 3733, 3735, 3736, 3738, 3740, 3742, 3744, 3746, 3748, 3750, 3752, 3754, 3756, 3758, 3760, 3762, | ||
327 | 3764, 3765, 3767, 3769, 3771, 3773, 3775, 3777, 3779, 3781, 3783, 3785, 3787, 3789, 3791, 3793, | ||
328 | 3795, 3796, 3798, 3800, 3802, 3804, 3806, 3808, 3810, 3812, 3814, 3816, 3818, 3820, 3822, 3824, | ||
329 | 3826, 3828, 3830, 3832, 3833, 3835, 3837, 3839, 3841, 3843, 3845, 3847, 3849, 3851, 3853, 3855, | ||
330 | 3857, 3859, 3861, 3863, 3865, 3867, 3869, 3871, 3873, 3875, 3877, 3879, 3881, 3883, 3884, 3886, | ||
331 | 3888, 3890, 3892, 3894, 3896, 3898, 3900, 3902, 3904, 3906, 3908, 3910, 3912, 3914, 3916, 3918, | ||
332 | 3920, 3922, 3924, 3926, 3928, 3930, 3932, 3934, 3936, 3938, 3940, 3942, 3944, 3946, 3948, 3950, | ||
333 | 3952, 3954, 3956, 3958, 3960, 3962, 3964, 3966, 3968, 3970, 3972, 3974, 3976, 3978, 3980, 3982, | ||
334 | 3984, 3986, 3988, 3990, 3992, 3994, 3996, 3998, 4000, 4002, 4004, 4006, 4008, 4010, 4012, 4014, | ||
335 | 4016, 4018, 4020, 4022, 4024, 4026, 4028, 4030, 4032, 4034, 4036, 4038, 4040, 4042, 4044, 4046, | ||
336 | 4048, 4050, 4052, 4054, 4056, 4058, 4060, 4062, 4064, 4066, 4068, 4070, 4072, 4074, 4076, 4078, | ||
337 | 4080, | ||
338 | }; | ||
339 | |||
340 | /* Generated table */ | ||
341 | const unsigned short tpg_linear_to_rec709[255 * 16 + 1] = { | ||
342 | 0, 5, 9, 14, 18, 22, 27, 32, 36, 41, 45, 50, 54, 59, 63, 68, | ||
343 | 72, 77, 81, 86, 90, 95, 99, 104, 108, 113, 117, 122, 126, 131, 135, 139, | ||
344 | 144, 149, 153, 158, 162, 167, 171, 176, 180, 185, 189, 194, 198, 203, 207, 212, | ||
345 | 216, 221, 225, 230, 234, 239, 243, 248, 252, 257, 261, 266, 270, 275, 279, 284, | ||
346 | 288, 293, 297, 302, 306, 311, 315, 320, 324, 328, 334, 338, 343, 347, 352, 356, | ||
347 | 360, 365, 369, 373, 377, 381, 386, 390, 394, 398, 402, 406, 410, 414, 418, 422, | ||
348 | 426, 430, 433, 437, 441, 445, 449, 452, 456, 460, 464, 467, 471, 475, 478, 482, | ||
349 | 485, 489, 492, 496, 499, 503, 506, 510, 513, 517, 520, 524, 527, 530, 534, 537, | ||
350 | 540, 544, 547, 550, 554, 557, 560, 563, 566, 570, 573, 576, 579, 582, 586, 589, | ||
351 | 592, 595, 598, 601, 604, 607, 610, 613, 616, 619, 622, 625, 628, 631, 634, 637, | ||
352 | 640, 643, 646, 649, 652, 655, 658, 660, 663, 666, 669, 672, 675, 677, 680, 683, | ||
353 | 686, 689, 691, 694, 697, 700, 702, 705, 708, 711, 713, 716, 719, 721, 724, 727, | ||
354 | 729, 732, 735, 737, 740, 743, 745, 748, 750, 753, 756, 758, 761, 763, 766, 768, | ||
355 | 771, 773, 776, 779, 781, 784, 786, 789, 791, 794, 796, 799, 801, 803, 806, 808, | ||
356 | 811, 813, 816, 818, 821, 823, 825, 828, 830, 833, 835, 837, 840, 842, 844, 847, | ||
357 | 849, 851, 854, 856, 858, 861, 863, 865, 868, 870, 872, 875, 877, 879, 881, 884, | ||
358 | 886, 888, 891, 893, 895, 897, 900, 902, 904, 906, 908, 911, 913, 915, 917, 919, | ||
359 | 922, 924, 926, 928, 930, 933, 935, 937, 939, 941, 943, 946, 948, 950, 952, 954, | ||
360 | 956, 958, 960, 963, 965, 967, 969, 971, 973, 975, 977, 979, 981, 984, 986, 988, | ||
361 | 990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, | ||
362 | 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, 1048, 1050, 1052, | ||
363 | 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, 1069, 1071, 1073, 1075, 1077, 1079, 1081, 1083, | ||
364 | 1085, 1087, 1089, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1107, 1109, 1111, 1113, | ||
365 | 1115, 1117, 1119, 1120, 1122, 1124, 1126, 1128, 1130, 1131, 1133, 1135, 1137, 1139, 1141, 1142, | ||
366 | 1144, 1146, 1148, 1150, 1151, 1153, 1155, 1157, 1159, 1160, 1162, 1164, 1166, 1168, 1169, 1171, | ||
367 | 1173, 1175, 1176, 1178, 1180, 1182, 1184, 1185, 1187, 1189, 1191, 1192, 1194, 1196, 1198, 1199, | ||
368 | 1201, 1203, 1204, 1206, 1208, 1210, 1211, 1213, 1215, 1217, 1218, 1220, 1222, 1223, 1225, 1227, | ||
369 | 1228, 1230, 1232, 1234, 1235, 1237, 1239, 1240, 1242, 1244, 1245, 1247, 1249, 1250, 1252, 1254, | ||
370 | 1255, 1257, 1259, 1260, 1262, 1264, 1265, 1267, 1269, 1270, 1272, 1274, 1275, 1277, 1279, 1280, | ||
371 | 1282, 1283, 1285, 1287, 1288, 1290, 1292, 1293, 1295, 1296, 1298, 1300, 1301, 1303, 1305, 1306, | ||
372 | 1308, 1309, 1311, 1313, 1314, 1316, 1317, 1319, 1321, 1322, 1324, 1325, 1327, 1328, 1330, 1332, | ||
373 | 1333, 1335, 1336, 1338, 1339, 1341, 1343, 1344, 1346, 1347, 1349, 1350, 1352, 1354, 1355, 1357, | ||
374 | 1358, 1360, 1361, 1363, 1364, 1366, 1367, 1369, 1371, 1372, 1374, 1375, 1377, 1378, 1380, 1381, | ||
375 | 1383, 1384, 1386, 1387, 1389, 1390, 1392, 1393, 1395, 1396, 1398, 1399, 1401, 1402, 1404, 1405, | ||
376 | 1407, 1408, 1410, 1411, 1413, 1414, 1416, 1417, 1419, 1420, 1422, 1423, 1425, 1426, 1428, 1429, | ||
377 | 1431, 1432, 1434, 1435, 1437, 1438, 1440, 1441, 1442, 1444, 1445, 1447, 1448, 1450, 1451, 1453, | ||
378 | 1454, 1456, 1457, 1458, 1460, 1461, 1463, 1464, 1466, 1467, 1469, 1470, 1471, 1473, 1474, 1476, | ||
379 | 1477, 1479, 1480, 1481, 1483, 1484, 1486, 1487, 1489, 1490, 1491, 1493, 1494, 1496, 1497, 1498, | ||
380 | 1500, 1501, 1503, 1504, 1505, 1507, 1508, 1510, 1511, 1512, 1514, 1515, 1517, 1518, 1519, 1521, | ||
381 | 1522, 1524, 1525, 1526, 1528, 1529, 1531, 1532, 1533, 1535, 1536, 1537, 1539, 1540, 1542, 1543, | ||
382 | 1544, 1546, 1547, 1548, 1550, 1551, 1553, 1554, 1555, 1557, 1558, 1559, 1561, 1562, 1563, 1565, | ||
383 | 1566, 1567, 1569, 1570, 1571, 1573, 1574, 1576, 1577, 1578, 1580, 1581, 1582, 1584, 1585, 1586, | ||
384 | 1588, 1589, 1590, 1592, 1593, 1594, 1596, 1597, 1598, 1600, 1601, 1602, 1603, 1605, 1606, 1607, | ||
385 | 1609, 1610, 1611, 1613, 1614, 1615, 1617, 1618, 1619, 1621, 1622, 1623, 1624, 1626, 1627, 1628, | ||
386 | 1630, 1631, 1632, 1634, 1635, 1636, 1637, 1639, 1640, 1641, 1643, 1644, 1645, 1647, 1648, 1649, | ||
387 | 1650, 1652, 1653, 1654, 1655, 1657, 1658, 1659, 1661, 1662, 1663, 1664, 1666, 1667, 1668, 1670, | ||
388 | 1671, 1672, 1673, 1675, 1676, 1677, 1678, 1680, 1681, 1682, 1683, 1685, 1686, 1687, 1688, 1690, | ||
389 | 1691, 1692, 1693, 1695, 1696, 1697, 1698, 1700, 1701, 1702, 1703, 1705, 1706, 1707, 1708, 1710, | ||
390 | 1711, 1712, 1713, 1715, 1716, 1717, 1718, 1720, 1721, 1722, 1723, 1724, 1726, 1727, 1728, 1729, | ||
391 | 1731, 1732, 1733, 1734, 1736, 1737, 1738, 1739, 1740, 1742, 1743, 1744, 1745, 1746, 1748, 1749, | ||
392 | 1750, 1751, 1753, 1754, 1755, 1756, 1757, 1759, 1760, 1761, 1762, 1763, 1765, 1766, 1767, 1768, | ||
393 | 1769, 1771, 1772, 1773, 1774, 1775, 1777, 1778, 1779, 1780, 1781, 1783, 1784, 1785, 1786, 1787, | ||
394 | 1788, 1790, 1791, 1792, 1793, 1794, 1796, 1797, 1798, 1799, 1800, 1801, 1803, 1804, 1805, 1806, | ||
395 | 1807, 1809, 1810, 1811, 1812, 1813, 1814, 1816, 1817, 1818, 1819, 1820, 1821, 1823, 1824, 1825, | ||
396 | 1826, 1827, 1828, 1829, 1831, 1832, 1833, 1834, 1835, 1836, 1838, 1839, 1840, 1841, 1842, 1843, | ||
397 | 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1861, 1862, | ||
398 | 1863, 1864, 1865, 1866, 1867, 1868, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1878, 1879, 1880, | ||
399 | 1881, 1882, 1883, 1884, 1885, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1896, 1897, 1898, | ||
400 | 1899, 1900, 1901, 1902, 1903, 1904, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1916, | ||
401 | 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1927, 1928, 1929, 1930, 1931, 1932, 1933, | ||
402 | 1934, 1935, 1936, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1950, 1951, | ||
403 | 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1963, 1964, 1965, 1966, 1967, 1968, | ||
404 | 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, | ||
405 | 1986, 1987, 1988, 1989, 1990, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, | ||
406 | 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, | ||
407 | 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2031, 2032, 2033, 2034, 2035, 2036, | ||
408 | 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, | ||
409 | 2053, 2054, 2055, 2056, 2057, 2058, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, | ||
410 | 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, | ||
411 | 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, | ||
412 | 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, | ||
413 | 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, | ||
414 | 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, | ||
415 | 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, | ||
416 | 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, | ||
417 | 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196, | ||
418 | 2197, 2198, 2199, 2200, 2201, 2202, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, | ||
419 | 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2224, 2225, 2226, | ||
420 | 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2241, | ||
421 | 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, | ||
422 | 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2271, | ||
423 | 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2283, 2284, 2285, 2286, | ||
424 | 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2295, 2296, 2297, 2298, 2299, 2300, 2301, | ||
425 | 2302, 2303, 2304, 2305, 2306, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, | ||
426 | 2317, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2327, 2328, 2329, 2330, | ||
427 | 2331, 2332, 2333, 2334, 2335, 2336, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, | ||
428 | 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2354, 2355, 2356, 2357, 2358, 2359, | ||
429 | 2360, 2361, 2362, 2363, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2371, 2372, 2373, | ||
430 | 2374, 2375, 2376, 2377, 2378, 2379, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2386, 2387, | ||
431 | 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2401, | ||
432 | 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2415, | ||
433 | 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2428, 2429, | ||
434 | 2430, 2431, 2432, 2433, 2434, 2435, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2441, 2442, 2443, | ||
435 | 2444, 2445, 2446, 2447, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2453, 2454, 2455, 2456, 2457, | ||
436 | 2458, 2459, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2465, 2466, 2467, 2468, 2469, 2470, 2471, | ||
437 | 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2477, 2478, 2479, 2480, 2481, 2482, 2482, 2483, 2484, | ||
438 | 2485, 2486, 2487, 2488, 2488, 2489, 2490, 2491, 2492, 2493, 2493, 2494, 2495, 2496, 2497, 2498, | ||
439 | 2499, 2499, 2500, 2501, 2502, 2503, 2504, 2504, 2505, 2506, 2507, 2508, 2509, 2509, 2510, 2511, | ||
440 | 2512, 2513, 2514, 2514, 2515, 2516, 2517, 2518, 2519, 2519, 2520, 2521, 2522, 2523, 2524, 2524, | ||
441 | 2525, 2526, 2527, 2528, 2529, 2529, 2530, 2531, 2532, 2533, 2534, 2534, 2535, 2536, 2537, 2538, | ||
442 | 2539, 2539, 2540, 2541, 2542, 2543, 2544, 2544, 2545, 2546, 2547, 2548, 2548, 2549, 2550, 2551, | ||
443 | 2552, 2553, 2553, 2554, 2555, 2556, 2557, 2558, 2558, 2559, 2560, 2561, 2562, 2562, 2563, 2564, | ||
444 | 2565, 2566, 2567, 2567, 2568, 2569, 2570, 2571, 2571, 2572, 2573, 2574, 2575, 2576, 2576, 2577, | ||
445 | 2578, 2579, 2580, 2580, 2581, 2582, 2583, 2584, 2584, 2585, 2586, 2587, 2588, 2589, 2589, 2590, | ||
446 | 2591, 2592, 2593, 2593, 2594, 2595, 2596, 2597, 2597, 2598, 2599, 2600, 2601, 2601, 2602, 2603, | ||
447 | 2604, 2605, 2605, 2606, 2607, 2608, 2609, 2610, 2610, 2611, 2612, 2613, 2614, 2614, 2615, 2616, | ||
448 | 2617, 2618, 2618, 2619, 2620, 2621, 2622, 2622, 2623, 2624, 2625, 2626, 2626, 2627, 2628, 2629, | ||
449 | 2630, 2630, 2631, 2632, 2633, 2634, 2634, 2635, 2636, 2637, 2637, 2638, 2639, 2640, 2641, 2641, | ||
450 | 2642, 2643, 2644, 2645, 2645, 2646, 2647, 2648, 2649, 2649, 2650, 2651, 2652, 2653, 2653, 2654, | ||
451 | 2655, 2656, 2656, 2657, 2658, 2659, 2660, 2660, 2661, 2662, 2663, 2664, 2664, 2665, 2666, 2667, | ||
452 | 2668, 2668, 2669, 2670, 2671, 2671, 2672, 2673, 2674, 2675, 2675, 2676, 2677, 2678, 2678, 2679, | ||
453 | 2680, 2681, 2682, 2682, 2683, 2684, 2685, 2686, 2686, 2687, 2688, 2689, 2689, 2690, 2691, 2692, | ||
454 | 2693, 2693, 2694, 2695, 2696, 2696, 2697, 2698, 2699, 2700, 2700, 2701, 2702, 2703, 2703, 2704, | ||
455 | 2705, 2706, 2706, 2707, 2708, 2709, 2710, 2710, 2711, 2712, 2713, 2713, 2714, 2715, 2716, 2717, | ||
456 | 2717, 2718, 2719, 2720, 2720, 2721, 2722, 2723, 2723, 2724, 2725, 2726, 2727, 2727, 2728, 2729, | ||
457 | 2730, 2730, 2731, 2732, 2733, 2733, 2734, 2735, 2736, 2736, 2737, 2738, 2739, 2740, 2740, 2741, | ||
458 | 2742, 2743, 2743, 2744, 2745, 2746, 2746, 2747, 2748, 2749, 2749, 2750, 2751, 2752, 2752, 2753, | ||
459 | 2754, 2755, 2755, 2756, 2757, 2758, 2759, 2759, 2760, 2761, 2762, 2762, 2763, 2764, 2765, 2765, | ||
460 | 2766, 2767, 2768, 2768, 2769, 2770, 2771, 2771, 2772, 2773, 2774, 2774, 2775, 2776, 2777, 2777, | ||
461 | 2778, 2779, 2780, 2780, 2781, 2782, 2783, 2783, 2784, 2785, 2786, 2786, 2787, 2788, 2789, 2789, | ||
462 | 2790, 2791, 2792, 2792, 2793, 2794, 2795, 2795, 2796, 2797, 2798, 2798, 2799, 2800, 2801, 2801, | ||
463 | 2802, 2803, 2804, 2804, 2805, 2806, 2807, 2807, 2808, 2809, 2810, 2810, 2811, 2812, 2813, 2813, | ||
464 | 2814, 2815, 2815, 2816, 2817, 2818, 2818, 2819, 2820, 2821, 2821, 2822, 2823, 2824, 2824, 2825, | ||
465 | 2826, 2827, 2827, 2828, 2829, 2830, 2830, 2831, 2832, 2832, 2833, 2834, 2835, 2835, 2836, 2837, | ||
466 | 2838, 2838, 2839, 2840, 2841, 2841, 2842, 2843, 2844, 2844, 2845, 2846, 2846, 2847, 2848, 2849, | ||
467 | 2849, 2850, 2851, 2852, 2852, 2853, 2854, 2855, 2855, 2856, 2857, 2857, 2858, 2859, 2860, 2860, | ||
468 | 2861, 2862, 2863, 2863, 2864, 2865, 2865, 2866, 2867, 2868, 2868, 2869, 2870, 2871, 2871, 2872, | ||
469 | 2873, 2873, 2874, 2875, 2876, 2876, 2877, 2878, 2879, 2879, 2880, 2881, 2881, 2882, 2883, 2884, | ||
470 | 2884, 2885, 2886, 2886, 2887, 2888, 2889, 2889, 2890, 2891, 2892, 2892, 2893, 2894, 2894, 2895, | ||
471 | 2896, 2897, 2897, 2898, 2899, 2899, 2900, 2901, 2902, 2902, 2903, 2904, 2904, 2905, 2906, 2907, | ||
472 | 2907, 2908, 2909, 2909, 2910, 2911, 2912, 2912, 2913, 2914, 2914, 2915, 2916, 2917, 2917, 2918, | ||
473 | 2919, 2919, 2920, 2921, 2922, 2922, 2923, 2924, 2924, 2925, 2926, 2927, 2927, 2928, 2929, 2929, | ||
474 | 2930, 2931, 2932, 2932, 2933, 2934, 2934, 2935, 2936, 2937, 2937, 2938, 2939, 2939, 2940, 2941, | ||
475 | 2941, 2942, 2943, 2944, 2944, 2945, 2946, 2946, 2947, 2948, 2949, 2949, 2950, 2951, 2951, 2952, | ||
476 | 2953, 2953, 2954, 2955, 2956, 2956, 2957, 2958, 2958, 2959, 2960, 2961, 2961, 2962, 2963, 2963, | ||
477 | 2964, 2965, 2965, 2966, 2967, 2968, 2968, 2969, 2970, 2970, 2971, 2972, 2972, 2973, 2974, 2975, | ||
478 | 2975, 2976, 2977, 2977, 2978, 2979, 2979, 2980, 2981, 2982, 2982, 2983, 2984, 2984, 2985, 2986, | ||
479 | 2986, 2987, 2988, 2988, 2989, 2990, 2991, 2991, 2992, 2993, 2993, 2994, 2995, 2995, 2996, 2997, | ||
480 | 2998, 2998, 2999, 3000, 3000, 3001, 3002, 3002, 3003, 3004, 3004, 3005, 3006, 3006, 3007, 3008, | ||
481 | 3009, 3009, 3010, 3011, 3011, 3012, 3013, 3013, 3014, 3015, 3015, 3016, 3017, 3018, 3018, 3019, | ||
482 | 3020, 3020, 3021, 3022, 3022, 3023, 3024, 3024, 3025, 3026, 3026, 3027, 3028, 3029, 3029, 3030, | ||
483 | 3031, 3031, 3032, 3033, 3033, 3034, 3035, 3035, 3036, 3037, 3037, 3038, 3039, 3039, 3040, 3041, | ||
484 | 3042, 3042, 3043, 3044, 3044, 3045, 3046, 3046, 3047, 3048, 3048, 3049, 3050, 3050, 3051, 3052, | ||
485 | 3052, 3053, 3054, 3054, 3055, 3056, 3056, 3057, 3058, 3059, 3059, 3060, 3061, 3061, 3062, 3063, | ||
486 | 3063, 3064, 3065, 3065, 3066, 3067, 3067, 3068, 3069, 3069, 3070, 3071, 3071, 3072, 3073, 3073, | ||
487 | 3074, 3075, 3075, 3076, 3077, 3077, 3078, 3079, 3079, 3080, 3081, 3081, 3082, 3083, 3084, 3084, | ||
488 | 3085, 3086, 3086, 3087, 3088, 3088, 3089, 3090, 3090, 3091, 3092, 3092, 3093, 3094, 3094, 3095, | ||
489 | 3096, 3096, 3097, 3098, 3098, 3099, 3100, 3100, 3101, 3102, 3102, 3103, 3104, 3104, 3105, 3106, | ||
490 | 3106, 3107, 3108, 3108, 3109, 3110, 3110, 3111, 3112, 3112, 3113, 3114, 3114, 3115, 3116, 3116, | ||
491 | 3117, 3118, 3118, 3119, 3120, 3120, 3121, 3122, 3122, 3123, 3124, 3124, 3125, 3126, 3126, 3127, | ||
492 | 3128, 3128, 3129, 3130, 3130, 3131, 3132, 3132, 3133, 3134, 3134, 3135, 3135, 3136, 3137, 3137, | ||
493 | 3138, 3139, 3139, 3140, 3141, 3141, 3142, 3143, 3143, 3144, 3145, 3145, 3146, 3147, 3147, 3148, | ||
494 | 3149, 3149, 3150, 3151, 3151, 3152, 3153, 3153, 3154, 3155, 3155, 3156, 3157, 3157, 3158, 3159, | ||
495 | 3159, 3160, 3160, 3161, 3162, 3162, 3163, 3164, 3164, 3165, 3166, 3166, 3167, 3168, 3168, 3169, | ||
496 | 3170, 3170, 3171, 3172, 3172, 3173, 3174, 3174, 3175, 3175, 3176, 3177, 3177, 3178, 3179, 3179, | ||
497 | 3180, 3181, 3181, 3182, 3183, 3183, 3184, 3185, 3185, 3186, 3187, 3187, 3188, 3188, 3189, 3190, | ||
498 | 3190, 3191, 3192, 3192, 3193, 3194, 3194, 3195, 3196, 3196, 3197, 3198, 3198, 3199, 3199, 3200, | ||
499 | 3201, 3201, 3202, 3203, 3203, 3204, 3205, 3205, 3206, 3207, 3207, 3208, 3209, 3209, 3210, 3210, | ||
500 | 3211, 3212, 3212, 3213, 3214, 3214, 3215, 3216, 3216, 3217, 3218, 3218, 3219, 3219, 3220, 3221, | ||
501 | 3221, 3222, 3223, 3223, 3224, 3225, 3225, 3226, 3227, 3227, 3228, 3228, 3229, 3230, 3230, 3231, | ||
502 | 3232, 3232, 3233, 3234, 3234, 3235, 3235, 3236, 3237, 3237, 3238, 3239, 3239, 3240, 3241, 3241, | ||
503 | 3242, 3242, 3243, 3244, 3244, 3245, 3246, 3246, 3247, 3248, 3248, 3249, 3249, 3250, 3251, 3251, | ||
504 | 3252, 3253, 3253, 3254, 3255, 3255, 3256, 3256, 3257, 3258, 3258, 3259, 3260, 3260, 3261, 3262, | ||
505 | 3262, 3263, 3263, 3264, 3265, 3265, 3266, 3267, 3267, 3268, 3268, 3269, 3270, 3270, 3271, 3272, | ||
506 | 3272, 3273, 3274, 3274, 3275, 3275, 3276, 3277, 3277, 3278, 3279, 3279, 3280, 3280, 3281, 3282, | ||
507 | 3282, 3283, 3284, 3284, 3285, 3285, 3286, 3287, 3287, 3288, 3289, 3289, 3290, 3290, 3291, 3292, | ||
508 | 3292, 3293, 3294, 3294, 3295, 3295, 3296, 3297, 3297, 3298, 3299, 3299, 3300, 3300, 3301, 3302, | ||
509 | 3302, 3303, 3304, 3304, 3305, 3305, 3306, 3307, 3307, 3308, 3309, 3309, 3310, 3310, 3311, 3312, | ||
510 | 3312, 3313, 3314, 3314, 3315, 3315, 3316, 3317, 3317, 3318, 3319, 3319, 3320, 3320, 3321, 3322, | ||
511 | 3322, 3323, 3323, 3324, 3325, 3325, 3326, 3327, 3327, 3328, 3328, 3329, 3330, 3330, 3331, 3332, | ||
512 | 3332, 3333, 3333, 3334, 3335, 3335, 3336, 3336, 3337, 3338, 3338, 3339, 3340, 3340, 3341, 3341, | ||
513 | 3342, 3343, 3343, 3344, 3345, 3345, 3346, 3346, 3347, 3348, 3348, 3349, 3349, 3350, 3351, 3351, | ||
514 | 3352, 3352, 3353, 3354, 3354, 3355, 3356, 3356, 3357, 3357, 3358, 3359, 3359, 3360, 3360, 3361, | ||
515 | 3362, 3362, 3363, 3364, 3364, 3365, 3365, 3366, 3367, 3367, 3368, 3368, 3369, 3370, 3370, 3371, | ||
516 | 3371, 3372, 3373, 3373, 3374, 3375, 3375, 3376, 3376, 3377, 3378, 3378, 3379, 3379, 3380, 3381, | ||
517 | 3381, 3382, 3382, 3383, 3384, 3384, 3385, 3385, 3386, 3387, 3387, 3388, 3389, 3389, 3390, 3390, | ||
518 | 3391, 3392, 3392, 3393, 3393, 3394, 3395, 3395, 3396, 3396, 3397, 3398, 3398, 3399, 3399, 3400, | ||
519 | 3401, 3401, 3402, 3402, 3403, 3404, 3404, 3405, 3405, 3406, 3407, 3407, 3408, 3408, 3409, 3410, | ||
520 | 3410, 3411, 3411, 3412, 3413, 3413, 3414, 3414, 3415, 3416, 3416, 3417, 3418, 3418, 3419, 3419, | ||
521 | 3420, 3421, 3421, 3422, 3422, 3423, 3424, 3424, 3425, 3425, 3426, 3427, 3427, 3428, 3428, 3429, | ||
522 | 3430, 3430, 3431, 3431, 3432, 3433, 3433, 3434, 3434, 3435, 3435, 3436, 3437, 3437, 3438, 3438, | ||
523 | 3439, 3440, 3440, 3441, 3441, 3442, 3443, 3443, 3444, 3444, 3445, 3446, 3446, 3447, 3447, 3448, | ||
524 | 3449, 3449, 3450, 3450, 3451, 3452, 3452, 3453, 3453, 3454, 3455, 3455, 3456, 3456, 3457, 3458, | ||
525 | 3458, 3459, 3459, 3460, 3461, 3461, 3462, 3462, 3463, 3463, 3464, 3465, 3465, 3466, 3466, 3467, | ||
526 | 3468, 3468, 3469, 3469, 3470, 3471, 3471, 3472, 3472, 3473, 3474, 3474, 3475, 3475, 3476, 3476, | ||
527 | 3477, 3478, 3478, 3479, 3479, 3480, 3481, 3481, 3482, 3482, 3483, 3484, 3484, 3485, 3485, 3486, | ||
528 | 3486, 3487, 3488, 3488, 3489, 3489, 3490, 3491, 3491, 3492, 3492, 3493, 3494, 3494, 3495, 3495, | ||
529 | 3496, 3496, 3497, 3498, 3498, 3499, 3499, 3500, 3501, 3501, 3502, 3502, 3503, 3504, 3504, 3505, | ||
530 | 3505, 3506, 3506, 3507, 3508, 3508, 3509, 3509, 3510, 3511, 3511, 3512, 3512, 3513, 3513, 3514, | ||
531 | 3515, 3515, 3516, 3516, 3517, 3518, 3518, 3519, 3519, 3520, 3520, 3521, 3522, 3522, 3523, 3523, | ||
532 | 3524, 3525, 3525, 3526, 3526, 3527, 3527, 3528, 3529, 3529, 3530, 3530, 3531, 3531, 3532, 3533, | ||
533 | 3533, 3534, 3534, 3535, 3536, 3536, 3537, 3537, 3538, 3538, 3539, 3540, 3540, 3541, 3541, 3542, | ||
534 | 3542, 3543, 3544, 3544, 3545, 3545, 3546, 3547, 3547, 3548, 3548, 3549, 3549, 3550, 3551, 3551, | ||
535 | 3552, 3552, 3553, 3553, 3554, 3555, 3555, 3556, 3556, 3557, 3557, 3558, 3559, 3559, 3560, 3560, | ||
536 | 3561, 3561, 3562, 3563, 3563, 3564, 3564, 3565, 3566, 3566, 3567, 3567, 3568, 3568, 3569, 3570, | ||
537 | 3570, 3571, 3571, 3572, 3572, 3573, 3574, 3574, 3575, 3575, 3576, 3576, 3577, 3578, 3578, 3579, | ||
538 | 3579, 3580, 3580, 3581, 3582, 3582, 3583, 3583, 3584, 3584, 3585, 3586, 3586, 3587, 3587, 3588, | ||
539 | 3588, 3589, 3590, 3590, 3591, 3591, 3592, 3592, 3593, 3594, 3594, 3595, 3595, 3596, 3596, 3597, | ||
540 | 3597, 3598, 3599, 3599, 3600, 3600, 3601, 3601, 3602, 3603, 3603, 3604, 3604, 3605, 3605, 3606, | ||
541 | 3607, 3607, 3608, 3608, 3609, 3609, 3610, 3611, 3611, 3612, 3612, 3613, 3613, 3614, 3615, 3615, | ||
542 | 3616, 3616, 3617, 3617, 3618, 3618, 3619, 3620, 3620, 3621, 3621, 3622, 3622, 3623, 3624, 3624, | ||
543 | 3625, 3625, 3626, 3626, 3627, 3627, 3628, 3629, 3629, 3630, 3630, 3631, 3631, 3632, 3633, 3633, | ||
544 | 3634, 3634, 3635, 3635, 3636, 3636, 3637, 3638, 3638, 3639, 3639, 3640, 3640, 3641, 3642, 3642, | ||
545 | 3643, 3643, 3644, 3644, 3645, 3645, 3646, 3647, 3647, 3648, 3648, 3649, 3649, 3650, 3650, 3651, | ||
546 | 3652, 3652, 3653, 3653, 3654, 3654, 3655, 3656, 3656, 3657, 3657, 3658, 3658, 3659, 3659, 3660, | ||
547 | 3661, 3661, 3662, 3662, 3663, 3663, 3664, 3664, 3665, 3666, 3666, 3667, 3667, 3668, 3668, 3669, | ||
548 | 3669, 3670, 3671, 3671, 3672, 3672, 3673, 3673, 3674, 3674, 3675, 3676, 3676, 3677, 3677, 3678, | ||
549 | 3678, 3679, 3679, 3680, 3681, 3681, 3682, 3682, 3683, 3683, 3684, 3684, 3685, 3686, 3686, 3687, | ||
550 | 3687, 3688, 3688, 3689, 3689, 3690, 3691, 3691, 3692, 3692, 3693, 3693, 3694, 3694, 3695, 3695, | ||
551 | 3696, 3697, 3697, 3698, 3698, 3699, 3699, 3700, 3700, 3701, 3702, 3702, 3703, 3703, 3704, 3704, | ||
552 | 3705, 3705, 3706, 3707, 3707, 3708, 3708, 3709, 3709, 3710, 3710, 3711, 3711, 3712, 3713, 3713, | ||
553 | 3714, 3714, 3715, 3715, 3716, 3716, 3717, 3717, 3718, 3719, 3719, 3720, 3720, 3721, 3721, 3722, | ||
554 | 3722, 3723, 3724, 3724, 3725, 3725, 3726, 3726, 3727, 3727, 3728, 3728, 3729, 3730, 3730, 3731, | ||
555 | 3731, 3732, 3732, 3733, 3733, 3734, 3734, 3735, 3736, 3736, 3737, 3737, 3738, 3738, 3739, 3739, | ||
556 | 3740, 3740, 3741, 3742, 3742, 3743, 3743, 3744, 3744, 3745, 3745, 3746, 3746, 3747, 3748, 3748, | ||
557 | 3749, 3749, 3750, 3750, 3751, 3751, 3752, 3752, 3753, 3753, 3754, 3755, 3755, 3756, 3756, 3757, | ||
558 | 3757, 3758, 3758, 3759, 3759, 3760, 3761, 3761, 3762, 3762, 3763, 3763, 3764, 3764, 3765, 3765, | ||
559 | 3766, 3766, 3767, 3768, 3768, 3769, 3769, 3770, 3770, 3771, 3771, 3772, 3772, 3773, 3773, 3774, | ||
560 | 3775, 3775, 3776, 3776, 3777, 3777, 3778, 3778, 3779, 3779, 3780, 3781, 3781, 3782, 3782, 3783, | ||
561 | 3783, 3784, 3784, 3785, 3785, 3786, 3786, 3787, 3787, 3788, 3789, 3789, 3790, 3790, 3791, 3791, | ||
562 | 3792, 3792, 3793, 3793, 3794, 3794, 3795, 3796, 3796, 3797, 3797, 3798, 3798, 3799, 3799, 3800, | ||
563 | 3800, 3801, 3801, 3802, 3802, 3803, 3804, 3804, 3805, 3805, 3806, 3806, 3807, 3807, 3808, 3808, | ||
564 | 3809, 3809, 3810, 3811, 3811, 3812, 3812, 3813, 3813, 3814, 3814, 3815, 3815, 3816, 3816, 3817, | ||
565 | 3817, 3818, 3819, 3819, 3820, 3820, 3821, 3821, 3822, 3822, 3823, 3823, 3824, 3824, 3825, 3825, | ||
566 | 3826, 3826, 3827, 3828, 3828, 3829, 3829, 3830, 3830, 3831, 3831, 3832, 3832, 3833, 3833, 3834, | ||
567 | 3834, 3835, 3835, 3836, 3837, 3837, 3838, 3838, 3839, 3839, 3840, 3840, 3841, 3841, 3842, 3842, | ||
568 | 3843, 3843, 3844, 3844, 3845, 3846, 3846, 3847, 3847, 3848, 3848, 3849, 3849, 3850, 3850, 3851, | ||
569 | 3851, 3852, 3852, 3853, 3853, 3854, 3855, 3855, 3856, 3856, 3857, 3857, 3858, 3858, 3859, 3859, | ||
570 | 3860, 3860, 3861, 3861, 3862, 3862, 3863, 3863, 3864, 3864, 3865, 3866, 3866, 3867, 3867, 3868, | ||
571 | 3868, 3869, 3869, 3870, 3870, 3871, 3871, 3872, 3872, 3873, 3873, 3874, 3874, 3875, 3876, 3876, | ||
572 | 3877, 3877, 3878, 3878, 3879, 3879, 3880, 3880, 3881, 3881, 3882, 3882, 3883, 3883, 3884, 3884, | ||
573 | 3885, 3885, 3886, 3886, 3887, 3888, 3888, 3889, 3889, 3890, 3890, 3891, 3891, 3892, 3892, 3893, | ||
574 | 3893, 3894, 3894, 3895, 3895, 3896, 3896, 3897, 3897, 3898, 3898, 3899, 3900, 3900, 3901, 3901, | ||
575 | 3902, 3902, 3903, 3903, 3904, 3904, 3905, 3905, 3906, 3906, 3907, 3907, 3908, 3908, 3909, 3909, | ||
576 | 3910, 3910, 3911, 3911, 3912, 3912, 3913, 3914, 3914, 3915, 3915, 3916, 3916, 3917, 3917, 3918, | ||
577 | 3918, 3919, 3919, 3920, 3920, 3921, 3921, 3922, 3922, 3923, 3923, 3924, 3924, 3925, 3925, 3926, | ||
578 | 3926, 3927, 3927, 3928, 3929, 3929, 3930, 3930, 3931, 3931, 3932, 3932, 3933, 3933, 3934, 3934, | ||
579 | 3935, 3935, 3936, 3936, 3937, 3937, 3938, 3938, 3939, 3939, 3940, 3940, 3941, 3941, 3942, 3942, | ||
580 | 3943, 3943, 3944, 3944, 3945, 3945, 3946, 3947, 3947, 3948, 3948, 3949, 3949, 3950, 3950, 3951, | ||
581 | 3951, 3952, 3952, 3953, 3953, 3954, 3954, 3955, 3955, 3956, 3956, 3957, 3957, 3958, 3958, 3959, | ||
582 | 3959, 3960, 3960, 3961, 3961, 3962, 3962, 3963, 3963, 3964, 3964, 3965, 3965, 3966, 3966, 3967, | ||
583 | 3967, 3968, 3969, 3969, 3970, 3970, 3971, 3971, 3972, 3972, 3973, 3973, 3974, 3974, 3975, 3975, | ||
584 | 3976, 3976, 3977, 3977, 3978, 3978, 3979, 3979, 3980, 3980, 3981, 3981, 3982, 3982, 3983, 3983, | ||
585 | 3984, 3984, 3985, 3985, 3986, 3986, 3987, 3987, 3988, 3988, 3989, 3989, 3990, 3990, 3991, 3991, | ||
586 | 3992, 3992, 3993, 3993, 3994, 3994, 3995, 3995, 3996, 3996, 3997, 3997, 3998, 3998, 3999, 3999, | ||
587 | 4000, 4001, 4001, 4002, 4002, 4003, 4003, 4004, 4004, 4005, 4005, 4006, 4006, 4007, 4007, 4008, | ||
588 | 4008, 4009, 4009, 4010, 4010, 4011, 4011, 4012, 4012, 4013, 4013, 4014, 4014, 4015, 4015, 4016, | ||
589 | 4016, 4017, 4017, 4018, 4018, 4019, 4019, 4020, 4020, 4021, 4021, 4022, 4022, 4023, 4023, 4024, | ||
590 | 4024, 4025, 4025, 4026, 4026, 4027, 4027, 4028, 4028, 4029, 4029, 4030, 4030, 4031, 4031, 4032, | ||
591 | 4032, 4033, 4033, 4034, 4034, 4035, 4035, 4036, 4036, 4037, 4037, 4038, 4038, 4039, 4039, 4040, | ||
592 | 4040, 4041, 4041, 4042, 4042, 4043, 4043, 4044, 4044, 4045, 4045, 4046, 4046, 4047, 4047, 4048, | ||
593 | 4048, 4049, 4049, 4050, 4050, 4051, 4051, 4052, 4052, 4053, 4053, 4054, 4054, 4055, 4055, 4056, | ||
594 | 4056, 4057, 4057, 4058, 4058, 4059, 4059, 4060, 4060, 4061, 4061, 4062, 4062, 4063, 4063, 4064, | ||
595 | 4064, 4065, 4065, 4066, 4066, 4067, 4067, 4068, 4068, 4069, 4069, 4070, 4070, 4071, 4071, 4072, | ||
596 | 4072, 4073, 4073, 4074, 4074, 4075, 4075, 4076, 4076, 4077, 4077, 4078, 4078, 4079, 4079, 4080, | ||
597 | 4080, | ||
598 | }; | ||
599 | |||
600 | /* Generated table */ | ||
601 | const struct color16 tpg_csc_colors[V4L2_COLORSPACE_BT2020 + 1][TPG_COLOR_CSC_BLACK + 1] = { | ||
602 | [V4L2_COLORSPACE_SMPTE170M][0] = { 2939, 2939, 2939 }, | ||
603 | [V4L2_COLORSPACE_SMPTE170M][1] = { 2953, 2963, 586 }, | ||
604 | [V4L2_COLORSPACE_SMPTE170M][2] = { 0, 2967, 2937 }, | ||
605 | [V4L2_COLORSPACE_SMPTE170M][3] = { 88, 2990, 575 }, | ||
606 | [V4L2_COLORSPACE_SMPTE170M][4] = { 3016, 259, 2933 }, | ||
607 | [V4L2_COLORSPACE_SMPTE170M][5] = { 3030, 405, 558 }, | ||
608 | [V4L2_COLORSPACE_SMPTE170M][6] = { 478, 428, 2931 }, | ||
609 | [V4L2_COLORSPACE_SMPTE170M][7] = { 547, 547, 547 }, | ||
90 | [V4L2_COLORSPACE_SMPTE240M][0] = { 2926, 2926, 2926 }, | 610 | [V4L2_COLORSPACE_SMPTE240M][0] = { 2926, 2926, 2926 }, |
91 | [V4L2_COLORSPACE_SMPTE240M][1] = { 2926, 2926, 857 }, | 611 | [V4L2_COLORSPACE_SMPTE240M][1] = { 2941, 2950, 546 }, |
92 | [V4L2_COLORSPACE_SMPTE240M][2] = { 1594, 2901, 2901 }, | 612 | [V4L2_COLORSPACE_SMPTE240M][2] = { 0, 2954, 2924 }, |
93 | [V4L2_COLORSPACE_SMPTE240M][3] = { 1594, 2901, 774 }, | 613 | [V4L2_COLORSPACE_SMPTE240M][3] = { 78, 2978, 536 }, |
94 | [V4L2_COLORSPACE_SMPTE240M][4] = { 2484, 618, 2858 }, | 614 | [V4L2_COLORSPACE_SMPTE240M][4] = { 3004, 230, 2920 }, |
95 | [V4L2_COLORSPACE_SMPTE240M][5] = { 2484, 618, 617 }, | 615 | [V4L2_COLORSPACE_SMPTE240M][5] = { 3018, 363, 518 }, |
96 | [V4L2_COLORSPACE_SMPTE240M][6] = { 507, 507, 2832 }, | 616 | [V4L2_COLORSPACE_SMPTE240M][6] = { 437, 387, 2918 }, |
97 | [V4L2_COLORSPACE_SMPTE240M][7] = { 507, 507, 507 }, | 617 | [V4L2_COLORSPACE_SMPTE240M][7] = { 507, 507, 507 }, |
98 | [V4L2_COLORSPACE_REC709][0] = { 2939, 2939, 2939 }, | 618 | [V4L2_COLORSPACE_REC709][0] = { 2939, 2939, 2939 }, |
99 | [V4L2_COLORSPACE_REC709][1] = { 2939, 2939, 547 }, | 619 | [V4L2_COLORSPACE_REC709][1] = { 2939, 2939, 547 }, |
@@ -103,21 +623,21 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLAC | |||
103 | [V4L2_COLORSPACE_REC709][5] = { 2939, 547, 547 }, | 623 | [V4L2_COLORSPACE_REC709][5] = { 2939, 547, 547 }, |
104 | [V4L2_COLORSPACE_REC709][6] = { 547, 547, 2939 }, | 624 | [V4L2_COLORSPACE_REC709][6] = { 547, 547, 2939 }, |
105 | [V4L2_COLORSPACE_REC709][7] = { 547, 547, 547 }, | 625 | [V4L2_COLORSPACE_REC709][7] = { 547, 547, 547 }, |
106 | [V4L2_COLORSPACE_470_SYSTEM_M][0] = { 2894, 2988, 2808 }, | 626 | [V4L2_COLORSPACE_470_SYSTEM_M][0] = { 2892, 2988, 2807 }, |
107 | [V4L2_COLORSPACE_470_SYSTEM_M][1] = { 2847, 3070, 843 }, | 627 | [V4L2_COLORSPACE_470_SYSTEM_M][1] = { 2846, 3070, 843 }, |
108 | [V4L2_COLORSPACE_470_SYSTEM_M][2] = { 1656, 2962, 2783 }, | 628 | [V4L2_COLORSPACE_470_SYSTEM_M][2] = { 1656, 2962, 2783 }, |
109 | [V4L2_COLORSPACE_470_SYSTEM_M][3] = { 1572, 3045, 763 }, | 629 | [V4L2_COLORSPACE_470_SYSTEM_M][3] = { 1572, 3045, 763 }, |
110 | [V4L2_COLORSPACE_470_SYSTEM_M][4] = { 2477, 229, 2743 }, | 630 | [V4L2_COLORSPACE_470_SYSTEM_M][4] = { 2476, 229, 2742 }, |
111 | [V4L2_COLORSPACE_470_SYSTEM_M][5] = { 2422, 672, 614 }, | 631 | [V4L2_COLORSPACE_470_SYSTEM_M][5] = { 2420, 672, 614 }, |
112 | [V4L2_COLORSPACE_470_SYSTEM_M][6] = { 725, 63, 2718 }, | 632 | [V4L2_COLORSPACE_470_SYSTEM_M][6] = { 725, 63, 2718 }, |
113 | [V4L2_COLORSPACE_470_SYSTEM_M][7] = { 534, 561, 509 }, | 633 | [V4L2_COLORSPACE_470_SYSTEM_M][7] = { 534, 561, 509 }, |
114 | [V4L2_COLORSPACE_470_SYSTEM_BG][0] = { 2939, 2939, 2939 }, | 634 | [V4L2_COLORSPACE_470_SYSTEM_BG][0] = { 2939, 2939, 2939 }, |
115 | [V4L2_COLORSPACE_470_SYSTEM_BG][1] = { 2939, 2939, 621 }, | 635 | [V4L2_COLORSPACE_470_SYSTEM_BG][1] = { 2939, 2939, 464 }, |
116 | [V4L2_COLORSPACE_470_SYSTEM_BG][2] = { 786, 2939, 2939 }, | 636 | [V4L2_COLORSPACE_470_SYSTEM_BG][2] = { 786, 2939, 2939 }, |
117 | [V4L2_COLORSPACE_470_SYSTEM_BG][3] = { 786, 2939, 621 }, | 637 | [V4L2_COLORSPACE_470_SYSTEM_BG][3] = { 786, 2939, 464 }, |
118 | [V4L2_COLORSPACE_470_SYSTEM_BG][4] = { 2879, 547, 2923 }, | 638 | [V4L2_COLORSPACE_470_SYSTEM_BG][4] = { 2879, 547, 2956 }, |
119 | [V4L2_COLORSPACE_470_SYSTEM_BG][5] = { 2879, 547, 547 }, | 639 | [V4L2_COLORSPACE_470_SYSTEM_BG][5] = { 2879, 547, 547 }, |
120 | [V4L2_COLORSPACE_470_SYSTEM_BG][6] = { 547, 547, 2923 }, | 640 | [V4L2_COLORSPACE_470_SYSTEM_BG][6] = { 547, 547, 2956 }, |
121 | [V4L2_COLORSPACE_470_SYSTEM_BG][7] = { 547, 547, 547 }, | 641 | [V4L2_COLORSPACE_470_SYSTEM_BG][7] = { 547, 547, 547 }, |
122 | [V4L2_COLORSPACE_SRGB][0] = { 3056, 3056, 3056 }, | 642 | [V4L2_COLORSPACE_SRGB][0] = { 3056, 3056, 3056 }, |
123 | [V4L2_COLORSPACE_SRGB][1] = { 3056, 3056, 800 }, | 643 | [V4L2_COLORSPACE_SRGB][1] = { 3056, 3056, 800 }, |
@@ -127,6 +647,22 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLAC | |||
127 | [V4L2_COLORSPACE_SRGB][5] = { 3056, 800, 800 }, | 647 | [V4L2_COLORSPACE_SRGB][5] = { 3056, 800, 800 }, |
128 | [V4L2_COLORSPACE_SRGB][6] = { 800, 800, 3056 }, | 648 | [V4L2_COLORSPACE_SRGB][6] = { 800, 800, 3056 }, |
129 | [V4L2_COLORSPACE_SRGB][7] = { 800, 800, 800 }, | 649 | [V4L2_COLORSPACE_SRGB][7] = { 800, 800, 800 }, |
650 | [V4L2_COLORSPACE_ADOBERGB][0] = { 3033, 3033, 3033 }, | ||
651 | [V4L2_COLORSPACE_ADOBERGB][1] = { 3033, 3033, 1063 }, | ||
652 | [V4L2_COLORSPACE_ADOBERGB][2] = { 1828, 3033, 3033 }, | ||
653 | [V4L2_COLORSPACE_ADOBERGB][3] = { 1828, 3033, 1063 }, | ||
654 | [V4L2_COLORSPACE_ADOBERGB][4] = { 2633, 851, 2979 }, | ||
655 | [V4L2_COLORSPACE_ADOBERGB][5] = { 2633, 851, 851 }, | ||
656 | [V4L2_COLORSPACE_ADOBERGB][6] = { 851, 851, 2979 }, | ||
657 | [V4L2_COLORSPACE_ADOBERGB][7] = { 851, 851, 851 }, | ||
658 | [V4L2_COLORSPACE_BT2020][0] = { 2939, 2939, 2939 }, | ||
659 | [V4L2_COLORSPACE_BT2020][1] = { 2877, 2923, 1058 }, | ||
660 | [V4L2_COLORSPACE_BT2020][2] = { 1837, 2840, 2916 }, | ||
661 | [V4L2_COLORSPACE_BT2020][3] = { 1734, 2823, 993 }, | ||
662 | [V4L2_COLORSPACE_BT2020][4] = { 2427, 961, 2812 }, | ||
663 | [V4L2_COLORSPACE_BT2020][5] = { 2351, 912, 648 }, | ||
664 | [V4L2_COLORSPACE_BT2020][6] = { 792, 618, 2788 }, | ||
665 | [V4L2_COLORSPACE_BT2020][7] = { 547, 547, 547 }, | ||
130 | }; | 666 | }; |
131 | 667 | ||
132 | #else | 668 | #else |
@@ -138,29 +674,40 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLAC | |||
138 | #include <stdlib.h> | 674 | #include <stdlib.h> |
139 | 675 | ||
140 | static const double rec709_to_ntsc1953[3][3] = { | 676 | static const double rec709_to_ntsc1953[3][3] = { |
141 | { 0.6698, 0.2678, 0.0323 }, | 677 | { 0.6689794, 0.2678309, 0.0323187 }, |
142 | { 0.0185, 1.0742, -0.0603 }, | 678 | { 0.0184901, 1.0742442, -0.0602820 }, |
143 | { 0.0162, 0.0432, 0.8551 } | 679 | { 0.0162259, 0.0431716, 0.8549253 } |
144 | }; | 680 | }; |
145 | 681 | ||
146 | static const double rec709_to_ebu[3][3] = { | 682 | static const double rec709_to_ebu[3][3] = { |
147 | { 0.9578, 0.0422, 0 }, | 683 | { 0.9578221, 0.0421779, -0.0000000 }, |
148 | { 0 , 1 , 0 }, | 684 | { -0.0000000, 1.0000000, 0.0000000 }, |
149 | { 0 , 0.0118, 0.9882 } | 685 | { -0.0000000, -0.0119367, 1.0119367 } |
150 | }; | 686 | }; |
151 | 687 | ||
152 | static const double rec709_to_170m[3][3] = { | 688 | static const double rec709_to_170m[3][3] = { |
153 | { 1.0654, -0.0554, -0.0010 }, | 689 | { 1.0653640, -0.0553900, -0.0099740 }, |
154 | { -0.0196, 1.0364, -0.0167 }, | 690 | { -0.0196361, 1.0363630, -0.0167269 }, |
155 | { 0.0016, 0.0044, 0.9940 } | 691 | { 0.0016327, 0.0044133, 0.9939540 }, |
156 | }; | 692 | }; |
157 | 693 | ||
158 | static const double rec709_to_240m[3][3] = { | 694 | static const double rec709_to_240m[3][3] = { |
159 | { 0.7151, 0.2849, 0 }, | 695 | { 1.0653640, -0.0553900, -0.0099740 }, |
160 | { 0.0179, 0.9821, 0 }, | 696 | { -0.0196361, 1.0363630, -0.0167269 }, |
161 | { 0.0177, 0.0472, 0.9350 } | 697 | { 0.0016327, 0.0044133, 0.9939540 }, |
698 | }; | ||
699 | |||
700 | static const double rec709_to_adobergb[3][3] = { | ||
701 | { 0.7151627, 0.2848373, -0.0000000 }, | ||
702 | { 0.0000000, 1.0000000, 0.0000000 }, | ||
703 | { -0.0000000, 0.0411705, 0.9588295 }, | ||
162 | }; | 704 | }; |
163 | 705 | ||
706 | static const double rec709_to_bt2020[3][3] = { | ||
707 | { 0.6274524, 0.3292485, 0.0432991 }, | ||
708 | { 0.0691092, 0.9195311, 0.0113597 }, | ||
709 | { 0.0163976, 0.0880301, 0.8955723 }, | ||
710 | }; | ||
164 | 711 | ||
165 | static void mult_matrix(double *r, double *g, double *b, const double m[3][3]) | 712 | static void mult_matrix(double *r, double *g, double *b, const double m[3][3]) |
166 | { | 713 | { |
@@ -176,7 +723,18 @@ static void mult_matrix(double *r, double *g, double *b, const double m[3][3]) | |||
176 | 723 | ||
177 | static double transfer_srgb_to_rgb(double v) | 724 | static double transfer_srgb_to_rgb(double v) |
178 | { | 725 | { |
179 | return (v <= 0.03928) ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4); | 726 | if (v < -0.04045) |
727 | return pow((-v + 0.055) / 1.055, 2.4); | ||
728 | return (v <= 0.04045) ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4); | ||
729 | } | ||
730 | |||
731 | static double transfer_rgb_to_srgb(double v) | ||
732 | { | ||
733 | if (v <= -0.0031308) | ||
734 | return -1.055 * pow(-v, 1.0 / 2.4) + 0.055; | ||
735 | if (v <= 0.0031308) | ||
736 | return v * 12.92; | ||
737 | return 1.055 * pow(v, 1.0 / 2.4) - 0.055; | ||
180 | } | 738 | } |
181 | 739 | ||
182 | static double transfer_rgb_to_smpte240m(double v) | 740 | static double transfer_rgb_to_smpte240m(double v) |
@@ -186,9 +744,21 @@ static double transfer_rgb_to_smpte240m(double v) | |||
186 | 744 | ||
187 | static double transfer_rgb_to_rec709(double v) | 745 | static double transfer_rgb_to_rec709(double v) |
188 | { | 746 | { |
747 | if (v <= -0.018) | ||
748 | return -1.099 * pow(-v, 0.45) + 0.099; | ||
189 | return (v < 0.018) ? v * 4.5 : 1.099 * pow(v, 0.45) - 0.099; | 749 | return (v < 0.018) ? v * 4.5 : 1.099 * pow(v, 0.45) - 0.099; |
190 | } | 750 | } |
191 | 751 | ||
752 | static double transfer_rec709_to_rgb(double v) | ||
753 | { | ||
754 | return (v < 0.081) ? v / 4.5 : pow((v + 0.099) / 1.099, 1.0 / 0.45); | ||
755 | } | ||
756 | |||
757 | static double transfer_rgb_to_adobergb(double v) | ||
758 | { | ||
759 | return pow(v, 1.0 / 2.19921875); | ||
760 | } | ||
761 | |||
192 | static double transfer_srgb_to_rec709(double v) | 762 | static double transfer_srgb_to_rec709(double v) |
193 | { | 763 | { |
194 | return transfer_rgb_to_rec709(transfer_srgb_to_rgb(v)); | 764 | return transfer_rgb_to_rec709(transfer_srgb_to_rgb(v)); |
@@ -196,6 +766,8 @@ static double transfer_srgb_to_rec709(double v) | |||
196 | 766 | ||
197 | static void csc(enum v4l2_colorspace colorspace, double *r, double *g, double *b) | 767 | static void csc(enum v4l2_colorspace colorspace, double *r, double *g, double *b) |
198 | { | 768 | { |
769 | int clamp = 1; | ||
770 | |||
199 | /* Convert the primaries of Rec. 709 Linear RGB */ | 771 | /* Convert the primaries of Rec. 709 Linear RGB */ |
200 | switch (colorspace) { | 772 | switch (colorspace) { |
201 | case V4L2_COLORSPACE_SMPTE240M: | 773 | case V4L2_COLORSPACE_SMPTE240M: |
@@ -222,15 +794,29 @@ static void csc(enum v4l2_colorspace colorspace, double *r, double *g, double *b | |||
222 | *b = transfer_srgb_to_rgb(*b); | 794 | *b = transfer_srgb_to_rgb(*b); |
223 | mult_matrix(r, g, b, rec709_to_ntsc1953); | 795 | mult_matrix(r, g, b, rec709_to_ntsc1953); |
224 | break; | 796 | break; |
797 | case V4L2_COLORSPACE_ADOBERGB: | ||
798 | *r = transfer_srgb_to_rgb(*r); | ||
799 | *g = transfer_srgb_to_rgb(*g); | ||
800 | *b = transfer_srgb_to_rgb(*b); | ||
801 | mult_matrix(r, g, b, rec709_to_adobergb); | ||
802 | break; | ||
803 | case V4L2_COLORSPACE_BT2020: | ||
804 | *r = transfer_srgb_to_rgb(*r); | ||
805 | *g = transfer_srgb_to_rgb(*g); | ||
806 | *b = transfer_srgb_to_rgb(*b); | ||
807 | mult_matrix(r, g, b, rec709_to_bt2020); | ||
808 | break; | ||
225 | case V4L2_COLORSPACE_SRGB: | 809 | case V4L2_COLORSPACE_SRGB: |
226 | case V4L2_COLORSPACE_REC709: | 810 | case V4L2_COLORSPACE_REC709: |
227 | default: | 811 | default: |
228 | break; | 812 | break; |
229 | } | 813 | } |
230 | 814 | ||
231 | *r = ((*r) < 0) ? 0 : (((*r) > 1) ? 1 : (*r)); | 815 | if (clamp) { |
232 | *g = ((*g) < 0) ? 0 : (((*g) > 1) ? 1 : (*g)); | 816 | *r = ((*r) < 0) ? 0 : (((*r) > 1) ? 1 : (*r)); |
233 | *b = ((*b) < 0) ? 0 : (((*b) > 1) ? 1 : (*b)); | 817 | *g = ((*g) < 0) ? 0 : (((*g) > 1) ? 1 : (*g)); |
818 | *b = ((*b) < 0) ? 0 : (((*b) > 1) ? 1 : (*b)); | ||
819 | } | ||
234 | 820 | ||
235 | /* Encode to gamma corrected colorspace */ | 821 | /* Encode to gamma corrected colorspace */ |
236 | switch (colorspace) { | 822 | switch (colorspace) { |
@@ -242,12 +828,18 @@ static void csc(enum v4l2_colorspace colorspace, double *r, double *g, double *b | |||
242 | case V4L2_COLORSPACE_SMPTE170M: | 828 | case V4L2_COLORSPACE_SMPTE170M: |
243 | case V4L2_COLORSPACE_470_SYSTEM_M: | 829 | case V4L2_COLORSPACE_470_SYSTEM_M: |
244 | case V4L2_COLORSPACE_470_SYSTEM_BG: | 830 | case V4L2_COLORSPACE_470_SYSTEM_BG: |
831 | case V4L2_COLORSPACE_BT2020: | ||
245 | *r = transfer_rgb_to_rec709(*r); | 832 | *r = transfer_rgb_to_rec709(*r); |
246 | *g = transfer_rgb_to_rec709(*g); | 833 | *g = transfer_rgb_to_rec709(*g); |
247 | *b = transfer_rgb_to_rec709(*b); | 834 | *b = transfer_rgb_to_rec709(*b); |
248 | break; | 835 | break; |
249 | case V4L2_COLORSPACE_SRGB: | 836 | case V4L2_COLORSPACE_SRGB: |
250 | break; | 837 | break; |
838 | case V4L2_COLORSPACE_ADOBERGB: | ||
839 | *r = transfer_rgb_to_adobergb(*r); | ||
840 | *g = transfer_rgb_to_adobergb(*g); | ||
841 | *b = transfer_rgb_to_adobergb(*b); | ||
842 | break; | ||
251 | case V4L2_COLORSPACE_REC709: | 843 | case V4L2_COLORSPACE_REC709: |
252 | default: | 844 | default: |
253 | *r = transfer_srgb_to_rec709(*r); | 845 | *r = transfer_srgb_to_rec709(*r); |
@@ -269,6 +861,8 @@ int main(int argc, char **argv) | |||
269 | V4L2_COLORSPACE_470_SYSTEM_BG, | 861 | V4L2_COLORSPACE_470_SYSTEM_BG, |
270 | 0, | 862 | 0, |
271 | V4L2_COLORSPACE_SRGB, | 863 | V4L2_COLORSPACE_SRGB, |
864 | V4L2_COLORSPACE_ADOBERGB, | ||
865 | V4L2_COLORSPACE_BT2020, | ||
272 | }; | 866 | }; |
273 | static const char * const colorspace_names[] = { | 867 | static const char * const colorspace_names[] = { |
274 | "", | 868 | "", |
@@ -280,13 +874,39 @@ int main(int argc, char **argv) | |||
280 | "V4L2_COLORSPACE_470_SYSTEM_BG", | 874 | "V4L2_COLORSPACE_470_SYSTEM_BG", |
281 | "", | 875 | "", |
282 | "V4L2_COLORSPACE_SRGB", | 876 | "V4L2_COLORSPACE_SRGB", |
877 | "V4L2_COLORSPACE_ADOBERGB", | ||
878 | "V4L2_COLORSPACE_BT2020", | ||
283 | }; | 879 | }; |
284 | int i; | 880 | int i; |
285 | int c; | 881 | int c; |
286 | 882 | ||
287 | printf("/* Generated table */\n"); | 883 | printf("/* Generated table */\n"); |
288 | printf("const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLACK + 1] = {\n"); | 884 | printf("const unsigned short tpg_rec709_to_linear[255 * 16 + 1] = {"); |
289 | for (c = 0; c <= V4L2_COLORSPACE_SRGB; c++) { | 885 | for (i = 0; i <= 255 * 16; i++) { |
886 | if (i % 16 == 0) | ||
887 | printf("\n\t"); | ||
888 | printf("%4d,%s", | ||
889 | (int)(0.5 + 16.0 * 255.0 * | ||
890 | transfer_rec709_to_rgb(i / (16.0 * 255.0))), | ||
891 | i % 16 == 15 || i == 255 * 16 ? "" : " "); | ||
892 | } | ||
893 | printf("\n};\n\n"); | ||
894 | |||
895 | printf("/* Generated table */\n"); | ||
896 | printf("const unsigned short tpg_linear_to_rec709[255 * 16 + 1] = {"); | ||
897 | for (i = 0; i <= 255 * 16; i++) { | ||
898 | if (i % 16 == 0) | ||
899 | printf("\n\t"); | ||
900 | printf("%4d,%s", | ||
901 | (int)(0.5 + 16.0 * 255.0 * | ||
902 | transfer_rgb_to_rec709(i / (16.0 * 255.0))), | ||
903 | i % 16 == 15 || i == 255 * 16 ? "" : " "); | ||
904 | } | ||
905 | printf("\n};\n\n"); | ||
906 | |||
907 | printf("/* Generated table */\n"); | ||
908 | printf("const struct color16 tpg_csc_colors[V4L2_COLORSPACE_BT2020 + 1][TPG_COLOR_CSC_BLACK + 1] = {\n"); | ||
909 | for (c = 0; c <= V4L2_COLORSPACE_BT2020; c++) { | ||
290 | for (i = 0; i <= TPG_COLOR_CSC_BLACK; i++) { | 910 | for (i = 0; i <= TPG_COLOR_CSC_BLACK; i++) { |
291 | double r, g, b; | 911 | double r, g, b; |
292 | 912 | ||
diff --git a/drivers/media/platform/vivid/vivid-tpg-colors.h b/drivers/media/platform/vivid/vivid-tpg-colors.h index a2678fbec256..2c333356451c 100644 --- a/drivers/media/platform/vivid/vivid-tpg-colors.h +++ b/drivers/media/platform/vivid/vivid-tpg-colors.h | |||
@@ -59,6 +59,8 @@ enum tpg_color { | |||
59 | }; | 59 | }; |
60 | 60 | ||
61 | extern const struct color tpg_colors[TPG_COLOR_MAX]; | 61 | extern const struct color tpg_colors[TPG_COLOR_MAX]; |
62 | extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLACK + 1]; | 62 | extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1]; |
63 | extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1]; | ||
64 | extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_BT2020 + 1][TPG_COLOR_CSC_BLACK + 1]; | ||
63 | 65 | ||
64 | #endif | 66 | #endif |
diff --git a/drivers/media/platform/vivid/vivid-tpg.c b/drivers/media/platform/vivid/vivid-tpg.c index cbcd6250e7b2..fc9c6536ba02 100644 --- a/drivers/media/platform/vivid/vivid-tpg.c +++ b/drivers/media/platform/vivid/vivid-tpg.c | |||
@@ -296,127 +296,193 @@ static enum tpg_color tpg_get_textfg_color(struct tpg_data *tpg) | |||
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | static u16 color_to_y(struct tpg_data *tpg, int r, int g, int b) | 299 | static inline int rec709_to_linear(int v) |
300 | { | 300 | { |
301 | switch (tpg->colorspace) { | 301 | v = clamp(v, 0, 0xff0); |
302 | case V4L2_COLORSPACE_SMPTE170M: | 302 | return tpg_rec709_to_linear[v]; |
303 | case V4L2_COLORSPACE_470_SYSTEM_M: | ||
304 | case V4L2_COLORSPACE_470_SYSTEM_BG: | ||
305 | return ((16829 * r + 33039 * g + 6416 * b + 16 * 32768) >> 16) + (16 << 4); | ||
306 | case V4L2_COLORSPACE_SMPTE240M: | ||
307 | return ((11932 * r + 39455 * g + 4897 * b + 16 * 32768) >> 16) + (16 << 4); | ||
308 | case V4L2_COLORSPACE_REC709: | ||
309 | case V4L2_COLORSPACE_SRGB: | ||
310 | default: | ||
311 | return ((11966 * r + 40254 * g + 4064 * b + 16 * 32768) >> 16) + (16 << 4); | ||
312 | } | ||
313 | } | 303 | } |
314 | 304 | ||
315 | static u16 color_to_cb(struct tpg_data *tpg, int r, int g, int b) | 305 | static inline int linear_to_rec709(int v) |
316 | { | 306 | { |
317 | switch (tpg->colorspace) { | 307 | v = clamp(v, 0, 0xff0); |
318 | case V4L2_COLORSPACE_SMPTE170M: | 308 | return tpg_linear_to_rec709[v]; |
319 | case V4L2_COLORSPACE_470_SYSTEM_M: | ||
320 | case V4L2_COLORSPACE_470_SYSTEM_BG: | ||
321 | return ((-9714 * r - 19070 * g + 28784 * b + 16 * 32768) >> 16) + (128 << 4); | ||
322 | case V4L2_COLORSPACE_SMPTE240M: | ||
323 | return ((-6684 * r - 22100 * g + 28784 * b + 16 * 32768) >> 16) + (128 << 4); | ||
324 | case V4L2_COLORSPACE_REC709: | ||
325 | case V4L2_COLORSPACE_SRGB: | ||
326 | default: | ||
327 | return ((-6596 * r - 22189 * g + 28784 * b + 16 * 32768) >> 16) + (128 << 4); | ||
328 | } | ||
329 | } | 309 | } |
330 | 310 | ||
331 | static u16 color_to_cr(struct tpg_data *tpg, int r, int g, int b) | 311 | static void rgb2ycbcr(const int m[3][3], int r, int g, int b, |
312 | int y_offset, int *y, int *cb, int *cr) | ||
332 | { | 313 | { |
333 | switch (tpg->colorspace) { | 314 | *y = ((m[0][0] * r + m[0][1] * g + m[0][2] * b) >> 16) + (y_offset << 4); |
334 | case V4L2_COLORSPACE_SMPTE170M: | 315 | *cb = ((m[1][0] * r + m[1][1] * g + m[1][2] * b) >> 16) + (128 << 4); |
335 | case V4L2_COLORSPACE_470_SYSTEM_M: | 316 | *cr = ((m[2][0] * r + m[2][1] * g + m[2][2] * b) >> 16) + (128 << 4); |
336 | case V4L2_COLORSPACE_470_SYSTEM_BG: | ||
337 | return ((28784 * r - 24103 * g - 4681 * b + 16 * 32768) >> 16) + (128 << 4); | ||
338 | case V4L2_COLORSPACE_SMPTE240M: | ||
339 | return ((28784 * r - 25606 * g - 3178 * b + 16 * 32768) >> 16) + (128 << 4); | ||
340 | case V4L2_COLORSPACE_REC709: | ||
341 | case V4L2_COLORSPACE_SRGB: | ||
342 | default: | ||
343 | return ((28784 * r - 26145 * g - 2639 * b + 16 * 32768) >> 16) + (128 << 4); | ||
344 | } | ||
345 | } | 317 | } |
346 | 318 | ||
347 | static u16 ycbcr_to_r(struct tpg_data *tpg, int y, int cb, int cr) | 319 | static void color_to_ycbcr(struct tpg_data *tpg, int r, int g, int b, |
320 | int *y, int *cb, int *cr) | ||
348 | { | 321 | { |
349 | int r; | 322 | #define COEFF(v, r) ((int)(0.5 + (v) * (r) * 256.0)) |
350 | 323 | ||
351 | y -= 16 << 4; | 324 | static const int bt601[3][3] = { |
352 | cb -= 128 << 4; | 325 | { COEFF(0.299, 219), COEFF(0.587, 219), COEFF(0.114, 219) }, |
353 | cr -= 128 << 4; | 326 | { COEFF(-0.169, 224), COEFF(-0.331, 224), COEFF(0.5, 224) }, |
354 | switch (tpg->colorspace) { | 327 | { COEFF(0.5, 224), COEFF(-0.419, 224), COEFF(-0.081, 224) }, |
355 | case V4L2_COLORSPACE_SMPTE170M: | 328 | }; |
356 | case V4L2_COLORSPACE_470_SYSTEM_M: | 329 | static const int bt601_full[3][3] = { |
357 | case V4L2_COLORSPACE_470_SYSTEM_BG: | 330 | { COEFF(0.299, 255), COEFF(0.587, 255), COEFF(0.114, 255) }, |
358 | r = 4769 * y + 6537 * cr; | 331 | { COEFF(-0.169, 255), COEFF(-0.331, 255), COEFF(0.5, 255) }, |
332 | { COEFF(0.5, 255), COEFF(-0.419, 255), COEFF(-0.081, 255) }, | ||
333 | }; | ||
334 | static const int rec709[3][3] = { | ||
335 | { COEFF(0.2126, 219), COEFF(0.7152, 219), COEFF(0.0722, 219) }, | ||
336 | { COEFF(-0.1146, 224), COEFF(-0.3854, 224), COEFF(0.5, 224) }, | ||
337 | { COEFF(0.5, 224), COEFF(-0.4542, 224), COEFF(-0.0458, 224) }, | ||
338 | }; | ||
339 | static const int rec709_full[3][3] = { | ||
340 | { COEFF(0.2126, 255), COEFF(0.7152, 255), COEFF(0.0722, 255) }, | ||
341 | { COEFF(-0.1146, 255), COEFF(-0.3854, 255), COEFF(0.5, 255) }, | ||
342 | { COEFF(0.5, 255), COEFF(-0.4542, 255), COEFF(-0.0458, 255) }, | ||
343 | }; | ||
344 | static const int smpte240m[3][3] = { | ||
345 | { COEFF(0.212, 219), COEFF(0.701, 219), COEFF(0.087, 219) }, | ||
346 | { COEFF(-0.116, 224), COEFF(-0.384, 224), COEFF(0.5, 224) }, | ||
347 | { COEFF(0.5, 224), COEFF(-0.445, 224), COEFF(-0.055, 224) }, | ||
348 | }; | ||
349 | static const int bt2020[3][3] = { | ||
350 | { COEFF(0.2726, 219), COEFF(0.6780, 219), COEFF(0.0593, 219) }, | ||
351 | { COEFF(-0.1396, 224), COEFF(-0.3604, 224), COEFF(0.5, 224) }, | ||
352 | { COEFF(0.5, 224), COEFF(-0.4629, 224), COEFF(-0.0405, 224) }, | ||
353 | }; | ||
354 | bool full = tpg->real_quantization == V4L2_QUANTIZATION_FULL_RANGE; | ||
355 | int lin_y, yc; | ||
356 | |||
357 | switch (tpg->real_ycbcr_enc) { | ||
358 | case V4L2_YCBCR_ENC_601: | ||
359 | case V4L2_YCBCR_ENC_XV601: | ||
360 | case V4L2_YCBCR_ENC_SYCC: | ||
361 | rgb2ycbcr(full ? bt601_full : bt601, r, g, b, 16, y, cb, cr); | ||
362 | break; | ||
363 | case V4L2_YCBCR_ENC_BT2020: | ||
364 | rgb2ycbcr(bt2020, r, g, b, 16, y, cb, cr); | ||
359 | break; | 365 | break; |
360 | case V4L2_COLORSPACE_SMPTE240M: | 366 | case V4L2_YCBCR_ENC_BT2020_CONST_LUM: |
361 | r = 4769 * y + 7376 * cr; | 367 | lin_y = (COEFF(0.2627, 255) * rec709_to_linear(r) + |
368 | COEFF(0.6780, 255) * rec709_to_linear(g) + | ||
369 | COEFF(0.0593, 255) * rec709_to_linear(b)) >> 16; | ||
370 | yc = linear_to_rec709(lin_y); | ||
371 | *y = (yc * 219) / 255 + (16 << 4); | ||
372 | if (b <= yc) | ||
373 | *cb = (((b - yc) * COEFF(1.0 / 1.9404, 224)) >> 16) + (128 << 4); | ||
374 | else | ||
375 | *cb = (((b - yc) * COEFF(1.0 / 1.5816, 224)) >> 16) + (128 << 4); | ||
376 | if (r <= yc) | ||
377 | *cr = (((r - yc) * COEFF(1.0 / 1.7184, 224)) >> 16) + (128 << 4); | ||
378 | else | ||
379 | *cr = (((r - yc) * COEFF(1.0 / 0.9936, 224)) >> 16) + (128 << 4); | ||
362 | break; | 380 | break; |
363 | case V4L2_COLORSPACE_REC709: | 381 | case V4L2_YCBCR_ENC_SMPTE240M: |
364 | case V4L2_COLORSPACE_SRGB: | 382 | rgb2ycbcr(smpte240m, r, g, b, 16, y, cb, cr); |
383 | break; | ||
384 | case V4L2_YCBCR_ENC_709: | ||
385 | case V4L2_YCBCR_ENC_XV709: | ||
365 | default: | 386 | default: |
366 | r = 4769 * y + 7343 * cr; | 387 | rgb2ycbcr(full ? rec709_full : rec709, r, g, b, 0, y, cb, cr); |
367 | break; | 388 | break; |
368 | } | 389 | } |
369 | return clamp(r >> 12, 0, 0xff0); | ||
370 | } | 390 | } |
371 | 391 | ||
372 | static u16 ycbcr_to_g(struct tpg_data *tpg, int y, int cb, int cr) | 392 | static void ycbcr2rgb(const int m[3][3], int y, int cb, int cr, |
393 | int y_offset, int *r, int *g, int *b) | ||
373 | { | 394 | { |
374 | int g; | 395 | y -= y_offset << 4; |
375 | |||
376 | y -= 16 << 4; | ||
377 | cb -= 128 << 4; | 396 | cb -= 128 << 4; |
378 | cr -= 128 << 4; | 397 | cr -= 128 << 4; |
379 | switch (tpg->colorspace) { | 398 | *r = m[0][0] * y + m[0][1] * cb + m[0][2] * cr; |
380 | case V4L2_COLORSPACE_SMPTE170M: | 399 | *g = m[1][0] * y + m[1][1] * cb + m[1][2] * cr; |
381 | case V4L2_COLORSPACE_470_SYSTEM_M: | 400 | *b = m[2][0] * y + m[2][1] * cb + m[2][2] * cr; |
382 | case V4L2_COLORSPACE_470_SYSTEM_BG: | 401 | *r = clamp(*r >> 12, 0, 0xff0); |
383 | g = 4769 * y - 1605 * cb - 3330 * cr; | 402 | *g = clamp(*g >> 12, 0, 0xff0); |
384 | break; | 403 | *b = clamp(*b >> 12, 0, 0xff0); |
385 | case V4L2_COLORSPACE_SMPTE240M: | ||
386 | g = 4769 * y - 1055 * cb - 2341 * cr; | ||
387 | break; | ||
388 | case V4L2_COLORSPACE_REC709: | ||
389 | case V4L2_COLORSPACE_SRGB: | ||
390 | default: | ||
391 | g = 4769 * y - 873 * cb - 2183 * cr; | ||
392 | break; | ||
393 | } | ||
394 | return clamp(g >> 12, 0, 0xff0); | ||
395 | } | 404 | } |
396 | 405 | ||
397 | static u16 ycbcr_to_b(struct tpg_data *tpg, int y, int cb, int cr) | 406 | static void ycbcr_to_color(struct tpg_data *tpg, int y, int cb, int cr, |
407 | int *r, int *g, int *b) | ||
398 | { | 408 | { |
399 | int b; | 409 | #undef COEFF |
410 | #define COEFF(v, r) ((int)(0.5 + (v) * ((255.0 * 255.0 * 16.0) / (r)))) | ||
411 | static const int bt601[3][3] = { | ||
412 | { COEFF(1, 219), COEFF(0, 224), COEFF(1.4020, 224) }, | ||
413 | { COEFF(1, 219), COEFF(-0.3441, 224), COEFF(-0.7141, 224) }, | ||
414 | { COEFF(1, 219), COEFF(1.7720, 224), COEFF(0, 224) }, | ||
415 | }; | ||
416 | static const int bt601_full[3][3] = { | ||
417 | { COEFF(1, 255), COEFF(0, 255), COEFF(1.4020, 255) }, | ||
418 | { COEFF(1, 255), COEFF(-0.3441, 255), COEFF(-0.7141, 255) }, | ||
419 | { COEFF(1, 255), COEFF(1.7720, 255), COEFF(0, 255) }, | ||
420 | }; | ||
421 | static const int rec709[3][3] = { | ||
422 | { COEFF(1, 219), COEFF(0, 224), COEFF(1.5748, 224) }, | ||
423 | { COEFF(1, 219), COEFF(-0.1873, 224), COEFF(-0.4681, 224) }, | ||
424 | { COEFF(1, 219), COEFF(1.8556, 224), COEFF(0, 224) }, | ||
425 | }; | ||
426 | static const int rec709_full[3][3] = { | ||
427 | { COEFF(1, 255), COEFF(0, 255), COEFF(1.5748, 255) }, | ||
428 | { COEFF(1, 255), COEFF(-0.1873, 255), COEFF(-0.4681, 255) }, | ||
429 | { COEFF(1, 255), COEFF(1.8556, 255), COEFF(0, 255) }, | ||
430 | }; | ||
431 | static const int smpte240m[3][3] = { | ||
432 | { COEFF(1, 219), COEFF(0, 224), COEFF(1.5756, 224) }, | ||
433 | { COEFF(1, 219), COEFF(-0.2253, 224), COEFF(-0.4767, 224) }, | ||
434 | { COEFF(1, 219), COEFF(1.8270, 224), COEFF(0, 224) }, | ||
435 | }; | ||
436 | static const int bt2020[3][3] = { | ||
437 | { COEFF(1, 219), COEFF(0, 224), COEFF(1.4746, 224) }, | ||
438 | { COEFF(1, 219), COEFF(-0.1646, 224), COEFF(-0.5714, 224) }, | ||
439 | { COEFF(1, 219), COEFF(1.8814, 224), COEFF(0, 224) }, | ||
440 | }; | ||
441 | bool full = tpg->real_quantization == V4L2_QUANTIZATION_FULL_RANGE; | ||
442 | int lin_r, lin_g, lin_b, lin_y; | ||
443 | |||
444 | switch (tpg->real_ycbcr_enc) { | ||
445 | case V4L2_YCBCR_ENC_601: | ||
446 | case V4L2_YCBCR_ENC_XV601: | ||
447 | case V4L2_YCBCR_ENC_SYCC: | ||
448 | ycbcr2rgb(full ? bt601_full : bt601, y, cb, cr, 16, r, g, b); | ||
449 | break; | ||
450 | case V4L2_YCBCR_ENC_BT2020: | ||
451 | ycbcr2rgb(bt2020, y, cb, cr, 16, r, g, b); | ||
452 | break; | ||
453 | case V4L2_YCBCR_ENC_BT2020_CONST_LUM: | ||
454 | y -= 16 << 4; | ||
455 | cb -= 128 << 4; | ||
456 | cr -= 128 << 4; | ||
400 | 457 | ||
401 | y -= 16 << 4; | 458 | if (cb <= 0) |
402 | cb -= 128 << 4; | 459 | *b = COEFF(1.0, 219) * y + COEFF(1.9404, 224) * cb; |
403 | cr -= 128 << 4; | 460 | else |
404 | switch (tpg->colorspace) { | 461 | *b = COEFF(1.0, 219) * y + COEFF(1.5816, 224) * cb; |
405 | case V4L2_COLORSPACE_SMPTE170M: | 462 | *b = *b >> 12; |
406 | case V4L2_COLORSPACE_470_SYSTEM_M: | 463 | if (cr <= 0) |
407 | case V4L2_COLORSPACE_470_SYSTEM_BG: | 464 | *r = COEFF(1.0, 219) * y + COEFF(1.7184, 224) * cr; |
408 | b = 4769 * y + 7343 * cb; | 465 | else |
466 | *r = COEFF(1.0, 219) * y + COEFF(0.9936, 224) * cr; | ||
467 | *r = *r >> 12; | ||
468 | lin_r = rec709_to_linear(*r); | ||
469 | lin_b = rec709_to_linear(*b); | ||
470 | lin_y = rec709_to_linear((y * 255) / 219); | ||
471 | |||
472 | lin_g = COEFF(1.0 / 0.6780, 255) * lin_y - | ||
473 | COEFF(0.2627 / 0.6780, 255) * lin_r - | ||
474 | COEFF(0.0593 / 0.6780, 255) * lin_b; | ||
475 | *g = linear_to_rec709(lin_g >> 12); | ||
409 | break; | 476 | break; |
410 | case V4L2_COLORSPACE_SMPTE240M: | 477 | case V4L2_YCBCR_ENC_SMPTE240M: |
411 | b = 4769 * y + 8552 * cb; | 478 | ycbcr2rgb(smpte240m, y, cb, cr, 16, r, g, b); |
412 | break; | 479 | break; |
413 | case V4L2_COLORSPACE_REC709: | 480 | case V4L2_YCBCR_ENC_709: |
414 | case V4L2_COLORSPACE_SRGB: | 481 | case V4L2_YCBCR_ENC_XV709: |
415 | default: | 482 | default: |
416 | b = 4769 * y + 8652 * cb; | 483 | ycbcr2rgb(full ? rec709_full : rec709, y, cb, cr, 16, r, g, b); |
417 | break; | 484 | break; |
418 | } | 485 | } |
419 | return clamp(b >> 12, 0, 0xff0); | ||
420 | } | 486 | } |
421 | 487 | ||
422 | /* precalculate color bar values to speed up rendering */ | 488 | /* precalculate color bar values to speed up rendering */ |
@@ -456,18 +522,17 @@ static void precalculate_color(struct tpg_data *tpg, int k) | |||
456 | g <<= 4; | 522 | g <<= 4; |
457 | b <<= 4; | 523 | b <<= 4; |
458 | } | 524 | } |
459 | if (tpg->qual == TPG_QUAL_GRAY) | 525 | if (tpg->qual == TPG_QUAL_GRAY) { |
460 | r = g = b = color_to_y(tpg, r, g, b); | 526 | /* Rec. 709 Luma function */ |
527 | /* (0.2126, 0.7152, 0.0722) * (255 * 256) */ | ||
528 | r = g = b = ((13879 * r + 46688 * g + 4713 * b) >> 16) + (16 << 4); | ||
529 | } | ||
461 | 530 | ||
462 | /* | 531 | /* |
463 | * The assumption is that the RGB output is always full range, | 532 | * The assumption is that the RGB output is always full range, |
464 | * so only if the rgb_range overrides the 'real' rgb range do | 533 | * so only if the rgb_range overrides the 'real' rgb range do |
465 | * we need to convert the RGB values. | 534 | * we need to convert the RGB values. |
466 | * | 535 | * |
467 | * Currently there is no way of signalling to userspace if you | ||
468 | * are actually giving it limited range RGB (or full range | ||
469 | * YUV for that matter). | ||
470 | * | ||
471 | * Remember that r, g and b are still in the 0 - 0xff0 range. | 536 | * Remember that r, g and b are still in the 0 - 0xff0 range. |
472 | */ | 537 | */ |
473 | if (tpg->real_rgb_range == V4L2_DV_RGB_RANGE_LIMITED && | 538 | if (tpg->real_rgb_range == V4L2_DV_RGB_RANGE_LIMITED && |
@@ -497,12 +562,12 @@ static void precalculate_color(struct tpg_data *tpg, int k) | |||
497 | if (tpg->brightness != 128 || tpg->contrast != 128 || | 562 | if (tpg->brightness != 128 || tpg->contrast != 128 || |
498 | tpg->saturation != 128 || tpg->hue) { | 563 | tpg->saturation != 128 || tpg->hue) { |
499 | /* Implement these operations */ | 564 | /* Implement these operations */ |
565 | int y, cb, cr; | ||
566 | int tmp_cb, tmp_cr; | ||
500 | 567 | ||
501 | /* First convert to YCbCr */ | 568 | /* First convert to YCbCr */ |
502 | int y = color_to_y(tpg, r, g, b); /* Luma */ | 569 | |
503 | int cb = color_to_cb(tpg, r, g, b); /* Cb */ | 570 | color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); |
504 | int cr = color_to_cr(tpg, r, g, b); /* Cr */ | ||
505 | int tmp_cb, tmp_cr; | ||
506 | 571 | ||
507 | y = (16 << 4) + ((y - (16 << 4)) * tpg->contrast) / 128; | 572 | y = (16 << 4) + ((y - (16 << 4)) * tpg->contrast) / 128; |
508 | y += (tpg->brightness << 4) - (128 << 4); | 573 | y += (tpg->brightness << 4) - (128 << 4); |
@@ -520,21 +585,29 @@ static void precalculate_color(struct tpg_data *tpg, int k) | |||
520 | tpg->colors[k][2] = clamp(cr >> 4, 1, 254); | 585 | tpg->colors[k][2] = clamp(cr >> 4, 1, 254); |
521 | return; | 586 | return; |
522 | } | 587 | } |
523 | r = ycbcr_to_r(tpg, y, cb, cr); | 588 | ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b); |
524 | g = ycbcr_to_g(tpg, y, cb, cr); | ||
525 | b = ycbcr_to_b(tpg, y, cb, cr); | ||
526 | } | 589 | } |
527 | 590 | ||
528 | if (tpg->is_yuv) { | 591 | if (tpg->is_yuv) { |
529 | /* Convert to YCbCr */ | 592 | /* Convert to YCbCr */ |
530 | u16 y = color_to_y(tpg, r, g, b); /* Luma */ | 593 | int y, cb, cr; |
531 | u16 cb = color_to_cb(tpg, r, g, b); /* Cb */ | 594 | |
532 | u16 cr = color_to_cr(tpg, r, g, b); /* Cr */ | 595 | color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); |
533 | 596 | ||
597 | if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) { | ||
598 | y = clamp(y, 16 << 4, 235 << 4); | ||
599 | cb = clamp(cb, 16 << 4, 240 << 4); | ||
600 | cr = clamp(cr, 16 << 4, 240 << 4); | ||
601 | } | ||
534 | tpg->colors[k][0] = clamp(y >> 4, 1, 254); | 602 | tpg->colors[k][0] = clamp(y >> 4, 1, 254); |
535 | tpg->colors[k][1] = clamp(cb >> 4, 1, 254); | 603 | tpg->colors[k][1] = clamp(cb >> 4, 1, 254); |
536 | tpg->colors[k][2] = clamp(cr >> 4, 1, 254); | 604 | tpg->colors[k][2] = clamp(cr >> 4, 1, 254); |
537 | } else { | 605 | } else { |
606 | if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) { | ||
607 | r = (r * 219) / 255 + (16 << 4); | ||
608 | g = (g * 219) / 255 + (16 << 4); | ||
609 | b = (b * 219) / 255 + (16 << 4); | ||
610 | } | ||
538 | switch (tpg->fourcc) { | 611 | switch (tpg->fourcc) { |
539 | case V4L2_PIX_FMT_RGB565: | 612 | case V4L2_PIX_FMT_RGB565: |
540 | case V4L2_PIX_FMT_RGB565X: | 613 | case V4L2_PIX_FMT_RGB565X: |
@@ -1152,6 +1225,46 @@ static void tpg_recalc(struct tpg_data *tpg) | |||
1152 | if (tpg->recalc_colors) { | 1225 | if (tpg->recalc_colors) { |
1153 | tpg->recalc_colors = false; | 1226 | tpg->recalc_colors = false; |
1154 | tpg->recalc_lines = true; | 1227 | tpg->recalc_lines = true; |
1228 | tpg->real_ycbcr_enc = tpg->ycbcr_enc; | ||
1229 | tpg->real_quantization = tpg->quantization; | ||
1230 | if (tpg->ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) { | ||
1231 | switch (tpg->colorspace) { | ||
1232 | case V4L2_COLORSPACE_REC709: | ||
1233 | tpg->real_ycbcr_enc = V4L2_YCBCR_ENC_709; | ||
1234 | break; | ||
1235 | case V4L2_COLORSPACE_SRGB: | ||
1236 | tpg->real_ycbcr_enc = V4L2_YCBCR_ENC_SYCC; | ||
1237 | break; | ||
1238 | case V4L2_COLORSPACE_BT2020: | ||
1239 | tpg->real_ycbcr_enc = V4L2_YCBCR_ENC_BT2020; | ||
1240 | break; | ||
1241 | case V4L2_COLORSPACE_SMPTE240M: | ||
1242 | tpg->real_ycbcr_enc = V4L2_YCBCR_ENC_SMPTE240M; | ||
1243 | break; | ||
1244 | case V4L2_COLORSPACE_SMPTE170M: | ||
1245 | case V4L2_COLORSPACE_470_SYSTEM_M: | ||
1246 | case V4L2_COLORSPACE_470_SYSTEM_BG: | ||
1247 | case V4L2_COLORSPACE_ADOBERGB: | ||
1248 | default: | ||
1249 | tpg->real_ycbcr_enc = V4L2_YCBCR_ENC_601; | ||
1250 | break; | ||
1251 | } | ||
1252 | } | ||
1253 | if (tpg->quantization == V4L2_QUANTIZATION_DEFAULT) { | ||
1254 | tpg->real_quantization = V4L2_QUANTIZATION_FULL_RANGE; | ||
1255 | if (tpg->is_yuv) { | ||
1256 | switch (tpg->real_ycbcr_enc) { | ||
1257 | case V4L2_YCBCR_ENC_SYCC: | ||
1258 | case V4L2_YCBCR_ENC_XV601: | ||
1259 | case V4L2_YCBCR_ENC_XV709: | ||
1260 | break; | ||
1261 | default: | ||
1262 | tpg->real_quantization = | ||
1263 | V4L2_QUANTIZATION_LIM_RANGE; | ||
1264 | break; | ||
1265 | } | ||
1266 | } | ||
1267 | } | ||
1155 | tpg_precalculate_colors(tpg); | 1268 | tpg_precalculate_colors(tpg); |
1156 | } | 1269 | } |
1157 | if (tpg->recalc_square_border) { | 1270 | if (tpg->recalc_square_border) { |
diff --git a/drivers/media/platform/vivid/vivid-tpg.h b/drivers/media/platform/vivid/vivid-tpg.h index 8ef3e52ba3be..9dc463a40ed3 100644 --- a/drivers/media/platform/vivid/vivid-tpg.h +++ b/drivers/media/platform/vivid/vivid-tpg.h | |||
@@ -119,6 +119,18 @@ struct tpg_data { | |||
119 | u32 fourcc; | 119 | u32 fourcc; |
120 | bool is_yuv; | 120 | bool is_yuv; |
121 | u32 colorspace; | 121 | u32 colorspace; |
122 | u32 ycbcr_enc; | ||
123 | /* | ||
124 | * Stores the actual Y'CbCr encoding, i.e. will never be | ||
125 | * V4L2_YCBCR_ENC_DEFAULT. | ||
126 | */ | ||
127 | u32 real_ycbcr_enc; | ||
128 | u32 quantization; | ||
129 | /* | ||
130 | * Stores the actual quantization, i.e. will never be | ||
131 | * V4L2_QUANTIZATION_DEFAULT. | ||
132 | */ | ||
133 | u32 real_quantization; | ||
122 | enum tpg_video_aspect vid_aspect; | 134 | enum tpg_video_aspect vid_aspect; |
123 | enum tpg_pixel_aspect pix_aspect; | 135 | enum tpg_pixel_aspect pix_aspect; |
124 | unsigned rgb_range; | 136 | unsigned rgb_range; |
@@ -286,6 +298,32 @@ static inline u32 tpg_g_colorspace(const struct tpg_data *tpg) | |||
286 | return tpg->colorspace; | 298 | return tpg->colorspace; |
287 | } | 299 | } |
288 | 300 | ||
301 | static inline void tpg_s_ycbcr_enc(struct tpg_data *tpg, u32 ycbcr_enc) | ||
302 | { | ||
303 | if (tpg->ycbcr_enc == ycbcr_enc) | ||
304 | return; | ||
305 | tpg->ycbcr_enc = ycbcr_enc; | ||
306 | tpg->recalc_colors = true; | ||
307 | } | ||
308 | |||
309 | static inline u32 tpg_g_ycbcr_enc(const struct tpg_data *tpg) | ||
310 | { | ||
311 | return tpg->ycbcr_enc; | ||
312 | } | ||
313 | |||
314 | static inline void tpg_s_quantization(struct tpg_data *tpg, u32 quantization) | ||
315 | { | ||
316 | if (tpg->quantization == quantization) | ||
317 | return; | ||
318 | tpg->quantization = quantization; | ||
319 | tpg->recalc_colors = true; | ||
320 | } | ||
321 | |||
322 | static inline u32 tpg_g_quantization(const struct tpg_data *tpg) | ||
323 | { | ||
324 | return tpg->quantization; | ||
325 | } | ||
326 | |||
289 | static inline unsigned tpg_g_planes(const struct tpg_data *tpg) | 327 | static inline unsigned tpg_g_planes(const struct tpg_data *tpg) |
290 | { | 328 | { |
291 | return tpg->planes; | 329 | return tpg->planes; |
diff --git a/drivers/media/platform/vivid/vivid-vbi-cap.c b/drivers/media/platform/vivid/vivid-vbi-cap.c index 2166d0bf6fe2..ef81b01b53d2 100644 --- a/drivers/media/platform/vivid/vivid-vbi-cap.c +++ b/drivers/media/platform/vivid/vivid-vbi-cap.c | |||
@@ -236,8 +236,8 @@ const struct vb2_ops vivid_vbi_cap_qops = { | |||
236 | .buf_queue = vbi_cap_buf_queue, | 236 | .buf_queue = vbi_cap_buf_queue, |
237 | .start_streaming = vbi_cap_start_streaming, | 237 | .start_streaming = vbi_cap_start_streaming, |
238 | .stop_streaming = vbi_cap_stop_streaming, | 238 | .stop_streaming = vbi_cap_stop_streaming, |
239 | .wait_prepare = vivid_unlock, | 239 | .wait_prepare = vb2_ops_wait_prepare, |
240 | .wait_finish = vivid_lock, | 240 | .wait_finish = vb2_ops_wait_finish, |
241 | }; | 241 | }; |
242 | 242 | ||
243 | int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, | 243 | int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, |
diff --git a/drivers/media/platform/vivid/vivid-vbi-out.c b/drivers/media/platform/vivid/vivid-vbi-out.c index 9d00a07ecdcd..4e4c70e1e04a 100644 --- a/drivers/media/platform/vivid/vivid-vbi-out.c +++ b/drivers/media/platform/vivid/vivid-vbi-out.c | |||
@@ -131,8 +131,8 @@ const struct vb2_ops vivid_vbi_out_qops = { | |||
131 | .buf_queue = vbi_out_buf_queue, | 131 | .buf_queue = vbi_out_buf_queue, |
132 | .start_streaming = vbi_out_start_streaming, | 132 | .start_streaming = vbi_out_start_streaming, |
133 | .stop_streaming = vbi_out_stop_streaming, | 133 | .stop_streaming = vbi_out_stop_streaming, |
134 | .wait_prepare = vivid_unlock, | 134 | .wait_prepare = vb2_ops_wait_prepare, |
135 | .wait_finish = vivid_lock, | 135 | .wait_finish = vb2_ops_wait_finish, |
136 | }; | 136 | }; |
137 | 137 | ||
138 | int vidioc_g_fmt_vbi_out(struct file *file, void *priv, | 138 | int vidioc_g_fmt_vbi_out(struct file *file, void *priv, |
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c index 331c54429b40..867a29a6d18f 100644 --- a/drivers/media/platform/vivid/vivid-vid-cap.c +++ b/drivers/media/platform/vivid/vivid-vid-cap.c | |||
@@ -288,8 +288,8 @@ const struct vb2_ops vivid_vid_cap_qops = { | |||
288 | .buf_queue = vid_cap_buf_queue, | 288 | .buf_queue = vid_cap_buf_queue, |
289 | .start_streaming = vid_cap_start_streaming, | 289 | .start_streaming = vid_cap_start_streaming, |
290 | .stop_streaming = vid_cap_stop_streaming, | 290 | .stop_streaming = vid_cap_stop_streaming, |
291 | .wait_prepare = vivid_unlock, | 291 | .wait_prepare = vb2_ops_wait_prepare, |
292 | .wait_finish = vivid_lock, | 292 | .wait_finish = vb2_ops_wait_finish, |
293 | }; | 293 | }; |
294 | 294 | ||
295 | /* | 295 | /* |
@@ -443,12 +443,12 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls) | |||
443 | break; | 443 | break; |
444 | if (bt->standards & V4L2_DV_BT_STD_CEA861) { | 444 | if (bt->standards & V4L2_DV_BT_STD_CEA861) { |
445 | if (bt->width == 720 && bt->height <= 576) | 445 | if (bt->width == 720 && bt->height <= 576) |
446 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SMPTE170M); | 446 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); |
447 | else | 447 | else |
448 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_REC709); | 448 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709); |
449 | v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 1); | 449 | v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 1); |
450 | } else { | 450 | } else { |
451 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SRGB); | 451 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); |
452 | v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 0); | 452 | v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 0); |
453 | } | 453 | } |
454 | tpg_s_rgb_range(&dev->tpg, v4l2_ctrl_g_ctrl(dev->rgb_range_cap)); | 454 | tpg_s_rgb_range(&dev->tpg, v4l2_ctrl_g_ctrl(dev->rgb_range_cap)); |
@@ -498,6 +498,20 @@ static unsigned vivid_colorspace_cap(struct vivid_dev *dev) | |||
498 | return dev->colorspace_out; | 498 | return dev->colorspace_out; |
499 | } | 499 | } |
500 | 500 | ||
501 | static unsigned vivid_ycbcr_enc_cap(struct vivid_dev *dev) | ||
502 | { | ||
503 | if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) | ||
504 | return tpg_g_ycbcr_enc(&dev->tpg); | ||
505 | return dev->ycbcr_enc_out; | ||
506 | } | ||
507 | |||
508 | static unsigned vivid_quantization_cap(struct vivid_dev *dev) | ||
509 | { | ||
510 | if (!dev->loop_video || vivid_is_webcam(dev) || vivid_is_tv_cap(dev)) | ||
511 | return tpg_g_quantization(&dev->tpg); | ||
512 | return dev->quantization_out; | ||
513 | } | ||
514 | |||
501 | int vivid_g_fmt_vid_cap(struct file *file, void *priv, | 515 | int vivid_g_fmt_vid_cap(struct file *file, void *priv, |
502 | struct v4l2_format *f) | 516 | struct v4l2_format *f) |
503 | { | 517 | { |
@@ -510,6 +524,8 @@ int vivid_g_fmt_vid_cap(struct file *file, void *priv, | |||
510 | mp->field = dev->field_cap; | 524 | mp->field = dev->field_cap; |
511 | mp->pixelformat = dev->fmt_cap->fourcc; | 525 | mp->pixelformat = dev->fmt_cap->fourcc; |
512 | mp->colorspace = vivid_colorspace_cap(dev); | 526 | mp->colorspace = vivid_colorspace_cap(dev); |
527 | mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); | ||
528 | mp->quantization = vivid_quantization_cap(dev); | ||
513 | mp->num_planes = dev->fmt_cap->planes; | 529 | mp->num_planes = dev->fmt_cap->planes; |
514 | for (p = 0; p < mp->num_planes; p++) { | 530 | for (p = 0; p < mp->num_planes; p++) { |
515 | mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p); | 531 | mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p); |
@@ -595,6 +611,8 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv, | |||
595 | memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved)); | 611 | memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved)); |
596 | } | 612 | } |
597 | mp->colorspace = vivid_colorspace_cap(dev); | 613 | mp->colorspace = vivid_colorspace_cap(dev); |
614 | mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev); | ||
615 | mp->quantization = vivid_quantization_cap(dev); | ||
598 | memset(mp->reserved, 0, sizeof(mp->reserved)); | 616 | memset(mp->reserved, 0, sizeof(mp->reserved)); |
599 | return 0; | 617 | return 0; |
600 | } | 618 | } |
@@ -1307,20 +1325,20 @@ int vidioc_s_input(struct file *file, void *priv, unsigned i) | |||
1307 | if (dev->colorspace) { | 1325 | if (dev->colorspace) { |
1308 | switch (dev->input_type[i]) { | 1326 | switch (dev->input_type[i]) { |
1309 | case WEBCAM: | 1327 | case WEBCAM: |
1310 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SRGB); | 1328 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); |
1311 | break; | 1329 | break; |
1312 | case TV: | 1330 | case TV: |
1313 | case SVID: | 1331 | case SVID: |
1314 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SMPTE170M); | 1332 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); |
1315 | break; | 1333 | break; |
1316 | case HDMI: | 1334 | case HDMI: |
1317 | if (bt->standards & V4L2_DV_BT_STD_CEA861) { | 1335 | if (bt->standards & V4L2_DV_BT_STD_CEA861) { |
1318 | if (dev->src_rect.width == 720 && dev->src_rect.height <= 576) | 1336 | if (dev->src_rect.width == 720 && dev->src_rect.height <= 576) |
1319 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SMPTE170M); | 1337 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M); |
1320 | else | 1338 | else |
1321 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_REC709); | 1339 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709); |
1322 | } else { | 1340 | } else { |
1323 | v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SRGB); | 1341 | v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB); |
1324 | } | 1342 | } |
1325 | break; | 1343 | break; |
1326 | } | 1344 | } |
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c index 16cd6d2d2ed6..6bef1e6d6788 100644 --- a/drivers/media/platform/vivid/vivid-vid-common.c +++ b/drivers/media/platform/vivid/vivid-vid-common.c | |||
@@ -259,6 +259,8 @@ void fmt_sp2mp(const struct v4l2_format *sp_fmt, struct v4l2_format *mp_fmt) | |||
259 | mp->pixelformat = pix->pixelformat; | 259 | mp->pixelformat = pix->pixelformat; |
260 | mp->field = pix->field; | 260 | mp->field = pix->field; |
261 | mp->colorspace = pix->colorspace; | 261 | mp->colorspace = pix->colorspace; |
262 | mp->ycbcr_enc = pix->ycbcr_enc; | ||
263 | mp->quantization = pix->quantization; | ||
262 | mp->num_planes = 1; | 264 | mp->num_planes = 1; |
263 | mp->flags = pix->flags; | 265 | mp->flags = pix->flags; |
264 | ppix->sizeimage = pix->sizeimage; | 266 | ppix->sizeimage = pix->sizeimage; |
@@ -285,6 +287,8 @@ int fmt_sp2mp_func(struct file *file, void *priv, | |||
285 | pix->pixelformat = mp->pixelformat; | 287 | pix->pixelformat = mp->pixelformat; |
286 | pix->field = mp->field; | 288 | pix->field = mp->field; |
287 | pix->colorspace = mp->colorspace; | 289 | pix->colorspace = mp->colorspace; |
290 | pix->ycbcr_enc = mp->ycbcr_enc; | ||
291 | pix->quantization = mp->quantization; | ||
288 | pix->sizeimage = ppix->sizeimage; | 292 | pix->sizeimage = ppix->sizeimage; |
289 | pix->bytesperline = ppix->bytesperline; | 293 | pix->bytesperline = ppix->bytesperline; |
290 | pix->flags = mp->flags; | 294 | pix->flags = mp->flags; |
diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c index 69c2dbd2d165..ee5c3992b276 100644 --- a/drivers/media/platform/vivid/vivid-vid-out.c +++ b/drivers/media/platform/vivid/vivid-vid-out.c | |||
@@ -209,8 +209,8 @@ const struct vb2_ops vivid_vid_out_qops = { | |||
209 | .buf_queue = vid_out_buf_queue, | 209 | .buf_queue = vid_out_buf_queue, |
210 | .start_streaming = vid_out_start_streaming, | 210 | .start_streaming = vid_out_start_streaming, |
211 | .stop_streaming = vid_out_stop_streaming, | 211 | .stop_streaming = vid_out_stop_streaming, |
212 | .wait_prepare = vivid_unlock, | 212 | .wait_prepare = vb2_ops_wait_prepare, |
213 | .wait_finish = vivid_lock, | 213 | .wait_finish = vb2_ops_wait_finish, |
214 | }; | 214 | }; |
215 | 215 | ||
216 | /* | 216 | /* |
@@ -259,6 +259,8 @@ void vivid_update_format_out(struct vivid_dev *dev) | |||
259 | } | 259 | } |
260 | break; | 260 | break; |
261 | } | 261 | } |
262 | dev->ycbcr_enc_out = V4L2_YCBCR_ENC_DEFAULT; | ||
263 | dev->quantization_out = V4L2_QUANTIZATION_DEFAULT; | ||
262 | dev->compose_out = dev->sink_rect; | 264 | dev->compose_out = dev->sink_rect; |
263 | dev->compose_bounds_out = dev->sink_rect; | 265 | dev->compose_bounds_out = dev->sink_rect; |
264 | dev->crop_out = dev->compose_out; | 266 | dev->crop_out = dev->compose_out; |
@@ -318,6 +320,8 @@ int vivid_g_fmt_vid_out(struct file *file, void *priv, | |||
318 | mp->field = dev->field_out; | 320 | mp->field = dev->field_out; |
319 | mp->pixelformat = dev->fmt_out->fourcc; | 321 | mp->pixelformat = dev->fmt_out->fourcc; |
320 | mp->colorspace = dev->colorspace_out; | 322 | mp->colorspace = dev->colorspace_out; |
323 | mp->ycbcr_enc = dev->ycbcr_enc_out; | ||
324 | mp->quantization = dev->quantization_out; | ||
321 | mp->num_planes = dev->fmt_out->planes; | 325 | mp->num_planes = dev->fmt_out->planes; |
322 | for (p = 0; p < mp->num_planes; p++) { | 326 | for (p = 0; p < mp->num_planes; p++) { |
323 | mp->plane_fmt[p].bytesperline = dev->bytesperline_out[p]; | 327 | mp->plane_fmt[p].bytesperline = dev->bytesperline_out[p]; |
@@ -394,16 +398,23 @@ int vivid_try_fmt_vid_out(struct file *file, void *priv, | |||
394 | pfmt[p].sizeimage = pfmt[p].bytesperline * mp->height; | 398 | pfmt[p].sizeimage = pfmt[p].bytesperline * mp->height; |
395 | memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved)); | 399 | memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved)); |
396 | } | 400 | } |
397 | if (vivid_is_svid_out(dev)) | 401 | mp->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; |
402 | mp->quantization = V4L2_QUANTIZATION_DEFAULT; | ||
403 | if (vivid_is_svid_out(dev)) { | ||
398 | mp->colorspace = V4L2_COLORSPACE_SMPTE170M; | 404 | mp->colorspace = V4L2_COLORSPACE_SMPTE170M; |
399 | else if (dev->dvi_d_out || !(bt->standards & V4L2_DV_BT_STD_CEA861)) | 405 | } else if (dev->dvi_d_out || !(bt->standards & V4L2_DV_BT_STD_CEA861)) { |
400 | mp->colorspace = V4L2_COLORSPACE_SRGB; | 406 | mp->colorspace = V4L2_COLORSPACE_SRGB; |
401 | else if (bt->width == 720 && bt->height <= 576) | 407 | if (dev->dvi_d_out) |
408 | mp->quantization = V4L2_QUANTIZATION_LIM_RANGE; | ||
409 | } else if (bt->width == 720 && bt->height <= 576) { | ||
402 | mp->colorspace = V4L2_COLORSPACE_SMPTE170M; | 410 | mp->colorspace = V4L2_COLORSPACE_SMPTE170M; |
403 | else if (mp->colorspace != V4L2_COLORSPACE_SMPTE170M && | 411 | } else if (mp->colorspace != V4L2_COLORSPACE_SMPTE170M && |
404 | mp->colorspace != V4L2_COLORSPACE_REC709 && | 412 | mp->colorspace != V4L2_COLORSPACE_REC709 && |
405 | mp->colorspace != V4L2_COLORSPACE_SRGB) | 413 | mp->colorspace != V4L2_COLORSPACE_ADOBERGB && |
414 | mp->colorspace != V4L2_COLORSPACE_BT2020 && | ||
415 | mp->colorspace != V4L2_COLORSPACE_SRGB) { | ||
406 | mp->colorspace = V4L2_COLORSPACE_REC709; | 416 | mp->colorspace = V4L2_COLORSPACE_REC709; |
417 | } | ||
407 | memset(mp->reserved, 0, sizeof(mp->reserved)); | 418 | memset(mp->reserved, 0, sizeof(mp->reserved)); |
408 | return 0; | 419 | return 0; |
409 | } | 420 | } |
@@ -522,6 +533,8 @@ int vivid_s_fmt_vid_out(struct file *file, void *priv, | |||
522 | 533 | ||
523 | set_colorspace: | 534 | set_colorspace: |
524 | dev->colorspace_out = mp->colorspace; | 535 | dev->colorspace_out = mp->colorspace; |
536 | dev->ycbcr_enc_out = mp->ycbcr_enc; | ||
537 | dev->quantization_out = mp->quantization; | ||
525 | if (dev->loop_video) { | 538 | if (dev->loop_video) { |
526 | vivid_send_source_change(dev, SVID); | 539 | vivid_send_source_change(dev, SVID); |
527 | vivid_send_source_change(dev, HDMI); | 540 | vivid_send_source_change(dev, HDMI); |
diff --git a/drivers/media/platform/vsp1/vsp1_bru.c b/drivers/media/platform/vsp1/vsp1_bru.c index a0c1984c733e..b21f381a9862 100644 --- a/drivers/media/platform/vsp1/vsp1_bru.c +++ b/drivers/media/platform/vsp1/vsp1_bru.c | |||
@@ -187,8 +187,8 @@ static int bru_enum_mbus_code(struct v4l2_subdev *subdev, | |||
187 | struct v4l2_subdev_mbus_code_enum *code) | 187 | struct v4l2_subdev_mbus_code_enum *code) |
188 | { | 188 | { |
189 | static const unsigned int codes[] = { | 189 | static const unsigned int codes[] = { |
190 | V4L2_MBUS_FMT_ARGB8888_1X32, | 190 | MEDIA_BUS_FMT_ARGB8888_1X32, |
191 | V4L2_MBUS_FMT_AYUV8_1X32, | 191 | MEDIA_BUS_FMT_AYUV8_1X32, |
192 | }; | 192 | }; |
193 | struct v4l2_mbus_framefmt *format; | 193 | struct v4l2_mbus_framefmt *format; |
194 | 194 | ||
@@ -215,8 +215,8 @@ static int bru_enum_frame_size(struct v4l2_subdev *subdev, | |||
215 | if (fse->index) | 215 | if (fse->index) |
216 | return -EINVAL; | 216 | return -EINVAL; |
217 | 217 | ||
218 | if (fse->code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 218 | if (fse->code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
219 | fse->code != V4L2_MBUS_FMT_AYUV8_1X32) | 219 | fse->code != MEDIA_BUS_FMT_AYUV8_1X32) |
220 | return -EINVAL; | 220 | return -EINVAL; |
221 | 221 | ||
222 | fse->min_width = BRU_MIN_SIZE; | 222 | fse->min_width = BRU_MIN_SIZE; |
@@ -261,9 +261,9 @@ static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_fh *fh, | |||
261 | switch (pad) { | 261 | switch (pad) { |
262 | case BRU_PAD_SINK(0): | 262 | case BRU_PAD_SINK(0): |
263 | /* Default to YUV if the requested format is not supported. */ | 263 | /* Default to YUV if the requested format is not supported. */ |
264 | if (fmt->code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 264 | if (fmt->code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
265 | fmt->code != V4L2_MBUS_FMT_AYUV8_1X32) | 265 | fmt->code != MEDIA_BUS_FMT_AYUV8_1X32) |
266 | fmt->code = V4L2_MBUS_FMT_AYUV8_1X32; | 266 | fmt->code = MEDIA_BUS_FMT_AYUV8_1X32; |
267 | break; | 267 | break; |
268 | 268 | ||
269 | default: | 269 | default: |
diff --git a/drivers/media/platform/vsp1/vsp1_hsit.c b/drivers/media/platform/vsp1/vsp1_hsit.c index db2950a73c60..80bedc554ee3 100644 --- a/drivers/media/platform/vsp1/vsp1_hsit.c +++ b/drivers/media/platform/vsp1/vsp1_hsit.c | |||
@@ -70,9 +70,9 @@ static int hsit_enum_mbus_code(struct v4l2_subdev *subdev, | |||
70 | 70 | ||
71 | if ((code->pad == HSIT_PAD_SINK && !hsit->inverse) | | 71 | if ((code->pad == HSIT_PAD_SINK && !hsit->inverse) | |
72 | (code->pad == HSIT_PAD_SOURCE && hsit->inverse)) | 72 | (code->pad == HSIT_PAD_SOURCE && hsit->inverse)) |
73 | code->code = V4L2_MBUS_FMT_ARGB8888_1X32; | 73 | code->code = MEDIA_BUS_FMT_ARGB8888_1X32; |
74 | else | 74 | else |
75 | code->code = V4L2_MBUS_FMT_AHSV8888_1X32; | 75 | code->code = MEDIA_BUS_FMT_AHSV8888_1X32; |
76 | 76 | ||
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
@@ -136,8 +136,8 @@ static int hsit_set_format(struct v4l2_subdev *subdev, | |||
136 | return 0; | 136 | return 0; |
137 | } | 137 | } |
138 | 138 | ||
139 | format->code = hsit->inverse ? V4L2_MBUS_FMT_AHSV8888_1X32 | 139 | format->code = hsit->inverse ? MEDIA_BUS_FMT_AHSV8888_1X32 |
140 | : V4L2_MBUS_FMT_ARGB8888_1X32; | 140 | : MEDIA_BUS_FMT_ARGB8888_1X32; |
141 | format->width = clamp_t(unsigned int, fmt->format.width, | 141 | format->width = clamp_t(unsigned int, fmt->format.width, |
142 | HSIT_MIN_SIZE, HSIT_MAX_SIZE); | 142 | HSIT_MIN_SIZE, HSIT_MAX_SIZE); |
143 | format->height = clamp_t(unsigned int, fmt->format.height, | 143 | format->height = clamp_t(unsigned int, fmt->format.height, |
@@ -151,8 +151,8 @@ static int hsit_set_format(struct v4l2_subdev *subdev, | |||
151 | format = vsp1_entity_get_pad_format(&hsit->entity, fh, HSIT_PAD_SOURCE, | 151 | format = vsp1_entity_get_pad_format(&hsit->entity, fh, HSIT_PAD_SOURCE, |
152 | fmt->which); | 152 | fmt->which); |
153 | *format = fmt->format; | 153 | *format = fmt->format; |
154 | format->code = hsit->inverse ? V4L2_MBUS_FMT_ARGB8888_1X32 | 154 | format->code = hsit->inverse ? MEDIA_BUS_FMT_ARGB8888_1X32 |
155 | : V4L2_MBUS_FMT_AHSV8888_1X32; | 155 | : MEDIA_BUS_FMT_AHSV8888_1X32; |
156 | 156 | ||
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
diff --git a/drivers/media/platform/vsp1/vsp1_lif.c b/drivers/media/platform/vsp1/vsp1_lif.c index d4fb23e9c4a8..17a6ca7dafe6 100644 --- a/drivers/media/platform/vsp1/vsp1_lif.c +++ b/drivers/media/platform/vsp1/vsp1_lif.c | |||
@@ -78,8 +78,8 @@ static int lif_enum_mbus_code(struct v4l2_subdev *subdev, | |||
78 | struct v4l2_subdev_mbus_code_enum *code) | 78 | struct v4l2_subdev_mbus_code_enum *code) |
79 | { | 79 | { |
80 | static const unsigned int codes[] = { | 80 | static const unsigned int codes[] = { |
81 | V4L2_MBUS_FMT_ARGB8888_1X32, | 81 | MEDIA_BUS_FMT_ARGB8888_1X32, |
82 | V4L2_MBUS_FMT_AYUV8_1X32, | 82 | MEDIA_BUS_FMT_AYUV8_1X32, |
83 | }; | 83 | }; |
84 | 84 | ||
85 | if (code->pad == LIF_PAD_SINK) { | 85 | if (code->pad == LIF_PAD_SINK) { |
@@ -147,9 +147,9 @@ static int lif_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, | |||
147 | struct v4l2_mbus_framefmt *format; | 147 | struct v4l2_mbus_framefmt *format; |
148 | 148 | ||
149 | /* Default to YUV if the requested format is not supported. */ | 149 | /* Default to YUV if the requested format is not supported. */ |
150 | if (fmt->format.code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 150 | if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
151 | fmt->format.code != V4L2_MBUS_FMT_AYUV8_1X32) | 151 | fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) |
152 | fmt->format.code = V4L2_MBUS_FMT_AYUV8_1X32; | 152 | fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; |
153 | 153 | ||
154 | format = vsp1_entity_get_pad_format(&lif->entity, fh, fmt->pad, | 154 | format = vsp1_entity_get_pad_format(&lif->entity, fh, fmt->pad, |
155 | fmt->which); | 155 | fmt->which); |
diff --git a/drivers/media/platform/vsp1/vsp1_lut.c b/drivers/media/platform/vsp1/vsp1_lut.c index fea36ebe2565..6f185c3621fe 100644 --- a/drivers/media/platform/vsp1/vsp1_lut.c +++ b/drivers/media/platform/vsp1/vsp1_lut.c | |||
@@ -86,9 +86,9 @@ static int lut_enum_mbus_code(struct v4l2_subdev *subdev, | |||
86 | struct v4l2_subdev_mbus_code_enum *code) | 86 | struct v4l2_subdev_mbus_code_enum *code) |
87 | { | 87 | { |
88 | static const unsigned int codes[] = { | 88 | static const unsigned int codes[] = { |
89 | V4L2_MBUS_FMT_ARGB8888_1X32, | 89 | MEDIA_BUS_FMT_ARGB8888_1X32, |
90 | V4L2_MBUS_FMT_AHSV8888_1X32, | 90 | MEDIA_BUS_FMT_AHSV8888_1X32, |
91 | V4L2_MBUS_FMT_AYUV8_1X32, | 91 | MEDIA_BUS_FMT_AYUV8_1X32, |
92 | }; | 92 | }; |
93 | struct v4l2_mbus_framefmt *format; | 93 | struct v4l2_mbus_framefmt *format; |
94 | 94 | ||
@@ -158,10 +158,10 @@ static int lut_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, | |||
158 | struct v4l2_mbus_framefmt *format; | 158 | struct v4l2_mbus_framefmt *format; |
159 | 159 | ||
160 | /* Default to YUV if the requested format is not supported. */ | 160 | /* Default to YUV if the requested format is not supported. */ |
161 | if (fmt->format.code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 161 | if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
162 | fmt->format.code != V4L2_MBUS_FMT_AHSV8888_1X32 && | 162 | fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 && |
163 | fmt->format.code != V4L2_MBUS_FMT_AYUV8_1X32) | 163 | fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) |
164 | fmt->format.code = V4L2_MBUS_FMT_AYUV8_1X32; | 164 | fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; |
165 | 165 | ||
166 | format = vsp1_entity_get_pad_format(&lut->entity, fh, fmt->pad, | 166 | format = vsp1_entity_get_pad_format(&lut->entity, fh, fmt->pad, |
167 | fmt->which); | 167 | fmt->which); |
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.c b/drivers/media/platform/vsp1/vsp1_rwpf.c index ec3dab6a9b9b..1f1ba26a834a 100644 --- a/drivers/media/platform/vsp1/vsp1_rwpf.c +++ b/drivers/media/platform/vsp1/vsp1_rwpf.c | |||
@@ -29,8 +29,8 @@ int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, | |||
29 | struct v4l2_subdev_mbus_code_enum *code) | 29 | struct v4l2_subdev_mbus_code_enum *code) |
30 | { | 30 | { |
31 | static const unsigned int codes[] = { | 31 | static const unsigned int codes[] = { |
32 | V4L2_MBUS_FMT_ARGB8888_1X32, | 32 | MEDIA_BUS_FMT_ARGB8888_1X32, |
33 | V4L2_MBUS_FMT_AYUV8_1X32, | 33 | MEDIA_BUS_FMT_AYUV8_1X32, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | if (code->index >= ARRAY_SIZE(codes)) | 36 | if (code->index >= ARRAY_SIZE(codes)) |
@@ -103,9 +103,9 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, | |||
103 | struct v4l2_rect *crop; | 103 | struct v4l2_rect *crop; |
104 | 104 | ||
105 | /* Default to YUV if the requested format is not supported. */ | 105 | /* Default to YUV if the requested format is not supported. */ |
106 | if (fmt->format.code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 106 | if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
107 | fmt->format.code != V4L2_MBUS_FMT_AYUV8_1X32) | 107 | fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) |
108 | fmt->format.code = V4L2_MBUS_FMT_AYUV8_1X32; | 108 | fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; |
109 | 109 | ||
110 | format = vsp1_entity_get_pad_format(&rwpf->entity, fh, fmt->pad, | 110 | format = vsp1_entity_get_pad_format(&rwpf->entity, fh, fmt->pad, |
111 | fmt->which); | 111 | fmt->which); |
diff --git a/drivers/media/platform/vsp1/vsp1_sru.c b/drivers/media/platform/vsp1/vsp1_sru.c index b7d3c8b9f189..1129494c7cfc 100644 --- a/drivers/media/platform/vsp1/vsp1_sru.c +++ b/drivers/media/platform/vsp1/vsp1_sru.c | |||
@@ -139,7 +139,7 @@ static int sru_s_stream(struct v4l2_subdev *subdev, int enable) | |||
139 | input = &sru->entity.formats[SRU_PAD_SINK]; | 139 | input = &sru->entity.formats[SRU_PAD_SINK]; |
140 | output = &sru->entity.formats[SRU_PAD_SOURCE]; | 140 | output = &sru->entity.formats[SRU_PAD_SOURCE]; |
141 | 141 | ||
142 | if (input->code == V4L2_MBUS_FMT_ARGB8888_1X32) | 142 | if (input->code == MEDIA_BUS_FMT_ARGB8888_1X32) |
143 | ctrl0 = VI6_SRU_CTRL0_PARAM2 | VI6_SRU_CTRL0_PARAM3 | 143 | ctrl0 = VI6_SRU_CTRL0_PARAM2 | VI6_SRU_CTRL0_PARAM3 |
144 | | VI6_SRU_CTRL0_PARAM4; | 144 | | VI6_SRU_CTRL0_PARAM4; |
145 | else | 145 | else |
@@ -170,8 +170,8 @@ static int sru_enum_mbus_code(struct v4l2_subdev *subdev, | |||
170 | struct v4l2_subdev_mbus_code_enum *code) | 170 | struct v4l2_subdev_mbus_code_enum *code) |
171 | { | 171 | { |
172 | static const unsigned int codes[] = { | 172 | static const unsigned int codes[] = { |
173 | V4L2_MBUS_FMT_ARGB8888_1X32, | 173 | MEDIA_BUS_FMT_ARGB8888_1X32, |
174 | V4L2_MBUS_FMT_AYUV8_1X32, | 174 | MEDIA_BUS_FMT_AYUV8_1X32, |
175 | }; | 175 | }; |
176 | struct v4l2_mbus_framefmt *format; | 176 | struct v4l2_mbus_framefmt *format; |
177 | 177 | ||
@@ -248,9 +248,9 @@ static void sru_try_format(struct vsp1_sru *sru, struct v4l2_subdev_fh *fh, | |||
248 | switch (pad) { | 248 | switch (pad) { |
249 | case SRU_PAD_SINK: | 249 | case SRU_PAD_SINK: |
250 | /* Default to YUV if the requested format is not supported. */ | 250 | /* Default to YUV if the requested format is not supported. */ |
251 | if (fmt->code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 251 | if (fmt->code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
252 | fmt->code != V4L2_MBUS_FMT_AYUV8_1X32) | 252 | fmt->code != MEDIA_BUS_FMT_AYUV8_1X32) |
253 | fmt->code = V4L2_MBUS_FMT_AYUV8_1X32; | 253 | fmt->code = MEDIA_BUS_FMT_AYUV8_1X32; |
254 | 254 | ||
255 | fmt->width = clamp(fmt->width, SRU_MIN_SIZE, SRU_MAX_SIZE); | 255 | fmt->width = clamp(fmt->width, SRU_MIN_SIZE, SRU_MAX_SIZE); |
256 | fmt->height = clamp(fmt->height, SRU_MIN_SIZE, SRU_MAX_SIZE); | 256 | fmt->height = clamp(fmt->height, SRU_MIN_SIZE, SRU_MAX_SIZE); |
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c index de92ef4944b3..a4afec133800 100644 --- a/drivers/media/platform/vsp1/vsp1_uds.c +++ b/drivers/media/platform/vsp1/vsp1_uds.c | |||
@@ -173,8 +173,8 @@ static int uds_enum_mbus_code(struct v4l2_subdev *subdev, | |||
173 | struct v4l2_subdev_mbus_code_enum *code) | 173 | struct v4l2_subdev_mbus_code_enum *code) |
174 | { | 174 | { |
175 | static const unsigned int codes[] = { | 175 | static const unsigned int codes[] = { |
176 | V4L2_MBUS_FMT_ARGB8888_1X32, | 176 | MEDIA_BUS_FMT_ARGB8888_1X32, |
177 | V4L2_MBUS_FMT_AYUV8_1X32, | 177 | MEDIA_BUS_FMT_AYUV8_1X32, |
178 | }; | 178 | }; |
179 | 179 | ||
180 | if (code->pad == UDS_PAD_SINK) { | 180 | if (code->pad == UDS_PAD_SINK) { |
@@ -246,9 +246,9 @@ static void uds_try_format(struct vsp1_uds *uds, struct v4l2_subdev_fh *fh, | |||
246 | switch (pad) { | 246 | switch (pad) { |
247 | case UDS_PAD_SINK: | 247 | case UDS_PAD_SINK: |
248 | /* Default to YUV if the requested format is not supported. */ | 248 | /* Default to YUV if the requested format is not supported. */ |
249 | if (fmt->code != V4L2_MBUS_FMT_ARGB8888_1X32 && | 249 | if (fmt->code != MEDIA_BUS_FMT_ARGB8888_1X32 && |
250 | fmt->code != V4L2_MBUS_FMT_AYUV8_1X32) | 250 | fmt->code != MEDIA_BUS_FMT_AYUV8_1X32) |
251 | fmt->code = V4L2_MBUS_FMT_AYUV8_1X32; | 251 | fmt->code = MEDIA_BUS_FMT_AYUV8_1X32; |
252 | 252 | ||
253 | fmt->width = clamp(fmt->width, UDS_MIN_SIZE, UDS_MAX_SIZE); | 253 | fmt->width = clamp(fmt->width, UDS_MIN_SIZE, UDS_MAX_SIZE); |
254 | fmt->height = clamp(fmt->height, UDS_MIN_SIZE, UDS_MAX_SIZE); | 254 | fmt->height = clamp(fmt->height, UDS_MIN_SIZE, UDS_MAX_SIZE); |
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 915a20eb003e..d91f19a9e1c1 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c | |||
@@ -48,85 +48,85 @@ | |||
48 | */ | 48 | */ |
49 | 49 | ||
50 | static const struct vsp1_format_info vsp1_video_formats[] = { | 50 | static const struct vsp1_format_info vsp1_video_formats[] = { |
51 | { V4L2_PIX_FMT_RGB332, V4L2_MBUS_FMT_ARGB8888_1X32, | 51 | { V4L2_PIX_FMT_RGB332, MEDIA_BUS_FMT_ARGB8888_1X32, |
52 | VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 52 | VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
53 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 53 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
54 | 1, { 8, 0, 0 }, false, false, 1, 1, false }, | 54 | 1, { 8, 0, 0 }, false, false, 1, 1, false }, |
55 | { V4L2_PIX_FMT_ARGB444, V4L2_MBUS_FMT_ARGB8888_1X32, | 55 | { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_FMT_ARGB8888_1X32, |
56 | VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 56 | VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
57 | VI6_RPF_DSWAP_P_WDS, | 57 | VI6_RPF_DSWAP_P_WDS, |
58 | 1, { 16, 0, 0 }, false, false, 1, 1, true }, | 58 | 1, { 16, 0, 0 }, false, false, 1, 1, true }, |
59 | { V4L2_PIX_FMT_XRGB444, V4L2_MBUS_FMT_ARGB8888_1X32, | 59 | { V4L2_PIX_FMT_XRGB444, MEDIA_BUS_FMT_ARGB8888_1X32, |
60 | VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 60 | VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
61 | VI6_RPF_DSWAP_P_WDS, | 61 | VI6_RPF_DSWAP_P_WDS, |
62 | 1, { 16, 0, 0 }, false, false, 1, 1, true }, | 62 | 1, { 16, 0, 0 }, false, false, 1, 1, true }, |
63 | { V4L2_PIX_FMT_ARGB555, V4L2_MBUS_FMT_ARGB8888_1X32, | 63 | { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_FMT_ARGB8888_1X32, |
64 | VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 64 | VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
65 | VI6_RPF_DSWAP_P_WDS, | 65 | VI6_RPF_DSWAP_P_WDS, |
66 | 1, { 16, 0, 0 }, false, false, 1, 1, true }, | 66 | 1, { 16, 0, 0 }, false, false, 1, 1, true }, |
67 | { V4L2_PIX_FMT_XRGB555, V4L2_MBUS_FMT_ARGB8888_1X32, | 67 | { V4L2_PIX_FMT_XRGB555, MEDIA_BUS_FMT_ARGB8888_1X32, |
68 | VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 68 | VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
69 | VI6_RPF_DSWAP_P_WDS, | 69 | VI6_RPF_DSWAP_P_WDS, |
70 | 1, { 16, 0, 0 }, false, false, 1, 1, false }, | 70 | 1, { 16, 0, 0 }, false, false, 1, 1, false }, |
71 | { V4L2_PIX_FMT_RGB565, V4L2_MBUS_FMT_ARGB8888_1X32, | 71 | { V4L2_PIX_FMT_RGB565, MEDIA_BUS_FMT_ARGB8888_1X32, |
72 | VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 72 | VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
73 | VI6_RPF_DSWAP_P_WDS, | 73 | VI6_RPF_DSWAP_P_WDS, |
74 | 1, { 16, 0, 0 }, false, false, 1, 1, false }, | 74 | 1, { 16, 0, 0 }, false, false, 1, 1, false }, |
75 | { V4L2_PIX_FMT_BGR24, V4L2_MBUS_FMT_ARGB8888_1X32, | 75 | { V4L2_PIX_FMT_BGR24, MEDIA_BUS_FMT_ARGB8888_1X32, |
76 | VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 76 | VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
77 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 77 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
78 | 1, { 24, 0, 0 }, false, false, 1, 1, false }, | 78 | 1, { 24, 0, 0 }, false, false, 1, 1, false }, |
79 | { V4L2_PIX_FMT_RGB24, V4L2_MBUS_FMT_ARGB8888_1X32, | 79 | { V4L2_PIX_FMT_RGB24, MEDIA_BUS_FMT_ARGB8888_1X32, |
80 | VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 80 | VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
81 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 81 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
82 | 1, { 24, 0, 0 }, false, false, 1, 1, false }, | 82 | 1, { 24, 0, 0 }, false, false, 1, 1, false }, |
83 | { V4L2_PIX_FMT_ABGR32, V4L2_MBUS_FMT_ARGB8888_1X32, | 83 | { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_FMT_ARGB8888_1X32, |
84 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, | 84 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, |
85 | 1, { 32, 0, 0 }, false, false, 1, 1, true }, | 85 | 1, { 32, 0, 0 }, false, false, 1, 1, true }, |
86 | { V4L2_PIX_FMT_XBGR32, V4L2_MBUS_FMT_ARGB8888_1X32, | 86 | { V4L2_PIX_FMT_XBGR32, MEDIA_BUS_FMT_ARGB8888_1X32, |
87 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, | 87 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, |
88 | 1, { 32, 0, 0 }, false, false, 1, 1, false }, | 88 | 1, { 32, 0, 0 }, false, false, 1, 1, false }, |
89 | { V4L2_PIX_FMT_ARGB32, V4L2_MBUS_FMT_ARGB8888_1X32, | 89 | { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_FMT_ARGB8888_1X32, |
90 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 90 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
91 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 91 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
92 | 1, { 32, 0, 0 }, false, false, 1, 1, true }, | 92 | 1, { 32, 0, 0 }, false, false, 1, 1, true }, |
93 | { V4L2_PIX_FMT_XRGB32, V4L2_MBUS_FMT_ARGB8888_1X32, | 93 | { V4L2_PIX_FMT_XRGB32, MEDIA_BUS_FMT_ARGB8888_1X32, |
94 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 94 | VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
95 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 95 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
96 | 1, { 32, 0, 0 }, false, false, 1, 1, false }, | 96 | 1, { 32, 0, 0 }, false, false, 1, 1, false }, |
97 | { V4L2_PIX_FMT_UYVY, V4L2_MBUS_FMT_AYUV8_1X32, | 97 | { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32, |
98 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 98 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
99 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 99 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
100 | 1, { 16, 0, 0 }, false, false, 2, 1, false }, | 100 | 1, { 16, 0, 0 }, false, false, 2, 1, false }, |
101 | { V4L2_PIX_FMT_VYUY, V4L2_MBUS_FMT_AYUV8_1X32, | 101 | { V4L2_PIX_FMT_VYUY, MEDIA_BUS_FMT_AYUV8_1X32, |
102 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 102 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
103 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 103 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
104 | 1, { 16, 0, 0 }, false, true, 2, 1, false }, | 104 | 1, { 16, 0, 0 }, false, true, 2, 1, false }, |
105 | { V4L2_PIX_FMT_YUYV, V4L2_MBUS_FMT_AYUV8_1X32, | 105 | { V4L2_PIX_FMT_YUYV, MEDIA_BUS_FMT_AYUV8_1X32, |
106 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 106 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
107 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 107 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
108 | 1, { 16, 0, 0 }, true, false, 2, 1, false }, | 108 | 1, { 16, 0, 0 }, true, false, 2, 1, false }, |
109 | { V4L2_PIX_FMT_YVYU, V4L2_MBUS_FMT_AYUV8_1X32, | 109 | { V4L2_PIX_FMT_YVYU, MEDIA_BUS_FMT_AYUV8_1X32, |
110 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 110 | VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
111 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 111 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
112 | 1, { 16, 0, 0 }, true, true, 2, 1, false }, | 112 | 1, { 16, 0, 0 }, true, true, 2, 1, false }, |
113 | { V4L2_PIX_FMT_NV12M, V4L2_MBUS_FMT_AYUV8_1X32, | 113 | { V4L2_PIX_FMT_NV12M, MEDIA_BUS_FMT_AYUV8_1X32, |
114 | VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 114 | VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
115 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 115 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
116 | 2, { 8, 16, 0 }, false, false, 2, 2, false }, | 116 | 2, { 8, 16, 0 }, false, false, 2, 2, false }, |
117 | { V4L2_PIX_FMT_NV21M, V4L2_MBUS_FMT_AYUV8_1X32, | 117 | { V4L2_PIX_FMT_NV21M, MEDIA_BUS_FMT_AYUV8_1X32, |
118 | VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 118 | VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
119 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 119 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
120 | 2, { 8, 16, 0 }, false, true, 2, 2, false }, | 120 | 2, { 8, 16, 0 }, false, true, 2, 2, false }, |
121 | { V4L2_PIX_FMT_NV16M, V4L2_MBUS_FMT_AYUV8_1X32, | 121 | { V4L2_PIX_FMT_NV16M, MEDIA_BUS_FMT_AYUV8_1X32, |
122 | VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 122 | VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
123 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 123 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
124 | 2, { 8, 16, 0 }, false, false, 2, 1, false }, | 124 | 2, { 8, 16, 0 }, false, false, 2, 1, false }, |
125 | { V4L2_PIX_FMT_NV61M, V4L2_MBUS_FMT_AYUV8_1X32, | 125 | { V4L2_PIX_FMT_NV61M, MEDIA_BUS_FMT_AYUV8_1X32, |
126 | VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 126 | VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
127 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 127 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
128 | 2, { 8, 16, 0 }, false, true, 2, 1, false }, | 128 | 2, { 8, 16, 0 }, false, true, 2, 1, false }, |
129 | { V4L2_PIX_FMT_YUV420M, V4L2_MBUS_FMT_AYUV8_1X32, | 129 | { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_FMT_AYUV8_1X32, |
130 | VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | | 130 | VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | |
131 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, | 131 | VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, |
132 | 3, { 8, 8, 8 }, false, false, 2, 2, false }, | 132 | 3, { 8, 8, 8 }, false, false, 2, 2, false }, |
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c index 9cf6731fb816..284f789265e0 100644 --- a/drivers/media/radio/radio-wl1273.c +++ b/drivers/media/radio/radio-wl1273.c | |||
@@ -1279,10 +1279,12 @@ static int wl1273_fm_vidioc_querycap(struct file *file, void *priv, | |||
1279 | strlcpy(capability->bus_info, radio->bus_type, | 1279 | strlcpy(capability->bus_info, radio->bus_type, |
1280 | sizeof(capability->bus_info)); | 1280 | sizeof(capability->bus_info)); |
1281 | 1281 | ||
1282 | capability->capabilities = V4L2_CAP_HW_FREQ_SEEK | | 1282 | capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | |
1283 | V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_AUDIO | | 1283 | V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_AUDIO | |
1284 | V4L2_CAP_RDS_CAPTURE | V4L2_CAP_MODULATOR | | 1284 | V4L2_CAP_RDS_CAPTURE | V4L2_CAP_MODULATOR | |
1285 | V4L2_CAP_RDS_OUTPUT; | 1285 | V4L2_CAP_RDS_OUTPUT; |
1286 | capability->capabilities = capability->device_caps | | ||
1287 | V4L2_CAP_DEVICE_CAPS; | ||
1286 | 1288 | ||
1287 | return 0; | 1289 | return 0; |
1288 | } | 1290 | } |
diff --git a/drivers/media/radio/si4713/radio-platform-si4713.c b/drivers/media/radio/si4713/radio-platform-si4713.c index a47502a330f0..2de5439b9c79 100644 --- a/drivers/media/radio/si4713/radio-platform-si4713.c +++ b/drivers/media/radio/si4713/radio-platform-si4713.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <media/v4l2-fh.h> | 34 | #include <media/v4l2-fh.h> |
35 | #include <media/v4l2-ctrls.h> | 35 | #include <media/v4l2-ctrls.h> |
36 | #include <media/v4l2-event.h> | 36 | #include <media/v4l2-event.h> |
37 | #include <media/radio-si4713.h> | 37 | #include "si4713.h" |
38 | 38 | ||
39 | /* module parameters */ | 39 | /* module parameters */ |
40 | static int radio_nr = -1; /* radio device minor (-1 ==> auto assign) */ | 40 | static int radio_nr = -1; /* radio device minor (-1 ==> auto assign) */ |
@@ -153,7 +153,6 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev) | |||
153 | { | 153 | { |
154 | struct radio_si4713_platform_data *pdata = pdev->dev.platform_data; | 154 | struct radio_si4713_platform_data *pdata = pdev->dev.platform_data; |
155 | struct radio_si4713_device *rsdev; | 155 | struct radio_si4713_device *rsdev; |
156 | struct i2c_adapter *adapter; | ||
157 | struct v4l2_subdev *sd; | 156 | struct v4l2_subdev *sd; |
158 | int rval = 0; | 157 | int rval = 0; |
159 | 158 | ||
@@ -177,20 +176,11 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev) | |||
177 | goto exit; | 176 | goto exit; |
178 | } | 177 | } |
179 | 178 | ||
180 | adapter = i2c_get_adapter(pdata->i2c_bus); | 179 | sd = i2c_get_clientdata(pdata->subdev); |
181 | if (!adapter) { | 180 | rval = v4l2_device_register_subdev(&rsdev->v4l2_dev, sd); |
182 | dev_err(&pdev->dev, "Cannot get i2c adapter %d\n", | 181 | if (rval) { |
183 | pdata->i2c_bus); | ||
184 | rval = -ENODEV; | ||
185 | goto unregister_v4l2_dev; | ||
186 | } | ||
187 | |||
188 | sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter, | ||
189 | pdata->subdev_board_info, NULL); | ||
190 | if (!sd) { | ||
191 | dev_err(&pdev->dev, "Cannot get v4l2 subdevice\n"); | 182 | dev_err(&pdev->dev, "Cannot get v4l2 subdevice\n"); |
192 | rval = -ENODEV; | 183 | goto unregister_v4l2_dev; |
193 | goto put_adapter; | ||
194 | } | 184 | } |
195 | 185 | ||
196 | rsdev->radio_dev = radio_si4713_vdev_template; | 186 | rsdev->radio_dev = radio_si4713_vdev_template; |
@@ -202,14 +192,12 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev) | |||
202 | if (video_register_device(&rsdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) { | 192 | if (video_register_device(&rsdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) { |
203 | dev_err(&pdev->dev, "Could not register video device.\n"); | 193 | dev_err(&pdev->dev, "Could not register video device.\n"); |
204 | rval = -EIO; | 194 | rval = -EIO; |
205 | goto put_adapter; | 195 | goto unregister_v4l2_dev; |
206 | } | 196 | } |
207 | dev_info(&pdev->dev, "New device successfully probed\n"); | 197 | dev_info(&pdev->dev, "New device successfully probed\n"); |
208 | 198 | ||
209 | goto exit; | 199 | goto exit; |
210 | 200 | ||
211 | put_adapter: | ||
212 | i2c_put_adapter(adapter); | ||
213 | unregister_v4l2_dev: | 201 | unregister_v4l2_dev: |
214 | v4l2_device_unregister(&rsdev->v4l2_dev); | 202 | v4l2_device_unregister(&rsdev->v4l2_dev); |
215 | exit: | 203 | exit: |
@@ -220,14 +208,10 @@ exit: | |||
220 | static int radio_si4713_pdriver_remove(struct platform_device *pdev) | 208 | static int radio_si4713_pdriver_remove(struct platform_device *pdev) |
221 | { | 209 | { |
222 | struct v4l2_device *v4l2_dev = platform_get_drvdata(pdev); | 210 | struct v4l2_device *v4l2_dev = platform_get_drvdata(pdev); |
223 | struct v4l2_subdev *sd = list_entry(v4l2_dev->subdevs.next, | ||
224 | struct v4l2_subdev, list); | ||
225 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
226 | struct radio_si4713_device *rsdev; | 211 | struct radio_si4713_device *rsdev; |
227 | 212 | ||
228 | rsdev = container_of(v4l2_dev, struct radio_si4713_device, v4l2_dev); | 213 | rsdev = container_of(v4l2_dev, struct radio_si4713_device, v4l2_dev); |
229 | video_unregister_device(&rsdev->radio_dev); | 214 | video_unregister_device(&rsdev->radio_dev); |
230 | i2c_put_adapter(client->adapter); | ||
231 | v4l2_device_unregister(&rsdev->v4l2_dev); | 215 | v4l2_device_unregister(&rsdev->v4l2_dev); |
232 | 216 | ||
233 | return 0; | 217 | return 0; |
diff --git a/drivers/media/radio/si4713/si4713.c b/drivers/media/radio/si4713/si4713.c index b5765557ea3d..c90004dac170 100644 --- a/drivers/media/radio/si4713/si4713.c +++ b/drivers/media/radio/si4713/si4713.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/completion.h> | 24 | #include <linux/completion.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/err.h> | ||
26 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
27 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
28 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
@@ -366,16 +367,25 @@ static int si4713_powerup(struct si4713_device *sdev) | |||
366 | if (sdev->power_state) | 367 | if (sdev->power_state) |
367 | return 0; | 368 | return 0; |
368 | 369 | ||
369 | if (sdev->supplies) { | 370 | if (sdev->vdd) { |
370 | err = regulator_bulk_enable(sdev->supplies, sdev->supply_data); | 371 | err = regulator_enable(sdev->vdd); |
371 | if (err) { | 372 | if (err) { |
372 | v4l2_err(&sdev->sd, "Failed to enable supplies: %d\n", err); | 373 | v4l2_err(&sdev->sd, "Failed to enable vdd: %d\n", err); |
373 | return err; | 374 | return err; |
374 | } | 375 | } |
375 | } | 376 | } |
376 | if (gpio_is_valid(sdev->gpio_reset)) { | 377 | |
378 | if (sdev->vio) { | ||
379 | err = regulator_enable(sdev->vio); | ||
380 | if (err) { | ||
381 | v4l2_err(&sdev->sd, "Failed to enable vio: %d\n", err); | ||
382 | return err; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | if (!IS_ERR(sdev->gpio_reset)) { | ||
377 | udelay(50); | 387 | udelay(50); |
378 | gpio_set_value(sdev->gpio_reset, 1); | 388 | gpiod_set_value(sdev->gpio_reset, 1); |
379 | } | 389 | } |
380 | 390 | ||
381 | if (client->irq) | 391 | if (client->irq) |
@@ -397,13 +407,20 @@ static int si4713_powerup(struct si4713_device *sdev) | |||
397 | SI4713_STC_INT | SI4713_CTS); | 407 | SI4713_STC_INT | SI4713_CTS); |
398 | return err; | 408 | return err; |
399 | } | 409 | } |
400 | if (gpio_is_valid(sdev->gpio_reset)) | 410 | if (!IS_ERR(sdev->gpio_reset)) |
401 | gpio_set_value(sdev->gpio_reset, 0); | 411 | gpiod_set_value(sdev->gpio_reset, 0); |
402 | if (sdev->supplies) { | 412 | |
403 | err = regulator_bulk_disable(sdev->supplies, sdev->supply_data); | 413 | |
414 | if (sdev->vdd) { | ||
415 | err = regulator_disable(sdev->vdd); | ||
404 | if (err) | 416 | if (err) |
405 | v4l2_err(&sdev->sd, | 417 | v4l2_err(&sdev->sd, "Failed to disable vdd: %d\n", err); |
406 | "Failed to disable supplies: %d\n", err); | 418 | } |
419 | |||
420 | if (sdev->vio) { | ||
421 | err = regulator_disable(sdev->vio); | ||
422 | if (err) | ||
423 | v4l2_err(&sdev->sd, "Failed to disable vio: %d\n", err); | ||
407 | } | 424 | } |
408 | 425 | ||
409 | return err; | 426 | return err; |
@@ -430,14 +447,23 @@ static int si4713_powerdown(struct si4713_device *sdev) | |||
430 | v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", | 447 | v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", |
431 | resp[0]); | 448 | resp[0]); |
432 | v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); | 449 | v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); |
433 | if (gpio_is_valid(sdev->gpio_reset)) | 450 | if (!IS_ERR(sdev->gpio_reset)) |
434 | gpio_set_value(sdev->gpio_reset, 0); | 451 | gpiod_set_value(sdev->gpio_reset, 0); |
435 | if (sdev->supplies) { | 452 | |
436 | err = regulator_bulk_disable(sdev->supplies, | 453 | if (sdev->vdd) { |
437 | sdev->supply_data); | 454 | err = regulator_disable(sdev->vdd); |
438 | if (err) | 455 | if (err) { |
439 | v4l2_err(&sdev->sd, | 456 | v4l2_err(&sdev->sd, |
440 | "Failed to disable supplies: %d\n", err); | 457 | "Failed to disable vdd: %d\n", err); |
458 | } | ||
459 | } | ||
460 | |||
461 | if (sdev->vio) { | ||
462 | err = regulator_disable(sdev->vio); | ||
463 | if (err) { | ||
464 | v4l2_err(&sdev->sd, | ||
465 | "Failed to disable vio: %d\n", err); | ||
466 | } | ||
441 | } | 467 | } |
442 | sdev->power_state = POWER_OFF; | 468 | sdev->power_state = POWER_OFF; |
443 | } | 469 | } |
@@ -1420,38 +1446,51 @@ static int si4713_probe(struct i2c_client *client, | |||
1420 | const struct i2c_device_id *id) | 1446 | const struct i2c_device_id *id) |
1421 | { | 1447 | { |
1422 | struct si4713_device *sdev; | 1448 | struct si4713_device *sdev; |
1423 | struct si4713_platform_data *pdata = client->dev.platform_data; | ||
1424 | struct v4l2_ctrl_handler *hdl; | 1449 | struct v4l2_ctrl_handler *hdl; |
1425 | int rval, i; | 1450 | struct si4713_platform_data *pdata = client->dev.platform_data; |
1451 | struct device_node *np = client->dev.of_node; | ||
1452 | struct radio_si4713_platform_data si4713_pdev_pdata; | ||
1453 | struct platform_device *si4713_pdev; | ||
1454 | int rval; | ||
1426 | 1455 | ||
1427 | sdev = kzalloc(sizeof(*sdev), GFP_KERNEL); | 1456 | sdev = devm_kzalloc(&client->dev, sizeof(*sdev), GFP_KERNEL); |
1428 | if (!sdev) { | 1457 | if (!sdev) { |
1429 | dev_err(&client->dev, "Failed to alloc video device.\n"); | 1458 | dev_err(&client->dev, "Failed to alloc video device.\n"); |
1430 | rval = -ENOMEM; | 1459 | rval = -ENOMEM; |
1431 | goto exit; | 1460 | goto exit; |
1432 | } | 1461 | } |
1433 | 1462 | ||
1434 | sdev->gpio_reset = -1; | 1463 | sdev->gpio_reset = devm_gpiod_get(&client->dev, "reset"); |
1435 | if (pdata && gpio_is_valid(pdata->gpio_reset)) { | 1464 | if (!IS_ERR(sdev->gpio_reset)) { |
1436 | rval = gpio_request(pdata->gpio_reset, "si4713 reset"); | 1465 | gpiod_direction_output(sdev->gpio_reset, 0); |
1437 | if (rval) { | 1466 | } else if (PTR_ERR(sdev->gpio_reset) == -ENOENT) { |
1438 | dev_err(&client->dev, | 1467 | dev_dbg(&client->dev, "No reset GPIO assigned\n"); |
1439 | "Failed to request gpio: %d\n", rval); | 1468 | } else if (PTR_ERR(sdev->gpio_reset) == -ENOSYS) { |
1440 | goto free_sdev; | 1469 | dev_dbg(&client->dev, "No reset GPIO support\n"); |
1441 | } | 1470 | } else { |
1442 | sdev->gpio_reset = pdata->gpio_reset; | 1471 | rval = PTR_ERR(sdev->gpio_reset); |
1443 | gpio_direction_output(sdev->gpio_reset, 0); | 1472 | dev_err(&client->dev, "Failed to request gpio: %d\n", rval); |
1444 | sdev->supplies = pdata->supplies; | 1473 | goto exit; |
1445 | } | 1474 | } |
1446 | 1475 | ||
1447 | for (i = 0; i < sdev->supplies; i++) | 1476 | sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd"); |
1448 | sdev->supply_data[i].supply = pdata->supply_names[i]; | 1477 | if (IS_ERR(sdev->vdd)) { |
1478 | rval = PTR_ERR(sdev->vdd); | ||
1479 | if (rval == -EPROBE_DEFER) | ||
1480 | goto exit; | ||
1449 | 1481 | ||
1450 | rval = regulator_bulk_get(&client->dev, sdev->supplies, | 1482 | dev_dbg(&client->dev, "no vdd regulator found: %d\n", rval); |
1451 | sdev->supply_data); | 1483 | sdev->vdd = NULL; |
1452 | if (rval) { | 1484 | } |
1453 | dev_err(&client->dev, "Cannot get regulators: %d\n", rval); | 1485 | |
1454 | goto free_gpio; | 1486 | sdev->vio = devm_regulator_get_optional(&client->dev, "vio"); |
1487 | if (IS_ERR(sdev->vio)) { | ||
1488 | rval = PTR_ERR(sdev->vio); | ||
1489 | if (rval == -EPROBE_DEFER) | ||
1490 | goto exit; | ||
1491 | |||
1492 | dev_dbg(&client->dev, "no vio regulator found: %d\n", rval); | ||
1493 | sdev->vio = NULL; | ||
1455 | } | 1494 | } |
1456 | 1495 | ||
1457 | v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops); | 1496 | v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops); |
@@ -1554,12 +1593,12 @@ static int si4713_probe(struct i2c_client *client, | |||
1554 | sdev->sd.ctrl_handler = hdl; | 1593 | sdev->sd.ctrl_handler = hdl; |
1555 | 1594 | ||
1556 | if (client->irq) { | 1595 | if (client->irq) { |
1557 | rval = request_irq(client->irq, | 1596 | rval = devm_request_irq(&client->dev, client->irq, |
1558 | si4713_handler, IRQF_TRIGGER_FALLING, | 1597 | si4713_handler, IRQF_TRIGGER_FALLING, |
1559 | client->name, sdev); | 1598 | client->name, sdev); |
1560 | if (rval < 0) { | 1599 | if (rval < 0) { |
1561 | v4l2_err(&sdev->sd, "Could not request IRQ\n"); | 1600 | v4l2_err(&sdev->sd, "Could not request IRQ\n"); |
1562 | goto put_reg; | 1601 | goto free_ctrls; |
1563 | } | 1602 | } |
1564 | v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n"); | 1603 | v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n"); |
1565 | } else { | 1604 | } else { |
@@ -1569,23 +1608,35 @@ static int si4713_probe(struct i2c_client *client, | |||
1569 | rval = si4713_initialize(sdev); | 1608 | rval = si4713_initialize(sdev); |
1570 | if (rval < 0) { | 1609 | if (rval < 0) { |
1571 | v4l2_err(&sdev->sd, "Failed to probe device information.\n"); | 1610 | v4l2_err(&sdev->sd, "Failed to probe device information.\n"); |
1572 | goto free_irq; | 1611 | goto free_ctrls; |
1573 | } | 1612 | } |
1574 | 1613 | ||
1614 | if (!np && (!pdata || !pdata->is_platform_device)) | ||
1615 | return 0; | ||
1616 | |||
1617 | si4713_pdev = platform_device_alloc("radio-si4713", -1); | ||
1618 | if (!si4713_pdev) | ||
1619 | goto put_main_pdev; | ||
1620 | |||
1621 | si4713_pdev_pdata.subdev = client; | ||
1622 | rval = platform_device_add_data(si4713_pdev, &si4713_pdev_pdata, | ||
1623 | sizeof(si4713_pdev_pdata)); | ||
1624 | if (rval) | ||
1625 | goto put_main_pdev; | ||
1626 | |||
1627 | rval = platform_device_add(si4713_pdev); | ||
1628 | if (rval) | ||
1629 | goto put_main_pdev; | ||
1630 | |||
1631 | sdev->pd = si4713_pdev; | ||
1632 | |||
1575 | return 0; | 1633 | return 0; |
1576 | 1634 | ||
1577 | free_irq: | 1635 | put_main_pdev: |
1578 | if (client->irq) | 1636 | platform_device_put(si4713_pdev); |
1579 | free_irq(client->irq, sdev); | 1637 | v4l2_device_unregister_subdev(&sdev->sd); |
1580 | free_ctrls: | 1638 | free_ctrls: |
1581 | v4l2_ctrl_handler_free(hdl); | 1639 | v4l2_ctrl_handler_free(hdl); |
1582 | put_reg: | ||
1583 | regulator_bulk_free(sdev->supplies, sdev->supply_data); | ||
1584 | free_gpio: | ||
1585 | if (gpio_is_valid(sdev->gpio_reset)) | ||
1586 | gpio_free(sdev->gpio_reset); | ||
1587 | free_sdev: | ||
1588 | kfree(sdev); | ||
1589 | exit: | 1640 | exit: |
1590 | return rval; | 1641 | return rval; |
1591 | } | 1642 | } |
@@ -1596,18 +1647,13 @@ static int si4713_remove(struct i2c_client *client) | |||
1596 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 1647 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
1597 | struct si4713_device *sdev = to_si4713_device(sd); | 1648 | struct si4713_device *sdev = to_si4713_device(sd); |
1598 | 1649 | ||
1650 | platform_device_unregister(sdev->pd); | ||
1651 | |||
1599 | if (sdev->power_state) | 1652 | if (sdev->power_state) |
1600 | si4713_set_power_state(sdev, POWER_DOWN); | 1653 | si4713_set_power_state(sdev, POWER_DOWN); |
1601 | 1654 | ||
1602 | if (client->irq > 0) | ||
1603 | free_irq(client->irq, sdev); | ||
1604 | |||
1605 | v4l2_device_unregister_subdev(sd); | 1655 | v4l2_device_unregister_subdev(sd); |
1606 | v4l2_ctrl_handler_free(sd->ctrl_handler); | 1656 | v4l2_ctrl_handler_free(sd->ctrl_handler); |
1607 | regulator_bulk_free(sdev->supplies, sdev->supply_data); | ||
1608 | if (gpio_is_valid(sdev->gpio_reset)) | ||
1609 | gpio_free(sdev->gpio_reset); | ||
1610 | kfree(sdev); | ||
1611 | 1657 | ||
1612 | return 0; | 1658 | return 0; |
1613 | } | 1659 | } |
diff --git a/drivers/media/radio/si4713/si4713.h b/drivers/media/radio/si4713/si4713.h index ed700e387605..8a376e142188 100644 --- a/drivers/media/radio/si4713/si4713.h +++ b/drivers/media/radio/si4713/si4713.h | |||
@@ -15,7 +15,9 @@ | |||
15 | #ifndef SI4713_I2C_H | 15 | #ifndef SI4713_I2C_H |
16 | #define SI4713_I2C_H | 16 | #define SI4713_I2C_H |
17 | 17 | ||
18 | #include <linux/platform_device.h> | ||
18 | #include <linux/regulator/consumer.h> | 19 | #include <linux/regulator/consumer.h> |
20 | #include <linux/gpio/consumer.h> | ||
19 | #include <media/v4l2-subdev.h> | 21 | #include <media/v4l2-subdev.h> |
20 | #include <media/v4l2-ctrls.h> | 22 | #include <media/v4l2-ctrls.h> |
21 | #include <media/si4713.h> | 23 | #include <media/si4713.h> |
@@ -190,8 +192,6 @@ | |||
190 | #define MIN_ACOMP_THRESHOLD (-40) | 192 | #define MIN_ACOMP_THRESHOLD (-40) |
191 | #define MAX_ACOMP_GAIN 20 | 193 | #define MAX_ACOMP_GAIN 20 |
192 | 194 | ||
193 | #define SI4713_NUM_SUPPLIES 2 | ||
194 | |||
195 | /* | 195 | /* |
196 | * si4713_device - private data | 196 | * si4713_device - private data |
197 | */ | 197 | */ |
@@ -236,9 +236,10 @@ struct si4713_device { | |||
236 | struct v4l2_ctrl *tune_ant_cap; | 236 | struct v4l2_ctrl *tune_ant_cap; |
237 | }; | 237 | }; |
238 | struct completion work; | 238 | struct completion work; |
239 | unsigned supplies; | 239 | struct regulator *vdd; |
240 | struct regulator_bulk_data supply_data[SI4713_NUM_SUPPLIES]; | 240 | struct regulator *vio; |
241 | int gpio_reset; | 241 | struct gpio_desc *gpio_reset; |
242 | struct platform_device *pd; | ||
242 | u32 power_state; | 243 | u32 power_state; |
243 | u32 rds_enabled; | 244 | u32 rds_enabled; |
244 | u32 frequency; | 245 | u32 frequency; |
@@ -246,4 +247,8 @@ struct si4713_device { | |||
246 | u32 stereo; | 247 | u32 stereo; |
247 | u32 tune_rnl; | 248 | u32 tune_rnl; |
248 | }; | 249 | }; |
250 | |||
251 | struct radio_si4713_platform_data { | ||
252 | struct i2c_client *subdev; | ||
253 | }; | ||
249 | #endif /* ifndef SI4713_I2C_H */ | 254 | #endif /* ifndef SI4713_I2C_H */ |
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index b55012c11842..a5bd3f674bbd 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c | |||
@@ -198,10 +198,12 @@ static int fm_v4l2_vidioc_querycap(struct file *file, void *priv, | |||
198 | strlcpy(capability->card, FM_DRV_CARD_SHORT_NAME, | 198 | strlcpy(capability->card, FM_DRV_CARD_SHORT_NAME, |
199 | sizeof(capability->card)); | 199 | sizeof(capability->card)); |
200 | sprintf(capability->bus_info, "UART"); | 200 | sprintf(capability->bus_info, "UART"); |
201 | capability->capabilities = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_TUNER | | 201 | capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_TUNER | |
202 | V4L2_CAP_RADIO | V4L2_CAP_MODULATOR | | 202 | V4L2_CAP_RADIO | V4L2_CAP_MODULATOR | |
203 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | | 203 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | |
204 | V4L2_CAP_RDS_CAPTURE; | 204 | V4L2_CAP_RDS_CAPTURE; |
205 | capability->capabilities = capability->device_caps | | ||
206 | V4L2_CAP_DEVICE_CAPS; | ||
205 | 207 | ||
206 | return 0; | 208 | return 0; |
207 | } | 209 | } |
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig index 8ce08107a69d..ddfab256b9a5 100644 --- a/drivers/media/rc/Kconfig +++ b/drivers/media/rc/Kconfig | |||
@@ -223,6 +223,17 @@ config IR_FINTEK | |||
223 | To compile this driver as a module, choose M here: the | 223 | To compile this driver as a module, choose M here: the |
224 | module will be called fintek-cir. | 224 | module will be called fintek-cir. |
225 | 225 | ||
226 | config IR_MESON | ||
227 | tristate "Amlogic Meson IR remote receiver" | ||
228 | depends on RC_CORE | ||
229 | depends on ARCH_MESON || COMPILE_TEST | ||
230 | ---help--- | ||
231 | Say Y if you want to use the IR remote receiver available | ||
232 | on Amlogic Meson SoCs. | ||
233 | |||
234 | To compile this driver as a module, choose M here: the | ||
235 | module will be called meson-ir. | ||
236 | |||
226 | config IR_NUVOTON | 237 | config IR_NUVOTON |
227 | tristate "Nuvoton w836x7hg Consumer Infrared Transceiver" | 238 | tristate "Nuvoton w836x7hg Consumer Infrared Transceiver" |
228 | depends on PNP | 239 | depends on PNP |
@@ -277,6 +288,21 @@ config IR_WINBOND_CIR | |||
277 | To compile this driver as a module, choose M here: the module will | 288 | To compile this driver as a module, choose M here: the module will |
278 | be called winbond_cir. | 289 | be called winbond_cir. |
279 | 290 | ||
291 | config IR_IGORPLUGUSB | ||
292 | tristate "IgorPlug-USB IR Receiver" | ||
293 | depends on USB_ARCH_HAS_HCD | ||
294 | depends on RC_CORE | ||
295 | select USB | ||
296 | ---help--- | ||
297 | Say Y here if you want to use the IgorPlug-USB IR Receiver by | ||
298 | Igor Cesko. This device is included on the Fit-PC2. | ||
299 | |||
300 | Note that this device can only record bursts of 36 IR pulses and | ||
301 | spaces, which is not enough for the NEC, Sanyo and RC-6 protocol. | ||
302 | |||
303 | To compile this driver as a module, choose M here: the module will | ||
304 | be called igorplugusb. | ||
305 | |||
280 | config IR_IGUANA | 306 | config IR_IGUANA |
281 | tristate "IguanaWorks USB IR Transceiver" | 307 | tristate "IguanaWorks USB IR Transceiver" |
282 | depends on USB_ARCH_HAS_HCD | 308 | depends on USB_ARCH_HAS_HCD |
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile index 0989f940e9cf..379a5c0f1379 100644 --- a/drivers/media/rc/Makefile +++ b/drivers/media/rc/Makefile | |||
@@ -22,6 +22,7 @@ obj-$(CONFIG_IR_IMON) += imon.o | |||
22 | obj-$(CONFIG_IR_ITE_CIR) += ite-cir.o | 22 | obj-$(CONFIG_IR_ITE_CIR) += ite-cir.o |
23 | obj-$(CONFIG_IR_MCEUSB) += mceusb.o | 23 | obj-$(CONFIG_IR_MCEUSB) += mceusb.o |
24 | obj-$(CONFIG_IR_FINTEK) += fintek-cir.o | 24 | obj-$(CONFIG_IR_FINTEK) += fintek-cir.o |
25 | obj-$(CONFIG_IR_MESON) += meson-ir.o | ||
25 | obj-$(CONFIG_IR_NUVOTON) += nuvoton-cir.o | 26 | obj-$(CONFIG_IR_NUVOTON) += nuvoton-cir.o |
26 | obj-$(CONFIG_IR_ENE) += ene_ir.o | 27 | obj-$(CONFIG_IR_ENE) += ene_ir.o |
27 | obj-$(CONFIG_IR_REDRAT3) += redrat3.o | 28 | obj-$(CONFIG_IR_REDRAT3) += redrat3.o |
@@ -30,6 +31,7 @@ obj-$(CONFIG_IR_STREAMZAP) += streamzap.o | |||
30 | obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o | 31 | obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o |
31 | obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o | 32 | obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o |
32 | obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o | 33 | obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o |
34 | obj-$(CONFIG_IR_IGORPLUGUSB) += igorplugusb.o | ||
33 | obj-$(CONFIG_IR_IGUANA) += iguanair.o | 35 | obj-$(CONFIG_IR_IGUANA) += iguanair.o |
34 | obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o | 36 | obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o |
35 | obj-$(CONFIG_RC_ST) += st_rc.o | 37 | obj-$(CONFIG_RC_ST) += st_rc.o |
diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c new file mode 100644 index 000000000000..b36e51576f8e --- /dev/null +++ b/drivers/media/rc/igorplugusb.c | |||
@@ -0,0 +1,261 @@ | |||
1 | /* | ||
2 | * IgorPlug-USB IR Receiver | ||
3 | * | ||
4 | * Copyright (C) 2014 Sean Young <sean@mess.org> | ||
5 | * | ||
6 | * Supports the standard homebrew IgorPlugUSB receiver with Igor's firmware. | ||
7 | * See http://www.cesko.host.sk/IgorPlugUSB/IgorPlug-USB%20(AVR)_eng.htm | ||
8 | * | ||
9 | * Based on the lirc_igorplugusb.c driver: | ||
10 | * Copyright (C) 2004 Jan M. Hochstein | ||
11 | * <hochstein@algo.informatik.tu-darmstadt.de> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | */ | ||
23 | #include <linux/device.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/usb.h> | ||
27 | #include <linux/usb/input.h> | ||
28 | #include <media/rc-core.h> | ||
29 | |||
30 | #define DRIVER_DESC "IgorPlug-USB IR Receiver" | ||
31 | #define DRIVER_NAME "igorplugusb" | ||
32 | |||
33 | #define HEADERLEN 3 | ||
34 | #define BUFLEN 36 | ||
35 | #define MAX_PACKET (HEADERLEN + BUFLEN) | ||
36 | |||
37 | #define SET_INFRABUFFER_EMPTY 1 | ||
38 | #define GET_INFRACODE 2 | ||
39 | |||
40 | |||
41 | struct igorplugusb { | ||
42 | struct rc_dev *rc; | ||
43 | struct device *dev; | ||
44 | |||
45 | struct urb *urb; | ||
46 | struct usb_ctrlrequest request; | ||
47 | |||
48 | struct timer_list timer; | ||
49 | |||
50 | uint8_t buf_in[MAX_PACKET]; | ||
51 | |||
52 | char phys[64]; | ||
53 | }; | ||
54 | |||
55 | static void igorplugusb_cmd(struct igorplugusb *ir, int cmd); | ||
56 | |||
57 | static void igorplugusb_irdata(struct igorplugusb *ir, unsigned len) | ||
58 | { | ||
59 | DEFINE_IR_RAW_EVENT(rawir); | ||
60 | unsigned i, start, overflow; | ||
61 | |||
62 | dev_dbg(ir->dev, "irdata: %*ph (len=%u)", len, ir->buf_in, len); | ||
63 | |||
64 | /* | ||
65 | * If more than 36 pulses and spaces follow each other, the igorplugusb | ||
66 | * overwrites its buffer from the beginning. The overflow value is the | ||
67 | * last offset which was not overwritten. Everything from this offset | ||
68 | * onwards occurred before everything until this offset. | ||
69 | */ | ||
70 | overflow = ir->buf_in[2]; | ||
71 | i = start = overflow + HEADERLEN; | ||
72 | |||
73 | if (start >= len) { | ||
74 | dev_err(ir->dev, "receive overflow invalid: %u", overflow); | ||
75 | } else { | ||
76 | if (overflow > 0) | ||
77 | dev_warn(ir->dev, "receive overflow, at least %u lost", | ||
78 | overflow); | ||
79 | |||
80 | do { | ||
81 | rawir.duration = ir->buf_in[i] * 85333; | ||
82 | rawir.pulse = i & 1; | ||
83 | |||
84 | ir_raw_event_store_with_filter(ir->rc, &rawir); | ||
85 | |||
86 | if (++i == len) | ||
87 | i = HEADERLEN; | ||
88 | } while (i != start); | ||
89 | |||
90 | /* add a trailing space */ | ||
91 | rawir.duration = ir->rc->timeout; | ||
92 | rawir.pulse = false; | ||
93 | ir_raw_event_store_with_filter(ir->rc, &rawir); | ||
94 | |||
95 | ir_raw_event_handle(ir->rc); | ||
96 | } | ||
97 | |||
98 | igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY); | ||
99 | } | ||
100 | |||
101 | static void igorplugusb_callback(struct urb *urb) | ||
102 | { | ||
103 | struct usb_ctrlrequest *req; | ||
104 | struct igorplugusb *ir = urb->context; | ||
105 | |||
106 | req = (struct usb_ctrlrequest *)urb->setup_packet; | ||
107 | |||
108 | switch (urb->status) { | ||
109 | case 0: | ||
110 | if (req->bRequest == GET_INFRACODE && | ||
111 | urb->actual_length > HEADERLEN) | ||
112 | igorplugusb_irdata(ir, urb->actual_length); | ||
113 | else /* request IR */ | ||
114 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(50)); | ||
115 | break; | ||
116 | case -EPROTO: | ||
117 | case -ECONNRESET: | ||
118 | case -ENOENT: | ||
119 | case -ESHUTDOWN: | ||
120 | usb_unlink_urb(urb); | ||
121 | return; | ||
122 | default: | ||
123 | dev_warn(ir->dev, "Error: urb status = %d\n", urb->status); | ||
124 | igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY); | ||
125 | break; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | static void igorplugusb_cmd(struct igorplugusb *ir, int cmd) | ||
130 | { | ||
131 | int ret; | ||
132 | |||
133 | ir->request.bRequest = cmd; | ||
134 | ir->urb->transfer_flags = 0; | ||
135 | ret = usb_submit_urb(ir->urb, GFP_ATOMIC); | ||
136 | if (ret) | ||
137 | dev_err(ir->dev, "submit urb failed: %d", ret); | ||
138 | } | ||
139 | |||
140 | static void igorplugusb_timer(unsigned long data) | ||
141 | { | ||
142 | struct igorplugusb *ir = (struct igorplugusb *)data; | ||
143 | |||
144 | igorplugusb_cmd(ir, GET_INFRACODE); | ||
145 | } | ||
146 | |||
147 | static int igorplugusb_probe(struct usb_interface *intf, | ||
148 | const struct usb_device_id *id) | ||
149 | { | ||
150 | struct usb_device *udev; | ||
151 | struct usb_host_interface *idesc; | ||
152 | struct usb_endpoint_descriptor *ep; | ||
153 | struct igorplugusb *ir; | ||
154 | struct rc_dev *rc; | ||
155 | int ret; | ||
156 | |||
157 | udev = interface_to_usbdev(intf); | ||
158 | idesc = intf->cur_altsetting; | ||
159 | |||
160 | if (idesc->desc.bNumEndpoints != 1) { | ||
161 | dev_err(&intf->dev, "incorrect number of endpoints"); | ||
162 | return -ENODEV; | ||
163 | } | ||
164 | |||
165 | ep = &idesc->endpoint[0].desc; | ||
166 | if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_control(ep)) { | ||
167 | dev_err(&intf->dev, "endpoint incorrect"); | ||
168 | return -ENODEV; | ||
169 | } | ||
170 | |||
171 | ir = devm_kzalloc(&intf->dev, sizeof(*ir), GFP_KERNEL); | ||
172 | if (!ir) | ||
173 | return -ENOMEM; | ||
174 | |||
175 | ir->dev = &intf->dev; | ||
176 | |||
177 | setup_timer(&ir->timer, igorplugusb_timer, (unsigned long)ir); | ||
178 | |||
179 | ir->request.bRequest = GET_INFRACODE; | ||
180 | ir->request.bRequestType = USB_TYPE_VENDOR | USB_DIR_IN; | ||
181 | ir->request.wLength = cpu_to_le16(sizeof(ir->buf_in)); | ||
182 | |||
183 | ir->urb = usb_alloc_urb(0, GFP_KERNEL); | ||
184 | if (!ir->urb) | ||
185 | return -ENOMEM; | ||
186 | |||
187 | usb_fill_control_urb(ir->urb, udev, | ||
188 | usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request, | ||
189 | ir->buf_in, sizeof(ir->buf_in), igorplugusb_callback, ir); | ||
190 | |||
191 | usb_make_path(udev, ir->phys, sizeof(ir->phys)); | ||
192 | |||
193 | rc = rc_allocate_device(); | ||
194 | rc->input_name = DRIVER_DESC; | ||
195 | rc->input_phys = ir->phys; | ||
196 | usb_to_input_id(udev, &rc->input_id); | ||
197 | rc->dev.parent = &intf->dev; | ||
198 | rc->driver_type = RC_DRIVER_IR_RAW; | ||
199 | /* | ||
200 | * This device can only store 36 pulses + spaces, which is not enough | ||
201 | * for the NEC protocol and many others. | ||
202 | */ | ||
203 | rc->allowed_protocols = RC_BIT_ALL & ~(RC_BIT_NEC | RC_BIT_RC6_6A_20 | | ||
204 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | | ||
205 | RC_BIT_SONY20 | RC_BIT_MCE_KBD | RC_BIT_SANYO); | ||
206 | |||
207 | rc->priv = ir; | ||
208 | rc->driver_name = DRIVER_NAME; | ||
209 | rc->map_name = RC_MAP_HAUPPAUGE; | ||
210 | rc->timeout = MS_TO_NS(100); | ||
211 | rc->rx_resolution = 85333; | ||
212 | |||
213 | ir->rc = rc; | ||
214 | ret = rc_register_device(rc); | ||
215 | if (ret) { | ||
216 | dev_err(&intf->dev, "failed to register rc device: %d", ret); | ||
217 | rc_free_device(rc); | ||
218 | usb_free_urb(ir->urb); | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | usb_set_intfdata(intf, ir); | ||
223 | |||
224 | igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY); | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static void igorplugusb_disconnect(struct usb_interface *intf) | ||
230 | { | ||
231 | struct igorplugusb *ir = usb_get_intfdata(intf); | ||
232 | |||
233 | rc_unregister_device(ir->rc); | ||
234 | del_timer_sync(&ir->timer); | ||
235 | usb_set_intfdata(intf, NULL); | ||
236 | usb_kill_urb(ir->urb); | ||
237 | usb_free_urb(ir->urb); | ||
238 | } | ||
239 | |||
240 | static struct usb_device_id igorplugusb_table[] = { | ||
241 | /* Igor Plug USB (Atmel's Manufact. ID) */ | ||
242 | { USB_DEVICE(0x03eb, 0x0002) }, | ||
243 | /* Fit PC2 Infrared Adapter */ | ||
244 | { USB_DEVICE(0x03eb, 0x21fe) }, | ||
245 | /* Terminating entry */ | ||
246 | { } | ||
247 | }; | ||
248 | |||
249 | static struct usb_driver igorplugusb_driver = { | ||
250 | .name = DRIVER_NAME, | ||
251 | .probe = igorplugusb_probe, | ||
252 | .disconnect = igorplugusb_disconnect, | ||
253 | .id_table = igorplugusb_table | ||
254 | }; | ||
255 | |||
256 | module_usb_driver(igorplugusb_driver); | ||
257 | |||
258 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
259 | MODULE_AUTHOR("Sean Young <sean@mess.org>"); | ||
260 | MODULE_LICENSE("GPL"); | ||
261 | MODULE_DEVICE_TABLE(usb, igorplugusb_table); | ||
diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig index 03ba9fc170fb..580715c7fc5e 100644 --- a/drivers/media/rc/img-ir/Kconfig +++ b/drivers/media/rc/img-ir/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config IR_IMG | 1 | config IR_IMG |
2 | tristate "ImgTec IR Decoder" | 2 | tristate "ImgTec IR Decoder" |
3 | depends on RC_CORE | 3 | depends on RC_CORE |
4 | depends on METAG || MIPS || COMPILE_TEST | ||
4 | select IR_IMG_HW if !IR_IMG_RAW | 5 | select IR_IMG_HW if !IR_IMG_RAW |
5 | help | 6 | help |
6 | Say Y or M here if you want to use the ImgTec infrared decoder | 7 | Say Y or M here if you want to use the ImgTec infrared decoder |
diff --git a/drivers/media/rc/img-ir/img-ir-core.c b/drivers/media/rc/img-ir/img-ir-core.c index a0cac2f09109..77c78de4f5bf 100644 --- a/drivers/media/rc/img-ir/img-ir-core.c +++ b/drivers/media/rc/img-ir/img-ir-core.c | |||
@@ -166,7 +166,6 @@ MODULE_DEVICE_TABLE(of, img_ir_match); | |||
166 | static struct platform_driver img_ir_driver = { | 166 | static struct platform_driver img_ir_driver = { |
167 | .driver = { | 167 | .driver = { |
168 | .name = "img-ir", | 168 | .name = "img-ir", |
169 | .owner = THIS_MODULE, | ||
170 | .of_match_table = img_ir_match, | 169 | .of_match_table = img_ir_match, |
171 | .pm = &img_ir_pmops, | 170 | .pm = &img_ir_pmops, |
172 | }, | 171 | }, |
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c index ec49f94425fc..2fd47c9bf5d8 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.c +++ b/drivers/media/rc/img-ir/img-ir-hw.c | |||
@@ -530,6 +530,22 @@ static void img_ir_set_decoder(struct img_ir_priv *priv, | |||
530 | u32 ir_status, irq_en; | 530 | u32 ir_status, irq_en; |
531 | spin_lock_irq(&priv->lock); | 531 | spin_lock_irq(&priv->lock); |
532 | 532 | ||
533 | /* | ||
534 | * First record that the protocol is being stopped so that the end timer | ||
535 | * isn't restarted while we're trying to stop it. | ||
536 | */ | ||
537 | hw->stopping = true; | ||
538 | |||
539 | /* | ||
540 | * Release the lock to stop the end timer, since the end timer handler | ||
541 | * acquires the lock and we don't want to deadlock waiting for it. | ||
542 | */ | ||
543 | spin_unlock_irq(&priv->lock); | ||
544 | del_timer_sync(&hw->end_timer); | ||
545 | spin_lock_irq(&priv->lock); | ||
546 | |||
547 | hw->stopping = false; | ||
548 | |||
533 | /* switch off and disable interrupts */ | 549 | /* switch off and disable interrupts */ |
534 | img_ir_write(priv, IMG_IR_CONTROL, 0); | 550 | img_ir_write(priv, IMG_IR_CONTROL, 0); |
535 | irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE); | 551 | irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE); |
@@ -541,12 +557,13 @@ static void img_ir_set_decoder(struct img_ir_priv *priv, | |||
541 | if (ir_status & (IMG_IR_RXDVAL | IMG_IR_RXDVALD2)) { | 557 | if (ir_status & (IMG_IR_RXDVAL | IMG_IR_RXDVALD2)) { |
542 | ir_status &= ~(IMG_IR_RXDVAL | IMG_IR_RXDVALD2); | 558 | ir_status &= ~(IMG_IR_RXDVAL | IMG_IR_RXDVALD2); |
543 | img_ir_write(priv, IMG_IR_STATUS, ir_status); | 559 | img_ir_write(priv, IMG_IR_STATUS, ir_status); |
544 | img_ir_read(priv, IMG_IR_DATA_LW); | ||
545 | img_ir_read(priv, IMG_IR_DATA_UP); | ||
546 | } | 560 | } |
547 | 561 | ||
548 | /* stop the end timer and switch back to normal mode */ | 562 | /* always read data to clear buffer if IR wakes the device */ |
549 | del_timer_sync(&hw->end_timer); | 563 | img_ir_read(priv, IMG_IR_DATA_LW); |
564 | img_ir_read(priv, IMG_IR_DATA_UP); | ||
565 | |||
566 | /* switch back to normal mode */ | ||
550 | hw->mode = IMG_IR_M_NORMAL; | 567 | hw->mode = IMG_IR_M_NORMAL; |
551 | 568 | ||
552 | /* clear the wakeup scancode filter */ | 569 | /* clear the wakeup scancode filter */ |
@@ -817,7 +834,8 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw) | |||
817 | } | 834 | } |
818 | 835 | ||
819 | 836 | ||
820 | if (dec->repeat) { | 837 | /* we mustn't update the end timer while trying to stop it */ |
838 | if (dec->repeat && !hw->stopping) { | ||
821 | unsigned long interval; | 839 | unsigned long interval; |
822 | 840 | ||
823 | img_ir_begin_repeat(priv); | 841 | img_ir_begin_repeat(priv); |
diff --git a/drivers/media/rc/img-ir/img-ir-hw.h b/drivers/media/rc/img-ir/img-ir-hw.h index 8fcc16c32c5b..5c2b216c5fe3 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.h +++ b/drivers/media/rc/img-ir/img-ir-hw.h | |||
@@ -186,9 +186,6 @@ struct img_ir_reg_timings { | |||
186 | struct img_ir_timing_regvals rtimings; | 186 | struct img_ir_timing_regvals rtimings; |
187 | }; | 187 | }; |
188 | 188 | ||
189 | int img_ir_register_decoder(struct img_ir_decoder *dec); | ||
190 | void img_ir_unregister_decoder(struct img_ir_decoder *dec); | ||
191 | |||
192 | struct img_ir_priv; | 189 | struct img_ir_priv; |
193 | 190 | ||
194 | #ifdef CONFIG_IR_IMG_HW | 191 | #ifdef CONFIG_IR_IMG_HW |
@@ -214,6 +211,8 @@ enum img_ir_mode { | |||
214 | * @flags: IMG_IR_F_*. | 211 | * @flags: IMG_IR_F_*. |
215 | * @filters: HW filters (derived from scancode filters). | 212 | * @filters: HW filters (derived from scancode filters). |
216 | * @mode: Current decode mode. | 213 | * @mode: Current decode mode. |
214 | * @stopping: Indicates that decoder is being taken down and timers | ||
215 | * should not be restarted. | ||
217 | * @suspend_irqen: Saved IRQ enable mask over suspend. | 216 | * @suspend_irqen: Saved IRQ enable mask over suspend. |
218 | */ | 217 | */ |
219 | struct img_ir_priv_hw { | 218 | struct img_ir_priv_hw { |
@@ -229,6 +228,7 @@ struct img_ir_priv_hw { | |||
229 | struct img_ir_filter filters[RC_FILTER_MAX]; | 228 | struct img_ir_filter filters[RC_FILTER_MAX]; |
230 | 229 | ||
231 | enum img_ir_mode mode; | 230 | enum img_ir_mode mode; |
231 | bool stopping; | ||
232 | u32 suspend_irqen; | 232 | u32 suspend_irqen; |
233 | }; | 233 | }; |
234 | 234 | ||
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index ed2c8a1ed8ca..98893a8332c7 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c | |||
@@ -42,11 +42,17 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) | |||
42 | return -EINVAL; | 42 | return -EINVAL; |
43 | 43 | ||
44 | /* Packet start */ | 44 | /* Packet start */ |
45 | if (ev.reset) | 45 | if (ev.reset) { |
46 | return 0; | 46 | /* Userspace expects a long space event before the start of |
47 | * the signal to use as a sync. This may be done with repeat | ||
48 | * packets and normal samples. But if a reset has been sent | ||
49 | * then we assume that a long time has passed, so we send a | ||
50 | * space with the maximum time value. */ | ||
51 | sample = LIRC_SPACE(LIRC_VALUE_MASK); | ||
52 | IR_dprintk(2, "delivering reset sync space to lirc_dev\n"); | ||
47 | 53 | ||
48 | /* Carrier reports */ | 54 | /* Carrier reports */ |
49 | if (ev.carrier_report) { | 55 | } else if (ev.carrier_report) { |
50 | sample = LIRC_FREQUENCY(ev.carrier); | 56 | sample = LIRC_FREQUENCY(ev.carrier); |
51 | IR_dprintk(2, "carrier report (freq: %d)\n", sample); | 57 | IR_dprintk(2, "carrier report (freq: %d)\n", sample); |
52 | 58 | ||
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 249d2fbc8f37..1e0545a67959 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c | |||
@@ -518,8 +518,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file) | |||
518 | 518 | ||
519 | WARN_ON(mutex_lock_killable(&lirc_dev_lock)); | 519 | WARN_ON(mutex_lock_killable(&lirc_dev_lock)); |
520 | 520 | ||
521 | if (ir->d.rdev) | 521 | rc_close(ir->d.rdev); |
522 | rc_close(ir->d.rdev); | ||
523 | 522 | ||
524 | ir->open--; | 523 | ir->open--; |
525 | if (ir->attached) { | 524 | if (ir->attached) { |
diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c new file mode 100644 index 000000000000..fcc3b82d1454 --- /dev/null +++ b/drivers/media/rc/meson-ir.c | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | * Driver for Amlogic Meson IR remote receiver | ||
3 | * | ||
4 | * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * You should have received a copy of the GNU General Public License | ||
11 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
12 | */ | ||
13 | |||
14 | #include <linux/device.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | |||
23 | #include <media/rc-core.h> | ||
24 | |||
25 | #define DRIVER_NAME "meson-ir" | ||
26 | |||
27 | #define IR_DEC_LDR_ACTIVE 0x00 | ||
28 | #define IR_DEC_LDR_IDLE 0x04 | ||
29 | #define IR_DEC_LDR_REPEAT 0x08 | ||
30 | #define IR_DEC_BIT_0 0x0c | ||
31 | #define IR_DEC_REG0 0x10 | ||
32 | #define IR_DEC_FRAME 0x14 | ||
33 | #define IR_DEC_STATUS 0x18 | ||
34 | #define IR_DEC_REG1 0x1c | ||
35 | |||
36 | #define REG0_RATE_MASK (BIT(11) - 1) | ||
37 | |||
38 | #define REG1_MODE_MASK (BIT(7) | BIT(8)) | ||
39 | #define REG1_MODE_NEC (0 << 7) | ||
40 | #define REG1_MODE_GENERAL (2 << 7) | ||
41 | |||
42 | #define REG1_TIME_IV_SHIFT 16 | ||
43 | #define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT) | ||
44 | |||
45 | #define REG1_IRQSEL_MASK (BIT(2) | BIT(3)) | ||
46 | #define REG1_IRQSEL_NEC_MODE (0 << 2) | ||
47 | #define REG1_IRQSEL_RISE_FALL (1 << 2) | ||
48 | #define REG1_IRQSEL_FALL (2 << 2) | ||
49 | #define REG1_IRQSEL_RISE (3 << 2) | ||
50 | |||
51 | #define REG1_RESET BIT(0) | ||
52 | #define REG1_ENABLE BIT(15) | ||
53 | |||
54 | #define STATUS_IR_DEC_IN BIT(8) | ||
55 | |||
56 | #define MESON_TRATE 10 /* us */ | ||
57 | |||
58 | struct meson_ir { | ||
59 | void __iomem *reg; | ||
60 | struct rc_dev *rc; | ||
61 | int irq; | ||
62 | spinlock_t lock; | ||
63 | }; | ||
64 | |||
65 | static void meson_ir_set_mask(struct meson_ir *ir, unsigned int reg, | ||
66 | u32 mask, u32 value) | ||
67 | { | ||
68 | u32 data; | ||
69 | |||
70 | data = readl(ir->reg + reg); | ||
71 | data &= ~mask; | ||
72 | data |= (value & mask); | ||
73 | writel(data, ir->reg + reg); | ||
74 | } | ||
75 | |||
76 | static irqreturn_t meson_ir_irq(int irqno, void *dev_id) | ||
77 | { | ||
78 | struct meson_ir *ir = dev_id; | ||
79 | u32 duration; | ||
80 | DEFINE_IR_RAW_EVENT(rawir); | ||
81 | |||
82 | spin_lock(&ir->lock); | ||
83 | |||
84 | duration = readl(ir->reg + IR_DEC_REG1); | ||
85 | duration = (duration & REG1_TIME_IV_MASK) >> REG1_TIME_IV_SHIFT; | ||
86 | rawir.duration = US_TO_NS(duration * MESON_TRATE); | ||
87 | |||
88 | rawir.pulse = !!(readl(ir->reg + IR_DEC_STATUS) & STATUS_IR_DEC_IN); | ||
89 | |||
90 | ir_raw_event_store_with_filter(ir->rc, &rawir); | ||
91 | ir_raw_event_handle(ir->rc); | ||
92 | |||
93 | spin_unlock(&ir->lock); | ||
94 | |||
95 | return IRQ_HANDLED; | ||
96 | } | ||
97 | |||
98 | static int meson_ir_probe(struct platform_device *pdev) | ||
99 | { | ||
100 | struct device *dev = &pdev->dev; | ||
101 | struct device_node *node = dev->of_node; | ||
102 | struct resource *res; | ||
103 | const char *map_name; | ||
104 | struct meson_ir *ir; | ||
105 | int ret; | ||
106 | |||
107 | ir = devm_kzalloc(dev, sizeof(struct meson_ir), GFP_KERNEL); | ||
108 | if (!ir) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
112 | ir->reg = devm_ioremap_resource(dev, res); | ||
113 | if (IS_ERR(ir->reg)) { | ||
114 | dev_err(dev, "failed to map registers\n"); | ||
115 | return PTR_ERR(ir->reg); | ||
116 | } | ||
117 | |||
118 | ir->irq = platform_get_irq(pdev, 0); | ||
119 | if (ir->irq < 0) { | ||
120 | dev_err(dev, "no irq resource\n"); | ||
121 | return ir->irq; | ||
122 | } | ||
123 | |||
124 | ir->rc = rc_allocate_device(); | ||
125 | if (!ir->rc) { | ||
126 | dev_err(dev, "failed to allocate rc device\n"); | ||
127 | return -ENOMEM; | ||
128 | } | ||
129 | |||
130 | ir->rc->priv = ir; | ||
131 | ir->rc->input_name = DRIVER_NAME; | ||
132 | ir->rc->input_phys = DRIVER_NAME "/input0"; | ||
133 | ir->rc->input_id.bustype = BUS_HOST; | ||
134 | map_name = of_get_property(node, "linux,rc-map-name", NULL); | ||
135 | ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY; | ||
136 | ir->rc->dev.parent = dev; | ||
137 | ir->rc->driver_type = RC_DRIVER_IR_RAW; | ||
138 | ir->rc->allowed_protocols = RC_BIT_ALL; | ||
139 | ir->rc->rx_resolution = US_TO_NS(MESON_TRATE); | ||
140 | ir->rc->timeout = MS_TO_NS(200); | ||
141 | ir->rc->driver_name = DRIVER_NAME; | ||
142 | |||
143 | spin_lock_init(&ir->lock); | ||
144 | platform_set_drvdata(pdev, ir); | ||
145 | |||
146 | ret = rc_register_device(ir->rc); | ||
147 | if (ret) { | ||
148 | dev_err(dev, "failed to register rc device\n"); | ||
149 | goto out_free; | ||
150 | } | ||
151 | |||
152 | ret = devm_request_irq(dev, ir->irq, meson_ir_irq, 0, "ir-meson", ir); | ||
153 | if (ret) { | ||
154 | dev_err(dev, "failed to request irq\n"); | ||
155 | goto out_unreg; | ||
156 | } | ||
157 | |||
158 | /* Reset the decoder */ | ||
159 | meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, REG1_RESET); | ||
160 | meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, 0); | ||
161 | /* Set general operation mode */ | ||
162 | meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK, REG1_MODE_GENERAL); | ||
163 | /* Set rate */ | ||
164 | meson_ir_set_mask(ir, IR_DEC_REG0, REG0_RATE_MASK, MESON_TRATE - 1); | ||
165 | /* IRQ on rising and falling edges */ | ||
166 | meson_ir_set_mask(ir, IR_DEC_REG1, REG1_IRQSEL_MASK, | ||
167 | REG1_IRQSEL_RISE_FALL); | ||
168 | /* Enable the decoder */ | ||
169 | meson_ir_set_mask(ir, IR_DEC_REG1, REG1_ENABLE, REG1_ENABLE); | ||
170 | |||
171 | dev_info(dev, "receiver initialized\n"); | ||
172 | |||
173 | return 0; | ||
174 | out_unreg: | ||
175 | rc_unregister_device(ir->rc); | ||
176 | ir->rc = NULL; | ||
177 | out_free: | ||
178 | rc_free_device(ir->rc); | ||
179 | |||
180 | return ret; | ||
181 | } | ||
182 | |||
183 | static int meson_ir_remove(struct platform_device *pdev) | ||
184 | { | ||
185 | struct meson_ir *ir = platform_get_drvdata(pdev); | ||
186 | unsigned long flags; | ||
187 | |||
188 | /* Disable the decoder */ | ||
189 | spin_lock_irqsave(&ir->lock, flags); | ||
190 | meson_ir_set_mask(ir, IR_DEC_REG1, REG1_ENABLE, 0); | ||
191 | spin_unlock_irqrestore(&ir->lock, flags); | ||
192 | |||
193 | rc_unregister_device(ir->rc); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static const struct of_device_id meson_ir_match[] = { | ||
199 | { .compatible = "amlogic,meson6-ir" }, | ||
200 | { }, | ||
201 | }; | ||
202 | |||
203 | static struct platform_driver meson_ir_driver = { | ||
204 | .probe = meson_ir_probe, | ||
205 | .remove = meson_ir_remove, | ||
206 | .driver = { | ||
207 | .name = DRIVER_NAME, | ||
208 | .of_match_table = meson_ir_match, | ||
209 | }, | ||
210 | }; | ||
211 | |||
212 | module_platform_driver(meson_ir_driver); | ||
213 | |||
214 | MODULE_DESCRIPTION("Amlogic Meson IR remote receiver driver"); | ||
215 | MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>"); | ||
216 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 8d3b74c5a717..86ffcd54339e 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -1298,8 +1298,7 @@ void rc_free_device(struct rc_dev *dev) | |||
1298 | if (!dev) | 1298 | if (!dev) |
1299 | return; | 1299 | return; |
1300 | 1300 | ||
1301 | if (dev->input_dev) | 1301 | input_free_device(dev->input_dev); |
1302 | input_free_device(dev->input_dev); | ||
1303 | 1302 | ||
1304 | put_device(&dev->dev); | 1303 | put_device(&dev->dev); |
1305 | 1304 | ||
@@ -1414,13 +1413,16 @@ int rc_register_device(struct rc_dev *dev) | |||
1414 | ir_raw_init(); | 1413 | ir_raw_init(); |
1415 | raw_init = true; | 1414 | raw_init = true; |
1416 | } | 1415 | } |
1416 | /* calls ir_register_device so unlock mutex here*/ | ||
1417 | mutex_unlock(&dev->lock); | ||
1417 | rc = ir_raw_event_register(dev); | 1418 | rc = ir_raw_event_register(dev); |
1419 | mutex_lock(&dev->lock); | ||
1418 | if (rc < 0) | 1420 | if (rc < 0) |
1419 | goto out_input; | 1421 | goto out_input; |
1420 | } | 1422 | } |
1421 | 1423 | ||
1422 | if (dev->change_protocol) { | 1424 | if (dev->change_protocol) { |
1423 | u64 rc_type = (1 << rc_map->rc_type); | 1425 | u64 rc_type = (1ll << rc_map->rc_type); |
1424 | if (dev->driver_type == RC_DRIVER_IR_RAW) | 1426 | if (dev->driver_type == RC_DRIVER_IR_RAW) |
1425 | rc_type |= RC_BIT_LIRC; | 1427 | rc_type |= RC_BIT_LIRC; |
1426 | rc = dev->change_protocol(dev, &rc_type); | 1428 | rc = dev->change_protocol(dev, &rc_type); |
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index 795b394a5d84..c4def66f9aa2 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c | |||
@@ -966,7 +966,7 @@ static int redrat3_dev_probe(struct usb_interface *intf, | |||
966 | 966 | ||
967 | rr3->ep_in = ep_in; | 967 | rr3->ep_in = ep_in; |
968 | rr3->bulk_in_buf = usb_alloc_coherent(udev, | 968 | rr3->bulk_in_buf = usb_alloc_coherent(udev, |
969 | le16_to_cpu(ep_in->wMaxPacketSize), GFP_ATOMIC, &rr3->dma_in); | 969 | le16_to_cpu(ep_in->wMaxPacketSize), GFP_KERNEL, &rr3->dma_in); |
970 | if (!rr3->bulk_in_buf) { | 970 | if (!rr3->bulk_in_buf) { |
971 | dev_err(dev, "Read buffer allocation failure\n"); | 971 | dev_err(dev, "Read buffer allocation failure\n"); |
972 | goto error; | 972 | goto error; |
@@ -975,6 +975,8 @@ static int redrat3_dev_probe(struct usb_interface *intf, | |||
975 | pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress); | 975 | pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress); |
976 | usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf, | 976 | usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf, |
977 | le16_to_cpu(ep_in->wMaxPacketSize), redrat3_handle_async, rr3); | 977 | le16_to_cpu(ep_in->wMaxPacketSize), redrat3_handle_async, rr3); |
978 | rr3->read_urb->transfer_dma = rr3->dma_in; | ||
979 | rr3->read_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
978 | 980 | ||
979 | rr3->ep_out = ep_out; | 981 | rr3->ep_out = ep_out; |
980 | rr3->udev = udev; | 982 | rr3->udev = udev; |
diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig index f039dc2a21cf..42e5a01b9192 100644 --- a/drivers/media/tuners/Kconfig +++ b/drivers/media/tuners/Kconfig | |||
@@ -232,6 +232,14 @@ config MEDIA_TUNER_M88TS2022 | |||
232 | help | 232 | help |
233 | Montage M88TS2022 silicon tuner driver. | 233 | Montage M88TS2022 silicon tuner driver. |
234 | 234 | ||
235 | config MEDIA_TUNER_M88RS6000T | ||
236 | tristate "Montage M88RS6000 internal tuner" | ||
237 | depends on MEDIA_SUPPORT && I2C | ||
238 | select REGMAP_I2C | ||
239 | default m if !MEDIA_SUBDRV_AUTOSELECT | ||
240 | help | ||
241 | Montage M88RS6000 internal tuner. | ||
242 | |||
235 | config MEDIA_TUNER_TUA9001 | 243 | config MEDIA_TUNER_TUA9001 |
236 | tristate "Infineon TUA 9001 silicon tuner" | 244 | tristate "Infineon TUA 9001 silicon tuner" |
237 | depends on MEDIA_SUPPORT && I2C | 245 | depends on MEDIA_SUPPORT && I2C |
diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile index 49fcf8033848..da4fe6ef73e7 100644 --- a/drivers/media/tuners/Makefile +++ b/drivers/media/tuners/Makefile | |||
@@ -41,6 +41,7 @@ obj-$(CONFIG_MEDIA_TUNER_IT913X) += it913x.o | |||
41 | obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o | 41 | obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o |
42 | obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o | 42 | obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o |
43 | obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o | 43 | obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o |
44 | obj-$(CONFIG_MEDIA_TUNER_M88RS6000T) += m88rs6000t.o | ||
44 | 45 | ||
45 | ccflags-y += -I$(srctree)/drivers/media/dvb-core | 46 | ccflags-y += -I$(srctree)/drivers/media/dvb-core |
46 | ccflags-y += -I$(srctree)/drivers/media/dvb-frontends | 47 | ccflags-y += -I$(srctree)/drivers/media/dvb-frontends |
diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c new file mode 100644 index 000000000000..d4c13fe6e7b3 --- /dev/null +++ b/drivers/media/tuners/m88rs6000t.c | |||
@@ -0,0 +1,744 @@ | |||
1 | /* | ||
2 | * Driver for the internal tuner of Montage M88RS6000 | ||
3 | * | ||
4 | * Copyright (C) 2014 Max nibble <nibble.max@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #include "m88rs6000t.h" | ||
18 | #include <linux/regmap.h> | ||
19 | |||
20 | struct m88rs6000t_dev { | ||
21 | struct m88rs6000t_config cfg; | ||
22 | struct i2c_client *client; | ||
23 | struct regmap *regmap; | ||
24 | u32 frequency_khz; | ||
25 | }; | ||
26 | |||
27 | struct m88rs6000t_reg_val { | ||
28 | u8 reg; | ||
29 | u8 val; | ||
30 | }; | ||
31 | |||
32 | /* set demod main mclk and ts mclk */ | ||
33 | static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe) | ||
34 | { | ||
35 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
36 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
37 | u8 reg11, reg15, reg16, reg1D, reg1E, reg1F; | ||
38 | u8 N, f0 = 0, f1 = 0, f2 = 0, f3 = 0; | ||
39 | u16 pll_div_fb; | ||
40 | u32 div, ts_mclk; | ||
41 | unsigned int utmp; | ||
42 | int ret; | ||
43 | |||
44 | /* select demod main mclk */ | ||
45 | ret = regmap_read(dev->regmap, 0x15, &utmp); | ||
46 | if (ret) | ||
47 | goto err; | ||
48 | reg15 = utmp; | ||
49 | if (c->symbol_rate > 45010000) { | ||
50 | reg11 = 0x0E; | ||
51 | reg15 |= 0x02; | ||
52 | reg16 = 115; /* mclk = 110.25MHz */ | ||
53 | } else { | ||
54 | reg11 = 0x0A; | ||
55 | reg15 &= ~0x02; | ||
56 | reg16 = 96; /* mclk = 96MHz */ | ||
57 | } | ||
58 | |||
59 | /* set ts mclk */ | ||
60 | if (c->delivery_system == SYS_DVBS) | ||
61 | ts_mclk = 96000; | ||
62 | else | ||
63 | ts_mclk = 144000; | ||
64 | |||
65 | pll_div_fb = (reg15 & 0x01) << 8; | ||
66 | pll_div_fb += reg16; | ||
67 | pll_div_fb += 32; | ||
68 | |||
69 | div = 36000 * pll_div_fb; | ||
70 | div /= ts_mclk; | ||
71 | |||
72 | if (div <= 32) { | ||
73 | N = 2; | ||
74 | f0 = 0; | ||
75 | f1 = div / 2; | ||
76 | f2 = div - f1; | ||
77 | f3 = 0; | ||
78 | } else if (div <= 48) { | ||
79 | N = 3; | ||
80 | f0 = div / 3; | ||
81 | f1 = (div - f0) / 2; | ||
82 | f2 = div - f0 - f1; | ||
83 | f3 = 0; | ||
84 | } else if (div <= 64) { | ||
85 | N = 4; | ||
86 | f0 = div / 4; | ||
87 | f1 = (div - f0) / 3; | ||
88 | f2 = (div - f0 - f1) / 2; | ||
89 | f3 = div - f0 - f1 - f2; | ||
90 | } else { | ||
91 | N = 4; | ||
92 | f0 = 16; | ||
93 | f1 = 16; | ||
94 | f2 = 16; | ||
95 | f3 = 16; | ||
96 | } | ||
97 | |||
98 | if (f0 == 16) | ||
99 | f0 = 0; | ||
100 | if (f1 == 16) | ||
101 | f1 = 0; | ||
102 | if (f2 == 16) | ||
103 | f2 = 0; | ||
104 | if (f3 == 16) | ||
105 | f3 = 0; | ||
106 | |||
107 | ret = regmap_read(dev->regmap, 0x1D, &utmp); | ||
108 | if (ret) | ||
109 | goto err; | ||
110 | reg1D = utmp; | ||
111 | reg1D &= ~0x03; | ||
112 | reg1D |= N - 1; | ||
113 | reg1E = ((f3 << 4) + f2) & 0xFF; | ||
114 | reg1F = ((f1 << 4) + f0) & 0xFF; | ||
115 | |||
116 | /* program and recalibrate demod PLL */ | ||
117 | ret = regmap_write(dev->regmap, 0x05, 0x40); | ||
118 | if (ret) | ||
119 | goto err; | ||
120 | ret = regmap_write(dev->regmap, 0x11, 0x08); | ||
121 | if (ret) | ||
122 | goto err; | ||
123 | ret = regmap_write(dev->regmap, 0x15, reg15); | ||
124 | if (ret) | ||
125 | goto err; | ||
126 | ret = regmap_write(dev->regmap, 0x16, reg16); | ||
127 | if (ret) | ||
128 | goto err; | ||
129 | ret = regmap_write(dev->regmap, 0x1D, reg1D); | ||
130 | if (ret) | ||
131 | goto err; | ||
132 | ret = regmap_write(dev->regmap, 0x1E, reg1E); | ||
133 | if (ret) | ||
134 | goto err; | ||
135 | ret = regmap_write(dev->regmap, 0x1F, reg1F); | ||
136 | if (ret) | ||
137 | goto err; | ||
138 | ret = regmap_write(dev->regmap, 0x17, 0xc1); | ||
139 | if (ret) | ||
140 | goto err; | ||
141 | ret = regmap_write(dev->regmap, 0x17, 0x81); | ||
142 | if (ret) | ||
143 | goto err; | ||
144 | usleep_range(5000, 50000); | ||
145 | ret = regmap_write(dev->regmap, 0x05, 0x00); | ||
146 | if (ret) | ||
147 | goto err; | ||
148 | ret = regmap_write(dev->regmap, 0x11, reg11); | ||
149 | if (ret) | ||
150 | goto err; | ||
151 | usleep_range(5000, 50000); | ||
152 | err: | ||
153 | if (ret) | ||
154 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev, | ||
159 | u32 tuner_freq_MHz) | ||
160 | { | ||
161 | u32 fcry_KHz, ulNDiv1, ulNDiv2, ulNDiv; | ||
162 | u8 refDiv, ucLoDiv1, ucLomod1, ucLoDiv2, ucLomod2, ucLoDiv, ucLomod; | ||
163 | u8 reg27, reg29, reg42, reg42buf; | ||
164 | unsigned int utmp; | ||
165 | int ret; | ||
166 | |||
167 | fcry_KHz = 27000; /* in kHz */ | ||
168 | refDiv = 27; | ||
169 | |||
170 | ret = regmap_write(dev->regmap, 0x36, (refDiv - 8)); | ||
171 | if (ret) | ||
172 | goto err; | ||
173 | ret = regmap_write(dev->regmap, 0x31, 0x00); | ||
174 | if (ret) | ||
175 | goto err; | ||
176 | ret = regmap_write(dev->regmap, 0x2c, 0x02); | ||
177 | if (ret) | ||
178 | goto err; | ||
179 | |||
180 | if (tuner_freq_MHz >= 1550) { | ||
181 | ucLoDiv1 = 2; | ||
182 | ucLomod1 = 0; | ||
183 | ucLoDiv2 = 2; | ||
184 | ucLomod2 = 0; | ||
185 | } else if (tuner_freq_MHz >= 1380) { | ||
186 | ucLoDiv1 = 3; | ||
187 | ucLomod1 = 16; | ||
188 | ucLoDiv2 = 2; | ||
189 | ucLomod2 = 0; | ||
190 | } else if (tuner_freq_MHz >= 1070) { | ||
191 | ucLoDiv1 = 3; | ||
192 | ucLomod1 = 16; | ||
193 | ucLoDiv2 = 3; | ||
194 | ucLomod2 = 16; | ||
195 | } else if (tuner_freq_MHz >= 1000) { | ||
196 | ucLoDiv1 = 3; | ||
197 | ucLomod1 = 16; | ||
198 | ucLoDiv2 = 4; | ||
199 | ucLomod2 = 64; | ||
200 | } else if (tuner_freq_MHz >= 775) { | ||
201 | ucLoDiv1 = 4; | ||
202 | ucLomod1 = 64; | ||
203 | ucLoDiv2 = 4; | ||
204 | ucLomod2 = 64; | ||
205 | } else if (tuner_freq_MHz >= 700) { | ||
206 | ucLoDiv1 = 6; | ||
207 | ucLomod1 = 48; | ||
208 | ucLoDiv2 = 4; | ||
209 | ucLomod2 = 64; | ||
210 | } else if (tuner_freq_MHz >= 520) { | ||
211 | ucLoDiv1 = 6; | ||
212 | ucLomod1 = 48; | ||
213 | ucLoDiv2 = 6; | ||
214 | ucLomod2 = 48; | ||
215 | } else { | ||
216 | ucLoDiv1 = 8; | ||
217 | ucLomod1 = 96; | ||
218 | ucLoDiv2 = 8; | ||
219 | ucLomod2 = 96; | ||
220 | } | ||
221 | |||
222 | ulNDiv1 = ((tuner_freq_MHz * ucLoDiv1 * 1000) * refDiv | ||
223 | / fcry_KHz - 1024) / 2; | ||
224 | ulNDiv2 = ((tuner_freq_MHz * ucLoDiv2 * 1000) * refDiv | ||
225 | / fcry_KHz - 1024) / 2; | ||
226 | |||
227 | reg27 = (((ulNDiv1 >> 8) & 0x0F) + ucLomod1) & 0x7F; | ||
228 | ret = regmap_write(dev->regmap, 0x27, reg27); | ||
229 | if (ret) | ||
230 | goto err; | ||
231 | ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv1 & 0xFF)); | ||
232 | if (ret) | ||
233 | goto err; | ||
234 | reg29 = (((ulNDiv2 >> 8) & 0x0F) + ucLomod2) & 0x7f; | ||
235 | ret = regmap_write(dev->regmap, 0x29, reg29); | ||
236 | if (ret) | ||
237 | goto err; | ||
238 | ret = regmap_write(dev->regmap, 0x2a, (u8)(ulNDiv2 & 0xFF)); | ||
239 | if (ret) | ||
240 | goto err; | ||
241 | ret = regmap_write(dev->regmap, 0x2F, 0xf5); | ||
242 | if (ret) | ||
243 | goto err; | ||
244 | ret = regmap_write(dev->regmap, 0x30, 0x05); | ||
245 | if (ret) | ||
246 | goto err; | ||
247 | ret = regmap_write(dev->regmap, 0x08, 0x1f); | ||
248 | if (ret) | ||
249 | goto err; | ||
250 | ret = regmap_write(dev->regmap, 0x08, 0x3f); | ||
251 | if (ret) | ||
252 | goto err; | ||
253 | ret = regmap_write(dev->regmap, 0x09, 0x20); | ||
254 | if (ret) | ||
255 | goto err; | ||
256 | ret = regmap_write(dev->regmap, 0x09, 0x00); | ||
257 | if (ret) | ||
258 | goto err; | ||
259 | ret = regmap_write(dev->regmap, 0x3e, 0x11); | ||
260 | if (ret) | ||
261 | goto err; | ||
262 | ret = regmap_write(dev->regmap, 0x08, 0x2f); | ||
263 | if (ret) | ||
264 | goto err; | ||
265 | ret = regmap_write(dev->regmap, 0x08, 0x3f); | ||
266 | if (ret) | ||
267 | goto err; | ||
268 | ret = regmap_write(dev->regmap, 0x09, 0x10); | ||
269 | if (ret) | ||
270 | goto err; | ||
271 | ret = regmap_write(dev->regmap, 0x09, 0x00); | ||
272 | if (ret) | ||
273 | goto err; | ||
274 | usleep_range(2000, 50000); | ||
275 | |||
276 | ret = regmap_read(dev->regmap, 0x42, &utmp); | ||
277 | if (ret) | ||
278 | goto err; | ||
279 | reg42 = utmp; | ||
280 | |||
281 | ret = regmap_write(dev->regmap, 0x3e, 0x10); | ||
282 | if (ret) | ||
283 | goto err; | ||
284 | ret = regmap_write(dev->regmap, 0x08, 0x2f); | ||
285 | if (ret) | ||
286 | goto err; | ||
287 | ret = regmap_write(dev->regmap, 0x08, 0x3f); | ||
288 | if (ret) | ||
289 | goto err; | ||
290 | ret = regmap_write(dev->regmap, 0x09, 0x10); | ||
291 | if (ret) | ||
292 | goto err; | ||
293 | ret = regmap_write(dev->regmap, 0x09, 0x00); | ||
294 | if (ret) | ||
295 | goto err; | ||
296 | usleep_range(2000, 50000); | ||
297 | |||
298 | ret = regmap_read(dev->regmap, 0x42, &utmp); | ||
299 | if (ret) | ||
300 | goto err; | ||
301 | reg42buf = utmp; | ||
302 | if (reg42buf < reg42) { | ||
303 | ret = regmap_write(dev->regmap, 0x3e, 0x11); | ||
304 | if (ret) | ||
305 | goto err; | ||
306 | } | ||
307 | usleep_range(5000, 50000); | ||
308 | |||
309 | ret = regmap_read(dev->regmap, 0x2d, &utmp); | ||
310 | if (ret) | ||
311 | goto err; | ||
312 | ret = regmap_write(dev->regmap, 0x2d, utmp); | ||
313 | if (ret) | ||
314 | goto err; | ||
315 | ret = regmap_read(dev->regmap, 0x2e, &utmp); | ||
316 | if (ret) | ||
317 | goto err; | ||
318 | ret = regmap_write(dev->regmap, 0x2e, utmp); | ||
319 | if (ret) | ||
320 | goto err; | ||
321 | |||
322 | ret = regmap_read(dev->regmap, 0x27, &utmp); | ||
323 | if (ret) | ||
324 | goto err; | ||
325 | reg27 = utmp & 0x70; | ||
326 | ret = regmap_read(dev->regmap, 0x83, &utmp); | ||
327 | if (ret) | ||
328 | goto err; | ||
329 | if (reg27 == (utmp & 0x70)) { | ||
330 | ucLoDiv = ucLoDiv1; | ||
331 | ulNDiv = ulNDiv1; | ||
332 | ucLomod = ucLomod1 / 16; | ||
333 | } else { | ||
334 | ucLoDiv = ucLoDiv2; | ||
335 | ulNDiv = ulNDiv2; | ||
336 | ucLomod = ucLomod2 / 16; | ||
337 | } | ||
338 | |||
339 | if ((ucLoDiv == 3) || (ucLoDiv == 6)) { | ||
340 | refDiv = 18; | ||
341 | ret = regmap_write(dev->regmap, 0x36, (refDiv - 8)); | ||
342 | if (ret) | ||
343 | goto err; | ||
344 | ulNDiv = ((tuner_freq_MHz * ucLoDiv * 1000) * refDiv | ||
345 | / fcry_KHz - 1024) / 2; | ||
346 | } | ||
347 | |||
348 | reg27 = (0x80 + ((ucLomod << 4) & 0x70) | ||
349 | + ((ulNDiv >> 8) & 0x0F)) & 0xFF; | ||
350 | ret = regmap_write(dev->regmap, 0x27, reg27); | ||
351 | if (ret) | ||
352 | goto err; | ||
353 | ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv & 0xFF)); | ||
354 | if (ret) | ||
355 | goto err; | ||
356 | ret = regmap_write(dev->regmap, 0x29, 0x80); | ||
357 | if (ret) | ||
358 | goto err; | ||
359 | ret = regmap_write(dev->regmap, 0x31, 0x03); | ||
360 | if (ret) | ||
361 | goto err; | ||
362 | |||
363 | if (ucLoDiv == 3) | ||
364 | utmp = 0xCE; | ||
365 | else | ||
366 | utmp = 0x8A; | ||
367 | ret = regmap_write(dev->regmap, 0x3b, utmp); | ||
368 | if (ret) | ||
369 | goto err; | ||
370 | |||
371 | dev->frequency_khz = fcry_KHz * (ulNDiv * 2 + 1024) / refDiv / ucLoDiv; | ||
372 | |||
373 | dev_dbg(&dev->client->dev, | ||
374 | "actual tune frequency=%d\n", dev->frequency_khz); | ||
375 | err: | ||
376 | if (ret) | ||
377 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
378 | return ret; | ||
379 | } | ||
380 | |||
381 | static int m88rs6000t_set_bb(struct m88rs6000t_dev *dev, | ||
382 | u32 symbol_rate_KSs, s32 lpf_offset_KHz) | ||
383 | { | ||
384 | u32 f3dB; | ||
385 | u8 reg40; | ||
386 | |||
387 | f3dB = symbol_rate_KSs * 9 / 14 + 2000; | ||
388 | f3dB += lpf_offset_KHz; | ||
389 | f3dB = clamp_val(f3dB, 6000U, 43000U); | ||
390 | reg40 = f3dB / 1000; | ||
391 | return regmap_write(dev->regmap, 0x40, reg40); | ||
392 | } | ||
393 | |||
394 | static int m88rs6000t_set_params(struct dvb_frontend *fe) | ||
395 | { | ||
396 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
397 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
398 | int ret; | ||
399 | s32 lpf_offset_KHz; | ||
400 | u32 realFreq, freq_MHz; | ||
401 | |||
402 | dev_dbg(&dev->client->dev, | ||
403 | "frequency=%d symbol_rate=%d\n", | ||
404 | c->frequency, c->symbol_rate); | ||
405 | |||
406 | if (c->symbol_rate < 5000000) | ||
407 | lpf_offset_KHz = 3000; | ||
408 | else | ||
409 | lpf_offset_KHz = 0; | ||
410 | |||
411 | realFreq = c->frequency + lpf_offset_KHz; | ||
412 | /* set tuner pll.*/ | ||
413 | freq_MHz = (realFreq + 500) / 1000; | ||
414 | ret = m88rs6000t_set_pll_freq(dev, freq_MHz); | ||
415 | if (ret) | ||
416 | goto err; | ||
417 | ret = m88rs6000t_set_bb(dev, c->symbol_rate / 1000, lpf_offset_KHz); | ||
418 | if (ret) | ||
419 | goto err; | ||
420 | ret = regmap_write(dev->regmap, 0x00, 0x01); | ||
421 | if (ret) | ||
422 | goto err; | ||
423 | ret = regmap_write(dev->regmap, 0x00, 0x00); | ||
424 | if (ret) | ||
425 | goto err; | ||
426 | /* set demod mlck */ | ||
427 | ret = m88rs6000t_set_demod_mclk(fe); | ||
428 | err: | ||
429 | if (ret) | ||
430 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
431 | return ret; | ||
432 | } | ||
433 | |||
434 | static int m88rs6000t_init(struct dvb_frontend *fe) | ||
435 | { | ||
436 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
437 | int ret; | ||
438 | |||
439 | dev_dbg(&dev->client->dev, "%s:\n", __func__); | ||
440 | |||
441 | ret = regmap_update_bits(dev->regmap, 0x11, 0x08, 0x08); | ||
442 | if (ret) | ||
443 | goto err; | ||
444 | usleep_range(5000, 50000); | ||
445 | ret = regmap_update_bits(dev->regmap, 0x10, 0x01, 0x01); | ||
446 | if (ret) | ||
447 | goto err; | ||
448 | usleep_range(10000, 50000); | ||
449 | ret = regmap_write(dev->regmap, 0x07, 0x7d); | ||
450 | err: | ||
451 | if (ret) | ||
452 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
453 | return ret; | ||
454 | } | ||
455 | |||
456 | static int m88rs6000t_sleep(struct dvb_frontend *fe) | ||
457 | { | ||
458 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
459 | int ret; | ||
460 | |||
461 | dev_dbg(&dev->client->dev, "%s:\n", __func__); | ||
462 | |||
463 | ret = regmap_write(dev->regmap, 0x07, 0x6d); | ||
464 | if (ret) | ||
465 | goto err; | ||
466 | usleep_range(5000, 10000); | ||
467 | err: | ||
468 | if (ret) | ||
469 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
470 | return ret; | ||
471 | } | ||
472 | |||
473 | static int m88rs6000t_get_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
474 | { | ||
475 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
476 | |||
477 | dev_dbg(&dev->client->dev, "\n"); | ||
478 | |||
479 | *frequency = dev->frequency_khz; | ||
480 | return 0; | ||
481 | } | ||
482 | |||
483 | static int m88rs6000t_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
484 | { | ||
485 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
486 | |||
487 | dev_dbg(&dev->client->dev, "\n"); | ||
488 | |||
489 | *frequency = 0; /* Zero-IF */ | ||
490 | return 0; | ||
491 | } | ||
492 | |||
493 | |||
494 | static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength) | ||
495 | { | ||
496 | struct m88rs6000t_dev *dev = fe->tuner_priv; | ||
497 | unsigned int val, i; | ||
498 | int ret; | ||
499 | u16 gain; | ||
500 | u32 PGA2_cri_GS = 46, PGA2_crf_GS = 290, TIA_GS = 290; | ||
501 | u32 RF_GC = 1200, IF_GC = 1100, BB_GC = 300; | ||
502 | u32 PGA2_GC = 300, TIA_GC = 300, PGA2_cri = 0, PGA2_crf = 0; | ||
503 | u32 RFG = 0, IFG = 0, BBG = 0, PGA2G = 0, TIAG = 0; | ||
504 | u32 RFGS[13] = {0, 245, 266, 268, 270, 285, | ||
505 | 298, 295, 283, 285, 285, 300, 300}; | ||
506 | u32 IFGS[12] = {0, 300, 230, 270, 270, 285, | ||
507 | 295, 285, 290, 295, 295, 310}; | ||
508 | u32 BBGS[14] = {0, 286, 275, 290, 294, 300, 290, | ||
509 | 290, 285, 283, 260, 295, 290, 260}; | ||
510 | |||
511 | ret = regmap_read(dev->regmap, 0x5A, &val); | ||
512 | if (ret) | ||
513 | goto err; | ||
514 | RF_GC = val & 0x0f; | ||
515 | |||
516 | ret = regmap_read(dev->regmap, 0x5F, &val); | ||
517 | if (ret) | ||
518 | goto err; | ||
519 | IF_GC = val & 0x0f; | ||
520 | |||
521 | ret = regmap_read(dev->regmap, 0x3F, &val); | ||
522 | if (ret) | ||
523 | goto err; | ||
524 | TIA_GC = (val >> 4) & 0x07; | ||
525 | |||
526 | ret = regmap_read(dev->regmap, 0x77, &val); | ||
527 | if (ret) | ||
528 | goto err; | ||
529 | BB_GC = (val >> 4) & 0x0f; | ||
530 | |||
531 | ret = regmap_read(dev->regmap, 0x76, &val); | ||
532 | if (ret) | ||
533 | goto err; | ||
534 | PGA2_GC = val & 0x3f; | ||
535 | PGA2_cri = PGA2_GC >> 2; | ||
536 | PGA2_crf = PGA2_GC & 0x03; | ||
537 | |||
538 | for (i = 0; i <= RF_GC; i++) | ||
539 | RFG += RFGS[i]; | ||
540 | |||
541 | if (RF_GC == 0) | ||
542 | RFG += 400; | ||
543 | if (RF_GC == 1) | ||
544 | RFG += 300; | ||
545 | if (RF_GC == 2) | ||
546 | RFG += 200; | ||
547 | if (RF_GC == 3) | ||
548 | RFG += 100; | ||
549 | |||
550 | for (i = 0; i <= IF_GC; i++) | ||
551 | IFG += IFGS[i]; | ||
552 | |||
553 | TIAG = TIA_GC * TIA_GS; | ||
554 | |||
555 | for (i = 0; i <= BB_GC; i++) | ||
556 | BBG += BBGS[i]; | ||
557 | |||
558 | PGA2G = PGA2_cri * PGA2_cri_GS + PGA2_crf * PGA2_crf_GS; | ||
559 | |||
560 | gain = RFG + IFG - TIAG + BBG + PGA2G; | ||
561 | |||
562 | /* scale value to 0x0000-0xffff */ | ||
563 | gain = clamp_val(gain, 1000U, 10500U); | ||
564 | *strength = (10500 - gain) * 0xffff / (10500 - 1000); | ||
565 | err: | ||
566 | if (ret) | ||
567 | dev_dbg(&dev->client->dev, "failed=%d\n", ret); | ||
568 | return ret; | ||
569 | } | ||
570 | |||
571 | static const struct dvb_tuner_ops m88rs6000t_tuner_ops = { | ||
572 | .info = { | ||
573 | .name = "Montage M88RS6000 Internal Tuner", | ||
574 | .frequency_min = 950000, | ||
575 | .frequency_max = 2150000, | ||
576 | }, | ||
577 | |||
578 | .init = m88rs6000t_init, | ||
579 | .sleep = m88rs6000t_sleep, | ||
580 | .set_params = m88rs6000t_set_params, | ||
581 | .get_frequency = m88rs6000t_get_frequency, | ||
582 | .get_if_frequency = m88rs6000t_get_if_frequency, | ||
583 | .get_rf_strength = m88rs6000t_get_rf_strength, | ||
584 | }; | ||
585 | |||
586 | static int m88rs6000t_probe(struct i2c_client *client, | ||
587 | const struct i2c_device_id *id) | ||
588 | { | ||
589 | struct m88rs6000t_config *cfg = client->dev.platform_data; | ||
590 | struct dvb_frontend *fe = cfg->fe; | ||
591 | struct m88rs6000t_dev *dev; | ||
592 | int ret, i; | ||
593 | unsigned int utmp; | ||
594 | static const struct regmap_config regmap_config = { | ||
595 | .reg_bits = 8, | ||
596 | .val_bits = 8, | ||
597 | }; | ||
598 | static const struct m88rs6000t_reg_val reg_vals[] = { | ||
599 | {0x10, 0xfb}, | ||
600 | {0x24, 0x38}, | ||
601 | {0x11, 0x0a}, | ||
602 | {0x12, 0x00}, | ||
603 | {0x2b, 0x1c}, | ||
604 | {0x44, 0x48}, | ||
605 | {0x54, 0x24}, | ||
606 | {0x55, 0x06}, | ||
607 | {0x59, 0x00}, | ||
608 | {0x5b, 0x4c}, | ||
609 | {0x60, 0x8b}, | ||
610 | {0x61, 0xf4}, | ||
611 | {0x65, 0x07}, | ||
612 | {0x6d, 0x6f}, | ||
613 | {0x6e, 0x31}, | ||
614 | {0x3c, 0xf3}, | ||
615 | {0x37, 0x0f}, | ||
616 | {0x48, 0x28}, | ||
617 | {0x49, 0xd8}, | ||
618 | {0x70, 0x66}, | ||
619 | {0x71, 0xCF}, | ||
620 | {0x72, 0x81}, | ||
621 | {0x73, 0xA7}, | ||
622 | {0x74, 0x4F}, | ||
623 | {0x75, 0xFC}, | ||
624 | }; | ||
625 | |||
626 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
627 | if (!dev) { | ||
628 | ret = -ENOMEM; | ||
629 | dev_err(&client->dev, "kzalloc() failed\n"); | ||
630 | goto err; | ||
631 | } | ||
632 | |||
633 | memcpy(&dev->cfg, cfg, sizeof(struct m88rs6000t_config)); | ||
634 | dev->client = client; | ||
635 | dev->regmap = devm_regmap_init_i2c(client, ®map_config); | ||
636 | if (IS_ERR(dev->regmap)) { | ||
637 | ret = PTR_ERR(dev->regmap); | ||
638 | goto err; | ||
639 | } | ||
640 | |||
641 | ret = regmap_update_bits(dev->regmap, 0x11, 0x08, 0x08); | ||
642 | if (ret) | ||
643 | goto err; | ||
644 | usleep_range(5000, 50000); | ||
645 | ret = regmap_update_bits(dev->regmap, 0x10, 0x01, 0x01); | ||
646 | if (ret) | ||
647 | goto err; | ||
648 | usleep_range(10000, 50000); | ||
649 | ret = regmap_write(dev->regmap, 0x07, 0x7d); | ||
650 | if (ret) | ||
651 | goto err; | ||
652 | ret = regmap_write(dev->regmap, 0x04, 0x01); | ||
653 | if (ret) | ||
654 | goto err; | ||
655 | |||
656 | /* check tuner chip id */ | ||
657 | ret = regmap_read(dev->regmap, 0x01, &utmp); | ||
658 | if (ret) | ||
659 | goto err; | ||
660 | dev_info(&dev->client->dev, "chip_id=%02x\n", utmp); | ||
661 | if (utmp != 0x64) { | ||
662 | ret = -ENODEV; | ||
663 | goto err; | ||
664 | } | ||
665 | |||
666 | /* tuner init. */ | ||
667 | ret = regmap_write(dev->regmap, 0x05, 0x40); | ||
668 | if (ret) | ||
669 | goto err; | ||
670 | ret = regmap_write(dev->regmap, 0x11, 0x08); | ||
671 | if (ret) | ||
672 | goto err; | ||
673 | ret = regmap_write(dev->regmap, 0x15, 0x6c); | ||
674 | if (ret) | ||
675 | goto err; | ||
676 | ret = regmap_write(dev->regmap, 0x17, 0xc1); | ||
677 | if (ret) | ||
678 | goto err; | ||
679 | ret = regmap_write(dev->regmap, 0x17, 0x81); | ||
680 | if (ret) | ||
681 | goto err; | ||
682 | usleep_range(10000, 50000); | ||
683 | ret = regmap_write(dev->regmap, 0x05, 0x00); | ||
684 | if (ret) | ||
685 | goto err; | ||
686 | ret = regmap_write(dev->regmap, 0x11, 0x0a); | ||
687 | if (ret) | ||
688 | goto err; | ||
689 | |||
690 | for (i = 0; i < ARRAY_SIZE(reg_vals); i++) { | ||
691 | ret = regmap_write(dev->regmap, | ||
692 | reg_vals[i].reg, reg_vals[i].val); | ||
693 | if (ret) | ||
694 | goto err; | ||
695 | } | ||
696 | |||
697 | dev_info(&dev->client->dev, "Montage M88RS6000 internal tuner successfully identified\n"); | ||
698 | |||
699 | fe->tuner_priv = dev; | ||
700 | memcpy(&fe->ops.tuner_ops, &m88rs6000t_tuner_ops, | ||
701 | sizeof(struct dvb_tuner_ops)); | ||
702 | i2c_set_clientdata(client, dev); | ||
703 | return 0; | ||
704 | err: | ||
705 | dev_dbg(&client->dev, "failed=%d\n", ret); | ||
706 | kfree(dev); | ||
707 | return ret; | ||
708 | } | ||
709 | |||
710 | static int m88rs6000t_remove(struct i2c_client *client) | ||
711 | { | ||
712 | struct m88rs6000t_dev *dev = i2c_get_clientdata(client); | ||
713 | struct dvb_frontend *fe = dev->cfg.fe; | ||
714 | |||
715 | dev_dbg(&client->dev, "\n"); | ||
716 | |||
717 | memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); | ||
718 | fe->tuner_priv = NULL; | ||
719 | kfree(dev); | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | static const struct i2c_device_id m88rs6000t_id[] = { | ||
725 | {"m88rs6000t", 0}, | ||
726 | {} | ||
727 | }; | ||
728 | MODULE_DEVICE_TABLE(i2c, m88rs6000t_id); | ||
729 | |||
730 | static struct i2c_driver m88rs6000t_driver = { | ||
731 | .driver = { | ||
732 | .owner = THIS_MODULE, | ||
733 | .name = "m88rs6000t", | ||
734 | }, | ||
735 | .probe = m88rs6000t_probe, | ||
736 | .remove = m88rs6000t_remove, | ||
737 | .id_table = m88rs6000t_id, | ||
738 | }; | ||
739 | |||
740 | module_i2c_driver(m88rs6000t_driver); | ||
741 | |||
742 | MODULE_AUTHOR("Max nibble <nibble.max@gmail.com>"); | ||
743 | MODULE_DESCRIPTION("Montage M88RS6000 internal tuner driver"); | ||
744 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/tuners/m88rs6000t.h b/drivers/media/tuners/m88rs6000t.h new file mode 100644 index 000000000000..264c13e2cd39 --- /dev/null +++ b/drivers/media/tuners/m88rs6000t.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Driver for the internal tuner of Montage M88RS6000 | ||
3 | * | ||
4 | * Copyright (C) 2014 Max nibble <nibble.max@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef _M88RS6000T_H_ | ||
18 | #define _M88RS6000T_H_ | ||
19 | |||
20 | #include "dvb_frontend.h" | ||
21 | |||
22 | struct m88rs6000t_config { | ||
23 | /* | ||
24 | * pointer to DVB frontend | ||
25 | */ | ||
26 | struct dvb_frontend *fe; | ||
27 | }; | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c index caa542346891..066e5431da93 100644 --- a/drivers/media/tuners/m88ts2022.c +++ b/drivers/media/tuners/m88ts2022.c | |||
@@ -488,6 +488,7 @@ static int m88ts2022_probe(struct i2c_client *client, | |||
488 | case 0x83: | 488 | case 0x83: |
489 | break; | 489 | break; |
490 | default: | 490 | default: |
491 | ret = -ENODEV; | ||
491 | goto err; | 492 | goto err; |
492 | } | 493 | } |
493 | 494 | ||
@@ -505,6 +506,7 @@ static int m88ts2022_probe(struct i2c_client *client, | |||
505 | u8tmp = 0x6c; | 506 | u8tmp = 0x6c; |
506 | break; | 507 | break; |
507 | default: | 508 | default: |
509 | ret = -EINVAL; | ||
508 | goto err; | 510 | goto err; |
509 | } | 511 | } |
510 | 512 | ||
diff --git a/drivers/media/tuners/mxl5007t.c b/drivers/media/tuners/mxl5007t.c index 69e453ef0a1a..1810ad66888e 100644 --- a/drivers/media/tuners/mxl5007t.c +++ b/drivers/media/tuners/mxl5007t.c | |||
@@ -374,7 +374,6 @@ static struct reg_pair_t *mxl5007t_calc_init_regs(struct mxl5007t_state *state, | |||
374 | mxl5007t_set_if_freq_bits(state, cfg->if_freq_hz, cfg->invert_if); | 374 | mxl5007t_set_if_freq_bits(state, cfg->if_freq_hz, cfg->invert_if); |
375 | mxl5007t_set_xtal_freq_bits(state, cfg->xtal_freq_hz); | 375 | mxl5007t_set_xtal_freq_bits(state, cfg->xtal_freq_hz); |
376 | 376 | ||
377 | set_reg_bits(state->tab_init, 0x04, 0x01, cfg->loop_thru_enable); | ||
378 | set_reg_bits(state->tab_init, 0x03, 0x08, cfg->clk_out_enable << 3); | 377 | set_reg_bits(state->tab_init, 0x03, 0x08, cfg->clk_out_enable << 3); |
379 | set_reg_bits(state->tab_init, 0x03, 0x07, cfg->clk_out_amp); | 378 | set_reg_bits(state->tab_init, 0x03, 0x07, cfg->clk_out_amp); |
380 | 379 | ||
@@ -531,10 +530,6 @@ static int mxl5007t_tuner_init(struct mxl5007t_state *state, | |||
531 | struct reg_pair_t *init_regs; | 530 | struct reg_pair_t *init_regs; |
532 | int ret; | 531 | int ret; |
533 | 532 | ||
534 | ret = mxl5007t_soft_reset(state); | ||
535 | if (mxl_fail(ret)) | ||
536 | goto fail; | ||
537 | |||
538 | /* calculate initialization reg array */ | 533 | /* calculate initialization reg array */ |
539 | init_regs = mxl5007t_calc_init_regs(state, mode); | 534 | init_regs = mxl5007t_calc_init_regs(state, mode); |
540 | 535 | ||
@@ -900,7 +895,32 @@ struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe, | |||
900 | /* existing tuner instance */ | 895 | /* existing tuner instance */ |
901 | break; | 896 | break; |
902 | } | 897 | } |
898 | |||
899 | if (fe->ops.i2c_gate_ctrl) | ||
900 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
901 | |||
902 | ret = mxl5007t_soft_reset(state); | ||
903 | |||
904 | if (fe->ops.i2c_gate_ctrl) | ||
905 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
906 | |||
907 | if (mxl_fail(ret)) | ||
908 | goto fail; | ||
909 | |||
910 | if (fe->ops.i2c_gate_ctrl) | ||
911 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
912 | |||
913 | ret = mxl5007t_write_reg(state, 0x04, | ||
914 | state->config->loop_thru_enable); | ||
915 | |||
916 | if (fe->ops.i2c_gate_ctrl) | ||
917 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
918 | |||
919 | if (mxl_fail(ret)) | ||
920 | goto fail; | ||
921 | |||
903 | fe->tuner_priv = state; | 922 | fe->tuner_priv = state; |
923 | |||
904 | mutex_unlock(&mxl5007t_list_mutex); | 924 | mutex_unlock(&mxl5007t_list_mutex); |
905 | 925 | ||
906 | memcpy(&fe->ops.tuner_ops, &mxl5007t_tuner_ops, | 926 | memcpy(&fe->ops.tuner_ops, &mxl5007t_tuner_ops, |
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index a759742cae7b..8e040cf9cf13 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c | |||
@@ -959,6 +959,18 @@ static int r820t_set_tv_standard(struct r820t_priv *priv, | |||
959 | lt_att = 0x00; /* r31[7], lt att enable */ | 959 | lt_att = 0x00; /* r31[7], lt att enable */ |
960 | flt_ext_widest = 0x00; /* r15[7]: flt_ext_wide off */ | 960 | flt_ext_widest = 0x00; /* r15[7]: flt_ext_wide off */ |
961 | polyfil_cur = 0x60; /* r25[6:5]:min */ | 961 | polyfil_cur = 0x60; /* r25[6:5]:min */ |
962 | } else if (delsys == SYS_DVBC_ANNEX_A) { | ||
963 | if_khz = 5070; | ||
964 | filt_cal_lo = 73500; | ||
965 | filt_gain = 0x10; /* +3db, 6mhz on */ | ||
966 | img_r = 0x00; /* image negative */ | ||
967 | filt_q = 0x10; /* r10[4]:low q(1'b1) */ | ||
968 | hp_cor = 0x0b; /* 1.7m disable, +0cap, 1.0mhz */ | ||
969 | ext_enable = 0x40; /* r30[6]=1 ext enable; r30[5]:1 ext at lna max-1 */ | ||
970 | loop_through = 0x00; /* r5[7], lt on */ | ||
971 | lt_att = 0x00; /* r31[7], lt att enable */ | ||
972 | flt_ext_widest = 0x00; /* r15[7]: flt_ext_wide off */ | ||
973 | polyfil_cur = 0x60; /* r25[6:5]:min */ | ||
962 | } else { | 974 | } else { |
963 | if (bw <= 6) { | 975 | if (bw <= 6) { |
964 | if_khz = 3570; | 976 | if_khz = 3570; |
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index cf97142e01e6..2180de9d654a 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Silicon Labs Si2147/2157/2158 silicon tuner driver | 2 | * Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver |
3 | * | 3 | * |
4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> |
5 | * | 5 | * |
@@ -93,8 +93,13 @@ static int si2157_init(struct dvb_frontend *fe) | |||
93 | goto warm; | 93 | goto warm; |
94 | 94 | ||
95 | /* power up */ | 95 | /* power up */ |
96 | memcpy(cmd.args, "\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15); | 96 | if (s->chiptype == SI2157_CHIPTYPE_SI2146) { |
97 | cmd.wlen = 15; | 97 | memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9); |
98 | cmd.wlen = 9; | ||
99 | } else { | ||
100 | memcpy(cmd.args, "\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15); | ||
101 | cmd.wlen = 15; | ||
102 | } | ||
98 | cmd.rlen = 1; | 103 | cmd.rlen = 1; |
99 | ret = si2157_cmd_execute(s, &cmd); | 104 | ret = si2157_cmd_execute(s, &cmd); |
100 | if (ret) | 105 | if (ret) |
@@ -112,17 +117,20 @@ static int si2157_init(struct dvb_frontend *fe) | |||
112 | cmd.args[4] << 0; | 117 | cmd.args[4] << 0; |
113 | 118 | ||
114 | #define SI2158_A20 ('A' << 24 | 58 << 16 | '2' << 8 | '0' << 0) | 119 | #define SI2158_A20 ('A' << 24 | 58 << 16 | '2' << 8 | '0' << 0) |
120 | #define SI2148_A20 ('A' << 24 | 48 << 16 | '2' << 8 | '0' << 0) | ||
115 | #define SI2157_A30 ('A' << 24 | 57 << 16 | '3' << 8 | '0' << 0) | 121 | #define SI2157_A30 ('A' << 24 | 57 << 16 | '3' << 8 | '0' << 0) |
116 | #define SI2147_A30 ('A' << 24 | 47 << 16 | '3' << 8 | '0' << 0) | 122 | #define SI2147_A30 ('A' << 24 | 47 << 16 | '3' << 8 | '0' << 0) |
123 | #define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0) | ||
117 | 124 | ||
118 | switch (chip_id) { | 125 | switch (chip_id) { |
119 | case SI2158_A20: | 126 | case SI2158_A20: |
127 | case SI2148_A20: | ||
120 | fw_file = SI2158_A20_FIRMWARE; | 128 | fw_file = SI2158_A20_FIRMWARE; |
121 | break; | 129 | break; |
122 | case SI2157_A30: | 130 | case SI2157_A30: |
123 | case SI2147_A30: | 131 | case SI2147_A30: |
132 | case SI2146_A10: | ||
124 | goto skip_fw_download; | 133 | goto skip_fw_download; |
125 | break; | ||
126 | default: | 134 | default: |
127 | dev_err(&s->client->dev, | 135 | dev_err(&s->client->dev, |
128 | "unknown chip version Si21%d-%c%c%c\n", | 136 | "unknown chip version Si21%d-%c%c%c\n", |
@@ -149,7 +157,7 @@ static int si2157_init(struct dvb_frontend *fe) | |||
149 | dev_err(&s->client->dev, "firmware file '%s' is invalid\n", | 157 | dev_err(&s->client->dev, "firmware file '%s' is invalid\n", |
150 | fw_file); | 158 | fw_file); |
151 | ret = -EINVAL; | 159 | ret = -EINVAL; |
152 | goto err; | 160 | goto fw_release_exit; |
153 | } | 161 | } |
154 | 162 | ||
155 | dev_info(&s->client->dev, "downloading firmware from file '%s'\n", | 163 | dev_info(&s->client->dev, "downloading firmware from file '%s'\n", |
@@ -165,7 +173,7 @@ static int si2157_init(struct dvb_frontend *fe) | |||
165 | dev_err(&s->client->dev, | 173 | dev_err(&s->client->dev, |
166 | "firmware download failed=%d\n", | 174 | "firmware download failed=%d\n", |
167 | ret); | 175 | ret); |
168 | goto err; | 176 | goto fw_release_exit; |
169 | } | 177 | } |
170 | } | 178 | } |
171 | 179 | ||
@@ -187,10 +195,9 @@ warm: | |||
187 | s->active = true; | 195 | s->active = true; |
188 | return 0; | 196 | return 0; |
189 | 197 | ||
198 | fw_release_exit: | ||
199 | release_firmware(fw); | ||
190 | err: | 200 | err: |
191 | if (fw) | ||
192 | release_firmware(fw); | ||
193 | |||
194 | dev_dbg(&s->client->dev, "failed=%d\n", ret); | 201 | dev_dbg(&s->client->dev, "failed=%d\n", ret); |
195 | return ret; | 202 | return ret; |
196 | } | 203 | } |
@@ -250,6 +257,9 @@ static int si2157_set_params(struct dvb_frontend *fe) | |||
250 | case SYS_ATSC: | 257 | case SYS_ATSC: |
251 | delivery_system = 0x00; | 258 | delivery_system = 0x00; |
252 | break; | 259 | break; |
260 | case SYS_DVBC_ANNEX_B: | ||
261 | delivery_system = 0x10; | ||
262 | break; | ||
253 | case SYS_DVBT: | 263 | case SYS_DVBT: |
254 | case SYS_DVBT2: /* it seems DVB-T and DVB-T2 both are 0x20 here */ | 264 | case SYS_DVBT2: /* it seems DVB-T and DVB-T2 both are 0x20 here */ |
255 | delivery_system = 0x20; | 265 | delivery_system = 0x20; |
@@ -272,7 +282,10 @@ static int si2157_set_params(struct dvb_frontend *fe) | |||
272 | if (ret) | 282 | if (ret) |
273 | goto err; | 283 | goto err; |
274 | 284 | ||
275 | memcpy(cmd.args, "\x14\x00\x02\x07\x01\x00", 6); | 285 | if (s->chiptype == SI2157_CHIPTYPE_SI2146) |
286 | memcpy(cmd.args, "\x14\x00\x02\x07\x00\x01", 6); | ||
287 | else | ||
288 | memcpy(cmd.args, "\x14\x00\x02\x07\x01\x00", 6); | ||
276 | cmd.wlen = 6; | 289 | cmd.wlen = 6; |
277 | cmd.rlen = 4; | 290 | cmd.rlen = 4; |
278 | ret = si2157_cmd_execute(s, &cmd); | 291 | ret = si2157_cmd_execute(s, &cmd); |
@@ -305,7 +318,7 @@ static int si2157_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) | |||
305 | 318 | ||
306 | static const struct dvb_tuner_ops si2157_ops = { | 319 | static const struct dvb_tuner_ops si2157_ops = { |
307 | .info = { | 320 | .info = { |
308 | .name = "Silicon Labs Si2157/Si2158", | 321 | .name = "Silicon Labs Si2146/2147/2148/2157/2158", |
309 | .frequency_min = 110000000, | 322 | .frequency_min = 110000000, |
310 | .frequency_max = 862000000, | 323 | .frequency_max = 862000000, |
311 | }, | 324 | }, |
@@ -336,6 +349,7 @@ static int si2157_probe(struct i2c_client *client, | |||
336 | s->fe = cfg->fe; | 349 | s->fe = cfg->fe; |
337 | s->inversion = cfg->inversion; | 350 | s->inversion = cfg->inversion; |
338 | s->fw_loaded = false; | 351 | s->fw_loaded = false; |
352 | s->chiptype = (u8)id->driver_data; | ||
339 | mutex_init(&s->i2c_mutex); | 353 | mutex_init(&s->i2c_mutex); |
340 | 354 | ||
341 | /* check if the tuner is there */ | 355 | /* check if the tuner is there */ |
@@ -352,7 +366,10 @@ static int si2157_probe(struct i2c_client *client, | |||
352 | i2c_set_clientdata(client, s); | 366 | i2c_set_clientdata(client, s); |
353 | 367 | ||
354 | dev_info(&s->client->dev, | 368 | dev_info(&s->client->dev, |
355 | "Silicon Labs Si2157/Si2158 successfully attached\n"); | 369 | "Silicon Labs %s successfully attached\n", |
370 | s->chiptype == SI2157_CHIPTYPE_SI2146 ? | ||
371 | "Si2146" : "Si2147/2148/2157/2158"); | ||
372 | |||
356 | return 0; | 373 | return 0; |
357 | err: | 374 | err: |
358 | dev_dbg(&client->dev, "failed=%d\n", ret); | 375 | dev_dbg(&client->dev, "failed=%d\n", ret); |
@@ -377,6 +394,7 @@ static int si2157_remove(struct i2c_client *client) | |||
377 | 394 | ||
378 | static const struct i2c_device_id si2157_id[] = { | 395 | static const struct i2c_device_id si2157_id[] = { |
379 | {"si2157", 0}, | 396 | {"si2157", 0}, |
397 | {"si2146", 1}, | ||
380 | {} | 398 | {} |
381 | }; | 399 | }; |
382 | MODULE_DEVICE_TABLE(i2c, si2157_id); | 400 | MODULE_DEVICE_TABLE(i2c, si2157_id); |
@@ -393,7 +411,7 @@ static struct i2c_driver si2157_driver = { | |||
393 | 411 | ||
394 | module_i2c_driver(si2157_driver); | 412 | module_i2c_driver(si2157_driver); |
395 | 413 | ||
396 | MODULE_DESCRIPTION("Silicon Labs Si2157/Si2158 silicon tuner driver"); | 414 | MODULE_DESCRIPTION("Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver"); |
397 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | 415 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
398 | MODULE_LICENSE("GPL"); | 416 | MODULE_LICENSE("GPL"); |
399 | MODULE_FIRMWARE(SI2158_A20_FIRMWARE); | 417 | MODULE_FIRMWARE(SI2158_A20_FIRMWARE); |
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h index d3b19cadb4a1..a564c4a9fba7 100644 --- a/drivers/media/tuners/si2157.h +++ b/drivers/media/tuners/si2157.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Silicon Labs Si2147/2157/2158 silicon tuner driver | 2 | * Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver |
3 | * | 3 | * |
4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> |
5 | * | 5 | * |
diff --git a/drivers/media/tuners/si2157_priv.h b/drivers/media/tuners/si2157_priv.h index e71ffafed951..d6e07cdd2a07 100644 --- a/drivers/media/tuners/si2157_priv.h +++ b/drivers/media/tuners/si2157_priv.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Silicon Labs Si2147/2157/2158 silicon tuner driver | 2 | * Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver |
3 | * | 3 | * |
4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> |
5 | * | 5 | * |
@@ -28,9 +28,13 @@ struct si2157 { | |||
28 | bool active; | 28 | bool active; |
29 | bool fw_loaded; | 29 | bool fw_loaded; |
30 | bool inversion; | 30 | bool inversion; |
31 | u8 chiptype; | ||
31 | }; | 32 | }; |
32 | 33 | ||
33 | /* firmare command struct */ | 34 | #define SI2157_CHIPTYPE_SI2157 0 |
35 | #define SI2157_CHIPTYPE_SI2146 1 | ||
36 | |||
37 | /* firmware command struct */ | ||
34 | #define SI2157_ARGLEN 30 | 38 | #define SI2157_ARGLEN 30 |
35 | struct si2157_cmd { | 39 | struct si2157_cmd { |
36 | u8 args[SI2157_ARGLEN]; | 40 | u8 args[SI2157_ARGLEN]; |
diff --git a/drivers/media/tuners/tda18271-common.c b/drivers/media/tuners/tda18271-common.c index 86e5e3110118..a26bb33102b8 100644 --- a/drivers/media/tuners/tda18271-common.c +++ b/drivers/media/tuners/tda18271-common.c | |||
@@ -178,7 +178,7 @@ int tda18271_read_extended(struct dvb_frontend *fe) | |||
178 | (i != R_EB17) && | 178 | (i != R_EB17) && |
179 | (i != R_EB19) && | 179 | (i != R_EB19) && |
180 | (i != R_EB20)) | 180 | (i != R_EB20)) |
181 | regs[i] = regdump[i]; | 181 | regs[i] = regdump[i]; |
182 | } | 182 | } |
183 | 183 | ||
184 | if (tda18271_debug & DBG_REG) | 184 | if (tda18271_debug & DBG_REG) |
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c index 803a0e63d47e..2a039de8ab9a 100644 --- a/drivers/media/tuners/xc5000.c +++ b/drivers/media/tuners/xc5000.c | |||
@@ -62,6 +62,7 @@ struct xc5000_priv { | |||
62 | unsigned int mode; | 62 | unsigned int mode; |
63 | u8 rf_mode; | 63 | u8 rf_mode; |
64 | u8 radio_input; | 64 | u8 radio_input; |
65 | u16 output_amp; | ||
65 | 66 | ||
66 | int chip_id; | 67 | int chip_id; |
67 | u16 pll_register_no; | 68 | u16 pll_register_no; |
@@ -744,7 +745,9 @@ static int xc5000_tune_digital(struct dvb_frontend *fe) | |||
744 | return -EIO; | 745 | return -EIO; |
745 | } | 746 | } |
746 | 747 | ||
747 | xc_write_reg(priv, XREG_OUTPUT_AMP, 0x8a); | 748 | dprintk(1, "%s() setting OUTPUT_AMP to 0x%x\n", |
749 | __func__, priv->output_amp); | ||
750 | xc_write_reg(priv, XREG_OUTPUT_AMP, priv->output_amp); | ||
748 | 751 | ||
749 | xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL); | 752 | xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL); |
750 | 753 | ||
@@ -1333,8 +1336,7 @@ static int xc5000_release(struct dvb_frontend *fe) | |||
1333 | 1336 | ||
1334 | if (priv) { | 1337 | if (priv) { |
1335 | cancel_delayed_work(&priv->timer_sleep); | 1338 | cancel_delayed_work(&priv->timer_sleep); |
1336 | if (priv->firmware) | 1339 | release_firmware(priv->firmware); |
1337 | release_firmware(priv->firmware); | ||
1338 | hybrid_tuner_release_state(priv); | 1340 | hybrid_tuner_release_state(priv); |
1339 | } | 1341 | } |
1340 | 1342 | ||
@@ -1358,6 +1360,9 @@ static int xc5000_set_config(struct dvb_frontend *fe, void *priv_cfg) | |||
1358 | if (p->radio_input) | 1360 | if (p->radio_input) |
1359 | priv->radio_input = p->radio_input; | 1361 | priv->radio_input = p->radio_input; |
1360 | 1362 | ||
1363 | if (p->output_amp) | ||
1364 | priv->output_amp = p->output_amp; | ||
1365 | |||
1361 | return 0; | 1366 | return 0; |
1362 | } | 1367 | } |
1363 | 1368 | ||
@@ -1438,6 +1443,12 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, | |||
1438 | it can be overridden if this is a hybrid driver */ | 1443 | it can be overridden if this is a hybrid driver */ |
1439 | priv->chip_id = (cfg->chip_id) ? cfg->chip_id : 0; | 1444 | priv->chip_id = (cfg->chip_id) ? cfg->chip_id : 0; |
1440 | 1445 | ||
1446 | /* don't override output_amp if it's already been set | ||
1447 | unless explicitly specified */ | ||
1448 | if ((priv->output_amp == 0) || (cfg->output_amp)) | ||
1449 | /* use default output_amp value if none specified */ | ||
1450 | priv->output_amp = (cfg->output_amp) ? cfg->output_amp : 0x8a; | ||
1451 | |||
1441 | /* Check if firmware has been loaded. It is possible that another | 1452 | /* Check if firmware has been loaded. It is possible that another |
1442 | instance of the driver has loaded the firmware. | 1453 | instance of the driver has loaded the firmware. |
1443 | */ | 1454 | */ |
diff --git a/drivers/media/tuners/xc5000.h b/drivers/media/tuners/xc5000.h index 7245cae19f0c..6aa534f17a30 100644 --- a/drivers/media/tuners/xc5000.h +++ b/drivers/media/tuners/xc5000.h | |||
@@ -36,6 +36,7 @@ struct xc5000_config { | |||
36 | u32 if_khz; | 36 | u32 if_khz; |
37 | u8 radio_input; | 37 | u8 radio_input; |
38 | u16 xtal_khz; | 38 | u16 xtal_khz; |
39 | u16 output_amp; | ||
39 | 40 | ||
40 | int chip_id; | 41 | int chip_id; |
41 | }; | 42 | }; |
diff --git a/drivers/media/usb/au0828/au0828-cards.c b/drivers/media/usb/au0828/au0828-cards.c index 9eb77ac2153b..da87f1cc31a9 100644 --- a/drivers/media/usb/au0828/au0828-cards.c +++ b/drivers/media/usb/au0828/au0828-cards.c | |||
@@ -36,6 +36,11 @@ static void hvr950q_cs5340_audio(void *priv, int enable) | |||
36 | au0828_clear(dev, REG_000, 0x10); | 36 | au0828_clear(dev, REG_000, 0x10); |
37 | } | 37 | } |
38 | 38 | ||
39 | /* | ||
40 | * WARNING: There's a quirks table at sound/usb/quirks-table.h | ||
41 | * that should also be updated every time a new device with V4L2 support | ||
42 | * is added here. | ||
43 | */ | ||
39 | struct au0828_board au0828_boards[] = { | 44 | struct au0828_board au0828_boards[] = { |
40 | [AU0828_BOARD_UNKNOWN] = { | 45 | [AU0828_BOARD_UNKNOWN] = { |
41 | .name = "Unknown board", | 46 | .name = "Unknown board", |
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index bc064803b6c7..082ae6ba492f 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c | |||
@@ -153,6 +153,14 @@ static void au0828_usb_disconnect(struct usb_interface *interface) | |||
153 | 153 | ||
154 | dprintk(1, "%s()\n", __func__); | 154 | dprintk(1, "%s()\n", __func__); |
155 | 155 | ||
156 | /* there is a small window after disconnect, before | ||
157 | dev->usbdev is NULL, for poll (e.g: IR) try to access | ||
158 | the device and fill the dmesg with error messages. | ||
159 | Set the status so poll routines can check and avoid | ||
160 | access after disconnect. | ||
161 | */ | ||
162 | dev->dev_state = DEV_DISCONNECTED; | ||
163 | |||
156 | au0828_rc_unregister(dev); | 164 | au0828_rc_unregister(dev); |
157 | /* Digital TV */ | 165 | /* Digital TV */ |
158 | au0828_dvb_unregister(dev); | 166 | au0828_dvb_unregister(dev); |
diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c index 00ab1563d142..c267d76f5b3c 100644 --- a/drivers/media/usb/au0828/au0828-dvb.c +++ b/drivers/media/usb/au0828/au0828-dvb.c | |||
@@ -88,12 +88,14 @@ static struct xc5000_config hauppauge_xc5000a_config = { | |||
88 | .i2c_address = 0x61, | 88 | .i2c_address = 0x61, |
89 | .if_khz = 6000, | 89 | .if_khz = 6000, |
90 | .chip_id = XC5000A, | 90 | .chip_id = XC5000A, |
91 | .output_amp = 0x8f, | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | static struct xc5000_config hauppauge_xc5000c_config = { | 94 | static struct xc5000_config hauppauge_xc5000c_config = { |
94 | .i2c_address = 0x61, | 95 | .i2c_address = 0x61, |
95 | .if_khz = 6000, | 96 | .if_khz = 6000, |
96 | .chip_id = XC5000C, | 97 | .chip_id = XC5000C, |
98 | .output_amp = 0x8f, | ||
97 | }; | 99 | }; |
98 | 100 | ||
99 | static struct mxl5007t_config mxl5007t_hvr950q_config = { | 101 | static struct mxl5007t_config mxl5007t_hvr950q_config = { |
diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c index 63995f97dc65..b0f067971979 100644 --- a/drivers/media/usb/au0828/au0828-input.c +++ b/drivers/media/usb/au0828/au0828-input.c | |||
@@ -129,6 +129,10 @@ static int au0828_get_key_au8522(struct au0828_rc *ir) | |||
129 | int prv_bit, bit, width; | 129 | int prv_bit, bit, width; |
130 | bool first = true; | 130 | bool first = true; |
131 | 131 | ||
132 | /* do nothing if device is disconnected */ | ||
133 | if (ir->dev->dev_state == DEV_DISCONNECTED) | ||
134 | return 0; | ||
135 | |||
132 | /* Check IR int */ | 136 | /* Check IR int */ |
133 | rc = au8522_rc_read(ir, 0xe1, -1, buf, 1); | 137 | rc = au8522_rc_read(ir, 0xe1, -1, buf, 1); |
134 | if (rc < 0 || !(buf[0] & (1 << 4))) { | 138 | if (rc < 0 || !(buf[0] & (1 << 4))) { |
@@ -255,8 +259,11 @@ static void au0828_rc_stop(struct rc_dev *rc) | |||
255 | 259 | ||
256 | cancel_delayed_work_sync(&ir->work); | 260 | cancel_delayed_work_sync(&ir->work); |
257 | 261 | ||
258 | /* Disable IR */ | 262 | /* do nothing if device is disconnected */ |
259 | au8522_rc_clear(ir, 0xe0, 1 << 4); | 263 | if (ir->dev->dev_state != DEV_DISCONNECTED) { |
264 | /* Disable IR */ | ||
265 | au8522_rc_clear(ir, 0xe0, 1 << 4); | ||
266 | } | ||
260 | } | 267 | } |
261 | 268 | ||
262 | static int au0828_probe_i2c_ir(struct au0828_dev *dev) | 269 | static int au0828_probe_i2c_ir(struct au0828_dev *dev) |
@@ -363,8 +370,7 @@ void au0828_rc_unregister(struct au0828_dev *dev) | |||
363 | if (!ir) | 370 | if (!ir) |
364 | return; | 371 | return; |
365 | 372 | ||
366 | if (ir->rc) | 373 | rc_unregister_device(ir->rc); |
367 | rc_unregister_device(ir->rc); | ||
368 | 374 | ||
369 | /* done */ | 375 | /* done */ |
370 | kfree(ir); | 376 | kfree(ir); |
diff --git a/drivers/media/usb/cx231xx/Kconfig b/drivers/media/usb/cx231xx/Kconfig index 569aa298c03f..173c0e287a08 100644 --- a/drivers/media/usb/cx231xx/Kconfig +++ b/drivers/media/usb/cx231xx/Kconfig | |||
@@ -7,6 +7,7 @@ config VIDEO_CX231XX | |||
7 | select VIDEOBUF_VMALLOC | 7 | select VIDEOBUF_VMALLOC |
8 | select VIDEO_CX25840 | 8 | select VIDEO_CX25840 |
9 | select VIDEO_CX2341X | 9 | select VIDEO_CX2341X |
10 | select I2C_MUX | ||
10 | 11 | ||
11 | ---help--- | 12 | ---help--- |
12 | This is a video4linux driver for Conexant 231xx USB based TV cards. | 13 | This is a video4linux driver for Conexant 231xx USB based TV cards. |
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index 459bb0e98971..3f295b4d1a3d 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c | |||
@@ -24,6 +24,8 @@ | |||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "cx231xx.h" | ||
28 | |||
27 | #include <linux/module.h> | 29 | #include <linux/module.h> |
28 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
29 | #include <linux/init.h> | 31 | #include <linux/init.h> |
@@ -37,9 +39,6 @@ | |||
37 | #include <media/v4l2-event.h> | 39 | #include <media/v4l2-event.h> |
38 | #include <media/cx2341x.h> | 40 | #include <media/cx2341x.h> |
39 | #include <media/tuner.h> | 41 | #include <media/tuner.h> |
40 | #include <linux/usb.h> | ||
41 | |||
42 | #include "cx231xx.h" | ||
43 | 42 | ||
44 | #define CX231xx_FIRM_IMAGE_SIZE 376836 | 43 | #define CX231xx_FIRM_IMAGE_SIZE 376836 |
45 | #define CX231xx_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw" | 44 | #define CX231xx_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw" |
@@ -90,10 +89,10 @@ static unsigned int v4l_debug = 1; | |||
90 | module_param(v4l_debug, int, 0644); | 89 | module_param(v4l_debug, int, 0644); |
91 | MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages"); | 90 | MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages"); |
92 | 91 | ||
93 | #define dprintk(level, fmt, arg...)\ | 92 | #define dprintk(level, fmt, arg...) \ |
94 | do { if (v4l_debug >= level) \ | 93 | do { \ |
95 | pr_info("%s: " fmt, \ | 94 | if (v4l_debug >= level) \ |
96 | (dev) ? dev->name : "cx231xx[?]", ## arg); \ | 95 | printk(KERN_DEBUG pr_fmt(fmt), ## arg); \ |
97 | } while (0) | 96 | } while (0) |
98 | 97 | ||
99 | static struct cx231xx_tvnorm cx231xx_tvnorms[] = { | 98 | static struct cx231xx_tvnorm cx231xx_tvnorms[] = { |
@@ -988,29 +987,34 @@ static int cx231xx_load_firmware(struct cx231xx *dev) | |||
988 | IVTV_REG_APU, 0); | 987 | IVTV_REG_APU, 0); |
989 | 988 | ||
990 | if (retval != 0) { | 989 | if (retval != 0) { |
991 | pr_err("%s: Error with mc417_register_write\n", __func__); | 990 | dev_err(dev->dev, |
991 | "%s: Error with mc417_register_write\n", __func__); | ||
992 | return -1; | 992 | return -1; |
993 | } | 993 | } |
994 | 994 | ||
995 | retval = request_firmware(&firmware, CX231xx_FIRM_IMAGE_NAME, | 995 | retval = request_firmware(&firmware, CX231xx_FIRM_IMAGE_NAME, |
996 | &dev->udev->dev); | 996 | dev->dev); |
997 | 997 | ||
998 | if (retval != 0) { | 998 | if (retval != 0) { |
999 | pr_err("ERROR: Hotplug firmware request failed (%s).\n", | 999 | dev_err(dev->dev, |
1000 | "ERROR: Hotplug firmware request failed (%s).\n", | ||
1000 | CX231xx_FIRM_IMAGE_NAME); | 1001 | CX231xx_FIRM_IMAGE_NAME); |
1001 | pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n"); | 1002 | dev_err(dev->dev, |
1003 | "Please fix your hotplug setup, the board will not work without firmware loaded!\n"); | ||
1002 | return -1; | 1004 | return -1; |
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | if (firmware->size != CX231xx_FIRM_IMAGE_SIZE) { | 1007 | if (firmware->size != CX231xx_FIRM_IMAGE_SIZE) { |
1006 | pr_err("ERROR: Firmware size mismatch (have %zd, expected %d)\n", | 1008 | dev_err(dev->dev, |
1009 | "ERROR: Firmware size mismatch (have %zd, expected %d)\n", | ||
1007 | firmware->size, CX231xx_FIRM_IMAGE_SIZE); | 1010 | firmware->size, CX231xx_FIRM_IMAGE_SIZE); |
1008 | release_firmware(firmware); | 1011 | release_firmware(firmware); |
1009 | return -1; | 1012 | return -1; |
1010 | } | 1013 | } |
1011 | 1014 | ||
1012 | if (0 != memcmp(firmware->data, magic, 8)) { | 1015 | if (0 != memcmp(firmware->data, magic, 8)) { |
1013 | pr_err("ERROR: Firmware magic mismatch, wrong file?\n"); | 1016 | dev_err(dev->dev, |
1017 | "ERROR: Firmware magic mismatch, wrong file?\n"); | ||
1014 | release_firmware(firmware); | 1018 | release_firmware(firmware); |
1015 | return -1; | 1019 | return -1; |
1016 | } | 1020 | } |
@@ -1057,7 +1061,8 @@ static int cx231xx_load_firmware(struct cx231xx *dev) | |||
1057 | retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS, | 1061 | retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS, |
1058 | IVTV_CMD_HW_BLOCKS_RST); | 1062 | IVTV_CMD_HW_BLOCKS_RST); |
1059 | if (retval < 0) { | 1063 | if (retval < 0) { |
1060 | pr_err("%s: Error with mc417_register_write\n", | 1064 | dev_err(dev->dev, |
1065 | "%s: Error with mc417_register_write\n", | ||
1061 | __func__); | 1066 | __func__); |
1062 | return retval; | 1067 | return retval; |
1063 | } | 1068 | } |
@@ -1069,7 +1074,8 @@ static int cx231xx_load_firmware(struct cx231xx *dev) | |||
1069 | retval |= mc417_register_write(dev, IVTV_REG_VPU, value & 0xFFFFFFE8); | 1074 | retval |= mc417_register_write(dev, IVTV_REG_VPU, value & 0xFFFFFFE8); |
1070 | 1075 | ||
1071 | if (retval < 0) { | 1076 | if (retval < 0) { |
1072 | pr_err("%s: Error with mc417_register_write\n", | 1077 | dev_err(dev->dev, |
1078 | "%s: Error with mc417_register_write\n", | ||
1073 | __func__); | 1079 | __func__); |
1074 | return retval; | 1080 | return retval; |
1075 | } | 1081 | } |
@@ -1114,28 +1120,31 @@ static int cx231xx_initialize_codec(struct cx231xx *dev) | |||
1114 | cx231xx_disable656(dev); | 1120 | cx231xx_disable656(dev); |
1115 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ | 1121 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ |
1116 | if (retval < 0) { | 1122 | if (retval < 0) { |
1117 | dprintk(2, "%s() PING OK\n", __func__); | 1123 | dprintk(2, "%s: PING OK\n", __func__); |
1118 | retval = cx231xx_load_firmware(dev); | 1124 | retval = cx231xx_load_firmware(dev); |
1119 | if (retval < 0) { | 1125 | if (retval < 0) { |
1120 | pr_err("%s() f/w load failed\n", __func__); | 1126 | dev_err(dev->dev, |
1127 | "%s: f/w load failed\n", __func__); | ||
1121 | return retval; | 1128 | return retval; |
1122 | } | 1129 | } |
1123 | retval = cx231xx_find_mailbox(dev); | 1130 | retval = cx231xx_find_mailbox(dev); |
1124 | if (retval < 0) { | 1131 | if (retval < 0) { |
1125 | pr_err("%s() mailbox < 0, error\n", | 1132 | dev_err(dev->dev, "%s: mailbox < 0, error\n", |
1126 | __func__); | 1133 | __func__); |
1127 | return -1; | 1134 | return -1; |
1128 | } | 1135 | } |
1129 | dev->cx23417_mailbox = retval; | 1136 | dev->cx23417_mailbox = retval; |
1130 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); | 1137 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); |
1131 | if (retval < 0) { | 1138 | if (retval < 0) { |
1132 | pr_err("ERROR: cx23417 firmware ping failed!\n"); | 1139 | dev_err(dev->dev, |
1140 | "ERROR: cx23417 firmware ping failed!\n"); | ||
1133 | return -1; | 1141 | return -1; |
1134 | } | 1142 | } |
1135 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, | 1143 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, |
1136 | &version); | 1144 | &version); |
1137 | if (retval < 0) { | 1145 | if (retval < 0) { |
1138 | pr_err("ERROR: cx23417 firmware get encoder: version failed!\n"); | 1146 | dev_err(dev->dev, |
1147 | "ERROR: cx23417 firmware get encoder: version failed!\n"); | ||
1139 | return -1; | 1148 | return -1; |
1140 | } | 1149 | } |
1141 | dprintk(1, "cx23417 firmware version is 0x%08x\n", version); | 1150 | dprintk(1, "cx23417 firmware version is 0x%08x\n", version); |
@@ -1416,8 +1425,9 @@ static int bb_buf_prepare(struct videobuf_queue *q, | |||
1416 | if (!dev->video_mode.bulk_ctl.num_bufs) | 1425 | if (!dev->video_mode.bulk_ctl.num_bufs) |
1417 | urb_init = 1; | 1426 | urb_init = 1; |
1418 | } | 1427 | } |
1419 | /*cx231xx_info("urb_init=%d dev->video_mode.max_pkt_size=%d\n", | 1428 | dev_dbg(dev->dev, |
1420 | urb_init, dev->video_mode.max_pkt_size);*/ | 1429 | "urb_init=%d dev->video_mode.max_pkt_size=%d\n", |
1430 | urb_init, dev->video_mode.max_pkt_size); | ||
1421 | dev->mode_tv = 1; | 1431 | dev->mode_tv = 1; |
1422 | 1432 | ||
1423 | if (urb_init) { | 1433 | if (urb_init) { |
@@ -1688,7 +1698,7 @@ static int mpeg_open(struct file *file) | |||
1688 | sizeof(struct cx231xx_buffer), fh, &dev->lock); | 1698 | sizeof(struct cx231xx_buffer), fh, &dev->lock); |
1689 | /* | 1699 | /* |
1690 | videobuf_queue_sg_init(&fh->vidq, &cx231xx_qops, | 1700 | videobuf_queue_sg_init(&fh->vidq, &cx231xx_qops, |
1691 | &dev->udev->dev, &dev->ts1.slock, | 1701 | dev->dev, &dev->ts1.slock, |
1692 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1702 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1693 | V4L2_FIELD_INTERLACED, | 1703 | V4L2_FIELD_INTERLACED, |
1694 | sizeof(struct cx231xx_buffer), | 1704 | sizeof(struct cx231xx_buffer), |
@@ -1798,7 +1808,6 @@ static unsigned int mpeg_poll(struct file *file, | |||
1798 | static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) | 1808 | static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) |
1799 | { | 1809 | { |
1800 | struct cx231xx_fh *fh = file->private_data; | 1810 | struct cx231xx_fh *fh = file->private_data; |
1801 | struct cx231xx *dev = fh->dev; | ||
1802 | 1811 | ||
1803 | dprintk(2, "%s()\n", __func__); | 1812 | dprintk(2, "%s()\n", __func__); |
1804 | 1813 | ||
@@ -1878,7 +1887,7 @@ static int cx231xx_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val) | |||
1878 | /* fix videodecoder resolution */ | 1887 | /* fix videodecoder resolution */ |
1879 | fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); | 1888 | fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); |
1880 | fmt.height = cxhdl->height; | 1889 | fmt.height = cxhdl->height; |
1881 | fmt.code = V4L2_MBUS_FMT_FIXED; | 1890 | fmt.code = MEDIA_BUS_FMT_FIXED; |
1882 | v4l2_subdev_call(dev->sd_cx25840, video, s_mbus_fmt, &fmt); | 1891 | v4l2_subdev_call(dev->sd_cx25840, video, s_mbus_fmt, &fmt); |
1883 | return 0; | 1892 | return 0; |
1884 | } | 1893 | } |
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c index 9b925874d392..de4ae5eb4830 100644 --- a/drivers/media/usb/cx231xx/cx231xx-audio.c +++ b/drivers/media/usb/cx231xx/cx231xx-audio.c | |||
@@ -20,8 +20,8 @@ | |||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "cx231xx.h" | ||
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/usb.h> | ||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/sound.h> | 26 | #include <linux/sound.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
@@ -37,25 +37,18 @@ | |||
37 | #include <sound/initval.h> | 37 | #include <sound/initval.h> |
38 | #include <sound/control.h> | 38 | #include <sound/control.h> |
39 | #include <media/v4l2-common.h> | 39 | #include <media/v4l2-common.h> |
40 | #include "cx231xx.h" | ||
41 | 40 | ||
42 | static int debug; | 41 | static int debug; |
43 | module_param(debug, int, 0644); | 42 | module_param(debug, int, 0644); |
44 | MODULE_PARM_DESC(debug, "activates debug info"); | 43 | MODULE_PARM_DESC(debug, "activates debug info"); |
45 | 44 | ||
46 | #define dprintk(fmt, arg...) do { \ | ||
47 | if (debug) \ | ||
48 | printk(KERN_INFO "cx231xx-audio %s: " fmt, \ | ||
49 | __func__, ##arg); \ | ||
50 | } while (0) | ||
51 | |||
52 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 45 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
53 | 46 | ||
54 | static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) | 47 | static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) |
55 | { | 48 | { |
56 | int i; | 49 | int i; |
57 | 50 | ||
58 | dprintk("Stopping isoc\n"); | 51 | dev_dbg(dev->dev, "Stopping isoc\n"); |
59 | 52 | ||
60 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | 53 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { |
61 | if (dev->adev.urb[i]) { | 54 | if (dev->adev.urb[i]) { |
@@ -79,7 +72,7 @@ static int cx231xx_bulk_audio_deinit(struct cx231xx *dev) | |||
79 | { | 72 | { |
80 | int i; | 73 | int i; |
81 | 74 | ||
82 | dprintk("Stopping bulk\n"); | 75 | dev_dbg(dev->dev, "Stopping bulk\n"); |
83 | 76 | ||
84 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | 77 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { |
85 | if (dev->adev.urb[i]) { | 78 | if (dev->adev.urb[i]) { |
@@ -123,7 +116,8 @@ static void cx231xx_audio_isocirq(struct urb *urb) | |||
123 | case -ESHUTDOWN: | 116 | case -ESHUTDOWN: |
124 | return; | 117 | return; |
125 | default: /* error */ | 118 | default: /* error */ |
126 | dprintk("urb completition error %d.\n", urb->status); | 119 | dev_dbg(dev->dev, "urb completition error %d.\n", |
120 | urb->status); | ||
127 | break; | 121 | break; |
128 | } | 122 | } |
129 | 123 | ||
@@ -182,8 +176,9 @@ static void cx231xx_audio_isocirq(struct urb *urb) | |||
182 | 176 | ||
183 | status = usb_submit_urb(urb, GFP_ATOMIC); | 177 | status = usb_submit_urb(urb, GFP_ATOMIC); |
184 | if (status < 0) { | 178 | if (status < 0) { |
185 | cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", | 179 | dev_err(dev->dev, |
186 | status); | 180 | "resubmit of audio urb failed (error=%i)\n", |
181 | status); | ||
187 | } | 182 | } |
188 | return; | 183 | return; |
189 | } | 184 | } |
@@ -211,7 +206,8 @@ static void cx231xx_audio_bulkirq(struct urb *urb) | |||
211 | case -ESHUTDOWN: | 206 | case -ESHUTDOWN: |
212 | return; | 207 | return; |
213 | default: /* error */ | 208 | default: /* error */ |
214 | dprintk("urb completition error %d.\n", urb->status); | 209 | dev_dbg(dev->dev, "urb completition error %d.\n", |
210 | urb->status); | ||
215 | break; | 211 | break; |
216 | } | 212 | } |
217 | 213 | ||
@@ -266,8 +262,9 @@ static void cx231xx_audio_bulkirq(struct urb *urb) | |||
266 | 262 | ||
267 | status = usb_submit_urb(urb, GFP_ATOMIC); | 263 | status = usb_submit_urb(urb, GFP_ATOMIC); |
268 | if (status < 0) { | 264 | if (status < 0) { |
269 | cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", | 265 | dev_err(dev->dev, |
270 | status); | 266 | "resubmit of audio urb failed (error=%i)\n", |
267 | status); | ||
271 | } | 268 | } |
272 | return; | 269 | return; |
273 | } | 270 | } |
@@ -277,7 +274,8 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) | |||
277 | int i, errCode; | 274 | int i, errCode; |
278 | int sb_size; | 275 | int sb_size; |
279 | 276 | ||
280 | cx231xx_info("%s: Starting ISO AUDIO transfers\n", __func__); | 277 | dev_dbg(dev->dev, |
278 | "%s: Starting ISO AUDIO transfers\n", __func__); | ||
281 | 279 | ||
282 | if (dev->state & DEV_DISCONNECTED) | 280 | if (dev->state & DEV_DISCONNECTED) |
283 | return -ENODEV; | 281 | return -ENODEV; |
@@ -295,7 +293,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev) | |||
295 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); | 293 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); |
296 | urb = usb_alloc_urb(CX231XX_ISO_NUM_AUDIO_PACKETS, GFP_ATOMIC); | 294 | urb = usb_alloc_urb(CX231XX_ISO_NUM_AUDIO_PACKETS, GFP_ATOMIC); |
297 | if (!urb) { | 295 | if (!urb) { |
298 | cx231xx_errdev("usb_alloc_urb failed!\n"); | 296 | dev_err(dev->dev, "usb_alloc_urb failed!\n"); |
299 | for (j = 0; j < i; j++) { | 297 | for (j = 0; j < i; j++) { |
300 | usb_free_urb(dev->adev.urb[j]); | 298 | usb_free_urb(dev->adev.urb[j]); |
301 | kfree(dev->adev.transfer_buffer[j]); | 299 | kfree(dev->adev.transfer_buffer[j]); |
@@ -338,7 +336,8 @@ static int cx231xx_init_audio_bulk(struct cx231xx *dev) | |||
338 | int i, errCode; | 336 | int i, errCode; |
339 | int sb_size; | 337 | int sb_size; |
340 | 338 | ||
341 | cx231xx_info("%s: Starting BULK AUDIO transfers\n", __func__); | 339 | dev_dbg(dev->dev, |
340 | "%s: Starting BULK AUDIO transfers\n", __func__); | ||
342 | 341 | ||
343 | if (dev->state & DEV_DISCONNECTED) | 342 | if (dev->state & DEV_DISCONNECTED) |
344 | return -ENODEV; | 343 | return -ENODEV; |
@@ -356,7 +355,7 @@ static int cx231xx_init_audio_bulk(struct cx231xx *dev) | |||
356 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); | 355 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); |
357 | urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); | 356 | urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); |
358 | if (!urb) { | 357 | if (!urb) { |
359 | cx231xx_errdev("usb_alloc_urb failed!\n"); | 358 | dev_err(dev->dev, "usb_alloc_urb failed!\n"); |
360 | for (j = 0; j < i; j++) { | 359 | for (j = 0; j < i; j++) { |
361 | usb_free_urb(dev->adev.urb[j]); | 360 | usb_free_urb(dev->adev.urb[j]); |
362 | kfree(dev->adev.transfer_buffer[j]); | 361 | kfree(dev->adev.transfer_buffer[j]); |
@@ -392,8 +391,9 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, | |||
392 | size_t size) | 391 | size_t size) |
393 | { | 392 | { |
394 | struct snd_pcm_runtime *runtime = subs->runtime; | 393 | struct snd_pcm_runtime *runtime = subs->runtime; |
394 | struct cx231xx *dev = snd_pcm_substream_chip(subs); | ||
395 | 395 | ||
396 | dprintk("Allocating vbuffer\n"); | 396 | dev_dbg(dev->dev, "Allocating vbuffer\n"); |
397 | if (runtime->dma_area) { | 397 | if (runtime->dma_area) { |
398 | if (runtime->dma_bytes > size) | 398 | if (runtime->dma_bytes > size) |
399 | return 0; | 399 | return 0; |
@@ -436,16 +436,12 @@ static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) | |||
436 | struct snd_pcm_runtime *runtime = substream->runtime; | 436 | struct snd_pcm_runtime *runtime = substream->runtime; |
437 | int ret = 0; | 437 | int ret = 0; |
438 | 438 | ||
439 | dprintk("opening device and trying to acquire exclusive lock\n"); | 439 | dev_dbg(dev->dev, |
440 | 440 | "opening device and trying to acquire exclusive lock\n"); | |
441 | if (!dev) { | ||
442 | cx231xx_errdev("BUG: cx231xx can't find device struct." | ||
443 | " Can't proceed with open\n"); | ||
444 | return -ENODEV; | ||
445 | } | ||
446 | 441 | ||
447 | if (dev->state & DEV_DISCONNECTED) { | 442 | if (dev->state & DEV_DISCONNECTED) { |
448 | cx231xx_errdev("Can't open. the device was removed.\n"); | 443 | dev_err(dev->dev, |
444 | "Can't open. the device was removed.\n"); | ||
449 | return -ENODEV; | 445 | return -ENODEV; |
450 | } | 446 | } |
451 | 447 | ||
@@ -458,7 +454,8 @@ static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) | |||
458 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); | 454 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); |
459 | mutex_unlock(&dev->lock); | 455 | mutex_unlock(&dev->lock); |
460 | if (ret < 0) { | 456 | if (ret < 0) { |
461 | cx231xx_errdev("failed to set alternate setting !\n"); | 457 | dev_err(dev->dev, |
458 | "failed to set alternate setting !\n"); | ||
462 | 459 | ||
463 | return ret; | 460 | return ret; |
464 | } | 461 | } |
@@ -484,7 +481,7 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) | |||
484 | int ret; | 481 | int ret; |
485 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | 482 | struct cx231xx *dev = snd_pcm_substream_chip(substream); |
486 | 483 | ||
487 | dprintk("closing device\n"); | 484 | dev_dbg(dev->dev, "closing device\n"); |
488 | 485 | ||
489 | /* inform hardware to stop streaming */ | 486 | /* inform hardware to stop streaming */ |
490 | mutex_lock(&dev->lock); | 487 | mutex_lock(&dev->lock); |
@@ -494,7 +491,8 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) | |||
494 | /* 1 - 48000 samples per sec */ | 491 | /* 1 - 48000 samples per sec */ |
495 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); | 492 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); |
496 | if (ret < 0) { | 493 | if (ret < 0) { |
497 | cx231xx_errdev("failed to set alternate setting !\n"); | 494 | dev_err(dev->dev, |
495 | "failed to set alternate setting !\n"); | ||
498 | 496 | ||
499 | mutex_unlock(&dev->lock); | 497 | mutex_unlock(&dev->lock); |
500 | return ret; | 498 | return ret; |
@@ -504,10 +502,10 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) | |||
504 | mutex_unlock(&dev->lock); | 502 | mutex_unlock(&dev->lock); |
505 | 503 | ||
506 | if (dev->adev.users == 0 && dev->adev.shutdown == 1) { | 504 | if (dev->adev.users == 0 && dev->adev.shutdown == 1) { |
507 | dprintk("audio users: %d\n", dev->adev.users); | 505 | dev_dbg(dev->dev, "audio users: %d\n", dev->adev.users); |
508 | dprintk("disabling audio stream!\n"); | 506 | dev_dbg(dev->dev, "disabling audio stream!\n"); |
509 | dev->adev.shutdown = 0; | 507 | dev->adev.shutdown = 0; |
510 | dprintk("released lock\n"); | 508 | dev_dbg(dev->dev, "released lock\n"); |
511 | if (atomic_read(&dev->stream_started) > 0) { | 509 | if (atomic_read(&dev->stream_started) > 0) { |
512 | atomic_set(&dev->stream_started, 0); | 510 | atomic_set(&dev->stream_started, 0); |
513 | schedule_work(&dev->wq_trigger); | 511 | schedule_work(&dev->wq_trigger); |
@@ -519,9 +517,10 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) | |||
519 | static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, | 517 | static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, |
520 | struct snd_pcm_hw_params *hw_params) | 518 | struct snd_pcm_hw_params *hw_params) |
521 | { | 519 | { |
520 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
522 | int ret; | 521 | int ret; |
523 | 522 | ||
524 | dprintk("Setting capture parameters\n"); | 523 | dev_dbg(dev->dev, "Setting capture parameters\n"); |
525 | 524 | ||
526 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | 525 | ret = snd_pcm_alloc_vmalloc_buffer(substream, |
527 | params_buffer_bytes(hw_params)); | 526 | params_buffer_bytes(hw_params)); |
@@ -543,7 +542,7 @@ static int snd_cx231xx_hw_capture_free(struct snd_pcm_substream *substream) | |||
543 | { | 542 | { |
544 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | 543 | struct cx231xx *dev = snd_pcm_substream_chip(substream); |
545 | 544 | ||
546 | dprintk("Stop capture, if needed\n"); | 545 | dev_dbg(dev->dev, "Stop capture, if needed\n"); |
547 | 546 | ||
548 | if (atomic_read(&dev->stream_started) > 0) { | 547 | if (atomic_read(&dev->stream_started) > 0) { |
549 | atomic_set(&dev->stream_started, 0); | 548 | atomic_set(&dev->stream_started, 0); |
@@ -568,7 +567,7 @@ static void audio_trigger(struct work_struct *work) | |||
568 | struct cx231xx *dev = container_of(work, struct cx231xx, wq_trigger); | 567 | struct cx231xx *dev = container_of(work, struct cx231xx, wq_trigger); |
569 | 568 | ||
570 | if (atomic_read(&dev->stream_started)) { | 569 | if (atomic_read(&dev->stream_started)) { |
571 | dprintk("starting capture"); | 570 | dev_dbg(dev->dev, "starting capture"); |
572 | if (is_fw_load(dev) == 0) | 571 | if (is_fw_load(dev) == 0) |
573 | cx25840_call(dev, core, load_fw); | 572 | cx25840_call(dev, core, load_fw); |
574 | if (dev->USE_ISO) | 573 | if (dev->USE_ISO) |
@@ -576,7 +575,7 @@ static void audio_trigger(struct work_struct *work) | |||
576 | else | 575 | else |
577 | cx231xx_init_audio_bulk(dev); | 576 | cx231xx_init_audio_bulk(dev); |
578 | } else { | 577 | } else { |
579 | dprintk("stopping capture"); | 578 | dev_dbg(dev->dev, "stopping capture"); |
580 | cx231xx_isoc_audio_deinit(dev); | 579 | cx231xx_isoc_audio_deinit(dev); |
581 | } | 580 | } |
582 | } | 581 | } |
@@ -662,10 +661,10 @@ static int cx231xx_audio_init(struct cx231xx *dev) | |||
662 | return 0; | 661 | return 0; |
663 | } | 662 | } |
664 | 663 | ||
665 | cx231xx_info("cx231xx-audio.c: probing for cx231xx " | 664 | dev_dbg(dev->dev, |
666 | "non standard usbaudio\n"); | 665 | "probing for cx231xx non standard usbaudio\n"); |
667 | 666 | ||
668 | err = snd_card_new(&dev->udev->dev, index[devnr], "Cx231xx Audio", | 667 | err = snd_card_new(dev->dev, index[devnr], "Cx231xx Audio", |
669 | THIS_MODULE, 0, &card); | 668 | THIS_MODULE, 0, &card); |
670 | if (err < 0) | 669 | if (err < 0) |
671 | return err; | 670 | return err; |
@@ -707,14 +706,13 @@ static int cx231xx_audio_init(struct cx231xx *dev) | |||
707 | bEndpointAddress; | 706 | bEndpointAddress; |
708 | 707 | ||
709 | adev->num_alt = uif->num_altsetting; | 708 | adev->num_alt = uif->num_altsetting; |
710 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | 709 | dev_info(dev->dev, |
711 | adev->end_point_addr, adev->num_alt); | 710 | "audio EndPoint Addr 0x%x, Alternate settings: %i\n", |
711 | adev->end_point_addr, adev->num_alt); | ||
712 | adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); | 712 | adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); |
713 | 713 | ||
714 | if (adev->alt_max_pkt_size == NULL) { | 714 | if (adev->alt_max_pkt_size == NULL) |
715 | cx231xx_errdev("out of memory!\n"); | ||
716 | return -ENOMEM; | 715 | return -ENOMEM; |
717 | } | ||
718 | 716 | ||
719 | for (i = 0; i < adev->num_alt; i++) { | 717 | for (i = 0; i < adev->num_alt; i++) { |
720 | u16 tmp = | 718 | u16 tmp = |
@@ -722,8 +720,9 @@ static int cx231xx_audio_init(struct cx231xx *dev) | |||
722 | wMaxPacketSize); | 720 | wMaxPacketSize); |
723 | adev->alt_max_pkt_size[i] = | 721 | adev->alt_max_pkt_size[i] = |
724 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 722 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
725 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 723 | dev_dbg(dev->dev, |
726 | adev->alt_max_pkt_size[i]); | 724 | "audio alternate setting %i, max size= %i\n", i, |
725 | adev->alt_max_pkt_size[i]); | ||
727 | } | 726 | } |
728 | 727 | ||
729 | return 0; | 728 | return 0; |
diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c index 40a69879fc0a..39e887925e3d 100644 --- a/drivers/media/usb/cx231xx/cx231xx-avcore.c +++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c | |||
@@ -22,12 +22,12 @@ | |||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "cx231xx.h" | ||
25 | #include <linux/init.h> | 26 | #include <linux/init.h> |
26 | #include <linux/list.h> | 27 | #include <linux/list.h> |
27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
28 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
29 | #include <linux/bitmap.h> | 30 | #include <linux/bitmap.h> |
30 | #include <linux/usb.h> | ||
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
@@ -36,7 +36,6 @@ | |||
36 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
37 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
38 | 38 | ||
39 | #include "cx231xx.h" | ||
40 | #include "cx231xx-dif.h" | 39 | #include "cx231xx-dif.h" |
41 | 40 | ||
42 | #define TUNER_MODE_FM_RADIO 0 | 41 | #define TUNER_MODE_FM_RADIO 0 |
@@ -83,10 +82,10 @@ void initGPIO(struct cx231xx *dev) | |||
83 | cx231xx_send_gpio_cmd(dev, _gpio_direction, (u8 *)&value, 4, 0, 0); | 82 | cx231xx_send_gpio_cmd(dev, _gpio_direction, (u8 *)&value, 4, 0, 0); |
84 | 83 | ||
85 | verve_read_byte(dev, 0x07, &val); | 84 | verve_read_byte(dev, 0x07, &val); |
86 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | 85 | dev_dbg(dev->dev, "verve_read_byte address0x07=0x%x\n", val); |
87 | verve_write_byte(dev, 0x07, 0xF4); | 86 | verve_write_byte(dev, 0x07, 0xF4); |
88 | verve_read_byte(dev, 0x07, &val); | 87 | verve_read_byte(dev, 0x07, &val); |
89 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | 88 | dev_dbg(dev->dev, "verve_read_byte address0x07=0x%x\n", val); |
90 | 89 | ||
91 | cx231xx_capture_start(dev, 1, Vbi); | 90 | cx231xx_capture_start(dev, 1, Vbi); |
92 | 91 | ||
@@ -156,22 +155,25 @@ int cx231xx_afe_init_super_block(struct cx231xx *dev, u32 ref_count) | |||
156 | while (afe_power_status != 0x18) { | 155 | while (afe_power_status != 0x18) { |
157 | status = afe_write_byte(dev, SUP_BLK_PWRDN, 0x18); | 156 | status = afe_write_byte(dev, SUP_BLK_PWRDN, 0x18); |
158 | if (status < 0) { | 157 | if (status < 0) { |
159 | cx231xx_info( | 158 | dev_dbg(dev->dev, |
160 | ": Init Super Block failed in send cmd\n"); | 159 | "%s: Init Super Block failed in send cmd\n", |
160 | __func__); | ||
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | 163 | ||
164 | status = afe_read_byte(dev, SUP_BLK_PWRDN, &afe_power_status); | 164 | status = afe_read_byte(dev, SUP_BLK_PWRDN, &afe_power_status); |
165 | afe_power_status &= 0xff; | 165 | afe_power_status &= 0xff; |
166 | if (status < 0) { | 166 | if (status < 0) { |
167 | cx231xx_info( | 167 | dev_dbg(dev->dev, |
168 | ": Init Super Block failed in receive cmd\n"); | 168 | "%s: Init Super Block failed in receive cmd\n", |
169 | __func__); | ||
169 | break; | 170 | break; |
170 | } | 171 | } |
171 | i++; | 172 | i++; |
172 | if (i == 10) { | 173 | if (i == 10) { |
173 | cx231xx_info( | 174 | dev_dbg(dev->dev, |
174 | ": Init Super Block force break in loop !!!!\n"); | 175 | "%s: Init Super Block force break in loop !!!!\n", |
176 | __func__); | ||
175 | status = -1; | 177 | status = -1; |
176 | break; | 178 | break; |
177 | } | 179 | } |
@@ -410,7 +412,7 @@ int cx231xx_afe_update_power_control(struct cx231xx *dev, | |||
410 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | 412 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, |
411 | 0x00); | 413 | 0x00); |
412 | } else { | 414 | } else { |
413 | cx231xx_info("Invalid AV mode input\n"); | 415 | dev_dbg(dev->dev, "Invalid AV mode input\n"); |
414 | status = -1; | 416 | status = -1; |
415 | } | 417 | } |
416 | break; | 418 | break; |
@@ -467,7 +469,7 @@ int cx231xx_afe_update_power_control(struct cx231xx *dev, | |||
467 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | 469 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, |
468 | 0x40); | 470 | 0x40); |
469 | } else { | 471 | } else { |
470 | cx231xx_info("Invalid AV mode input\n"); | 472 | dev_dbg(dev->dev, "Invalid AV mode input\n"); |
471 | status = -1; | 473 | status = -1; |
472 | } | 474 | } |
473 | } /* switch */ | 475 | } /* switch */ |
@@ -573,9 +575,9 @@ int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | |||
573 | status = cx231xx_set_power_mode(dev, | 575 | status = cx231xx_set_power_mode(dev, |
574 | POLARIS_AVMODE_ENXTERNAL_AV); | 576 | POLARIS_AVMODE_ENXTERNAL_AV); |
575 | if (status < 0) { | 577 | if (status < 0) { |
576 | cx231xx_errdev("%s: set_power_mode : Failed to" | 578 | dev_err(dev->dev, |
577 | " set Power - errCode [%d]!\n", | 579 | "%s: Failed to set Power - errCode [%d]!\n", |
578 | __func__, status); | 580 | __func__, status); |
579 | return status; | 581 | return status; |
580 | } | 582 | } |
581 | } | 583 | } |
@@ -591,8 +593,8 @@ int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | |||
591 | status = cx231xx_set_power_mode(dev, | 593 | status = cx231xx_set_power_mode(dev, |
592 | POLARIS_AVMODE_ANALOGT_TV); | 594 | POLARIS_AVMODE_ANALOGT_TV); |
593 | if (status < 0) { | 595 | if (status < 0) { |
594 | cx231xx_errdev("%s: set_power_mode:Failed" | 596 | dev_err(dev->dev, |
595 | " to set Power - errCode [%d]!\n", | 597 | "%s: Failed to set Power - errCode [%d]!\n", |
596 | __func__, status); | 598 | __func__, status); |
597 | return status; | 599 | return status; |
598 | } | 600 | } |
@@ -608,8 +610,8 @@ int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | |||
608 | 610 | ||
609 | break; | 611 | break; |
610 | default: | 612 | default: |
611 | cx231xx_errdev("%s: set_power_mode : Unknown Input %d !\n", | 613 | dev_err(dev->dev, "%s: Unknown Input %d !\n", |
612 | __func__, INPUT(input)->type); | 614 | __func__, INPUT(input)->type); |
613 | break; | 615 | break; |
614 | } | 616 | } |
615 | 617 | ||
@@ -628,8 +630,8 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
628 | if (pin_type != dev->video_input) { | 630 | if (pin_type != dev->video_input) { |
629 | status = cx231xx_afe_adjust_ref_count(dev, pin_type); | 631 | status = cx231xx_afe_adjust_ref_count(dev, pin_type); |
630 | if (status < 0) { | 632 | if (status < 0) { |
631 | cx231xx_errdev("%s: adjust_ref_count :Failed to set" | 633 | dev_err(dev->dev, |
632 | "AFE input mux - errCode [%d]!\n", | 634 | "%s: adjust_ref_count :Failed to set AFE input mux - errCode [%d]!\n", |
633 | __func__, status); | 635 | __func__, status); |
634 | return status; | 636 | return status; |
635 | } | 637 | } |
@@ -638,9 +640,9 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
638 | /* call afe block to set video inputs */ | 640 | /* call afe block to set video inputs */ |
639 | status = cx231xx_afe_set_input_mux(dev, input); | 641 | status = cx231xx_afe_set_input_mux(dev, input); |
640 | if (status < 0) { | 642 | if (status < 0) { |
641 | cx231xx_errdev("%s: set_input_mux :Failed to set" | 643 | dev_err(dev->dev, |
642 | " AFE input mux - errCode [%d]!\n", | 644 | "%s: set_input_mux :Failed to set AFE input mux - errCode [%d]!\n", |
643 | __func__, status); | 645 | __func__, status); |
644 | return status; | 646 | return status; |
645 | } | 647 | } |
646 | 648 | ||
@@ -670,8 +672,8 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
670 | /* Tell DIF object to go to baseband mode */ | 672 | /* Tell DIF object to go to baseband mode */ |
671 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | 673 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); |
672 | if (status < 0) { | 674 | if (status < 0) { |
673 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | 675 | dev_err(dev->dev, |
674 | " mode- errCode [%d]!\n", | 676 | "%s: cx231xx_dif set to By pass mode- errCode [%d]!\n", |
675 | __func__, status); | 677 | __func__, status); |
676 | return status; | 678 | return status; |
677 | } | 679 | } |
@@ -715,8 +717,8 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
715 | /* Tell DIF object to go to baseband mode */ | 717 | /* Tell DIF object to go to baseband mode */ |
716 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | 718 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); |
717 | if (status < 0) { | 719 | if (status < 0) { |
718 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | 720 | dev_err(dev->dev, |
719 | " mode- errCode [%d]!\n", | 721 | "%s: cx231xx_dif set to By pass mode- errCode [%d]!\n", |
720 | __func__, status); | 722 | __func__, status); |
721 | return status; | 723 | return status; |
722 | } | 724 | } |
@@ -790,9 +792,9 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
790 | status = cx231xx_dif_set_standard(dev, | 792 | status = cx231xx_dif_set_standard(dev, |
791 | DIF_USE_BASEBAND); | 793 | DIF_USE_BASEBAND); |
792 | if (status < 0) { | 794 | if (status < 0) { |
793 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | 795 | dev_err(dev->dev, |
794 | " mode- errCode [%d]!\n", | 796 | "%s: cx231xx_dif set to By pass mode- errCode [%d]!\n", |
795 | __func__, status); | 797 | __func__, status); |
796 | return status; | 798 | return status; |
797 | } | 799 | } |
798 | 800 | ||
@@ -826,9 +828,9 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
826 | /* Reinitialize the DIF */ | 828 | /* Reinitialize the DIF */ |
827 | status = cx231xx_dif_set_standard(dev, dev->norm); | 829 | status = cx231xx_dif_set_standard(dev, dev->norm); |
828 | if (status < 0) { | 830 | if (status < 0) { |
829 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | 831 | dev_err(dev->dev, |
830 | " mode- errCode [%d]!\n", | 832 | "%s: cx231xx_dif set to By pass mode- errCode [%d]!\n", |
831 | __func__, status); | 833 | __func__, status); |
832 | return status; | 834 | return status; |
833 | } | 835 | } |
834 | 836 | ||
@@ -970,14 +972,14 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
970 | { | 972 | { |
971 | int status = 0; | 973 | int status = 0; |
972 | 974 | ||
973 | cx231xx_info("do_mode_ctrl_overrides : 0x%x\n", | 975 | dev_dbg(dev->dev, "%s: 0x%x\n", |
974 | (unsigned int)dev->norm); | 976 | __func__, (unsigned int)dev->norm); |
975 | 977 | ||
976 | /* Change the DFE_CTRL3 bp_percent to fix flagging */ | 978 | /* Change the DFE_CTRL3 bp_percent to fix flagging */ |
977 | status = vid_blk_write_word(dev, DFE_CTRL3, 0xCD3F0280); | 979 | status = vid_blk_write_word(dev, DFE_CTRL3, 0xCD3F0280); |
978 | 980 | ||
979 | if (dev->norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) { | 981 | if (dev->norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) { |
980 | cx231xx_info("do_mode_ctrl_overrides NTSC\n"); | 982 | dev_dbg(dev->dev, "%s: NTSC\n", __func__); |
981 | 983 | ||
982 | /* Move the close caption lines out of active video, | 984 | /* Move the close caption lines out of active video, |
983 | adjust the active video start point */ | 985 | adjust the active video start point */ |
@@ -1004,7 +1006,7 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
1004 | (FLD_HBLANK_CNT, 0x79)); | 1006 | (FLD_HBLANK_CNT, 0x79)); |
1005 | 1007 | ||
1006 | } else if (dev->norm & V4L2_STD_SECAM) { | 1008 | } else if (dev->norm & V4L2_STD_SECAM) { |
1007 | cx231xx_info("do_mode_ctrl_overrides SECAM\n"); | 1009 | dev_dbg(dev->dev, "%s: SECAM\n", __func__); |
1008 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1010 | status = cx231xx_read_modify_write_i2c_dword(dev, |
1009 | VID_BLK_I2C_ADDRESS, | 1011 | VID_BLK_I2C_ADDRESS, |
1010 | VERT_TIM_CTRL, | 1012 | VERT_TIM_CTRL, |
@@ -1031,7 +1033,7 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
1031 | cx231xx_set_field | 1033 | cx231xx_set_field |
1032 | (FLD_HBLANK_CNT, 0x85)); | 1034 | (FLD_HBLANK_CNT, 0x85)); |
1033 | } else { | 1035 | } else { |
1034 | cx231xx_info("do_mode_ctrl_overrides PAL\n"); | 1036 | dev_dbg(dev->dev, "%s: PAL\n", __func__); |
1035 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1037 | status = cx231xx_read_modify_write_i2c_dword(dev, |
1036 | VID_BLK_I2C_ADDRESS, | 1038 | VID_BLK_I2C_ADDRESS, |
1037 | VERT_TIM_CTRL, | 1039 | VERT_TIM_CTRL, |
@@ -1206,7 +1208,8 @@ int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | |||
1206 | /* This is just a casual suggestion to people adding | 1208 | /* This is just a casual suggestion to people adding |
1207 | new boards in case they use a tuner type we don't | 1209 | new boards in case they use a tuner type we don't |
1208 | currently know about */ | 1210 | currently know about */ |
1209 | printk(KERN_INFO "Unknown tuner type configuring SIF"); | 1211 | dev_info(dev->dev, |
1212 | "Unknown tuner type configuring SIF"); | ||
1210 | break; | 1213 | break; |
1211 | } | 1214 | } |
1212 | break; | 1215 | break; |
@@ -1270,8 +1273,13 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3) | |||
1270 | int status = 0; | 1273 | int status = 0; |
1271 | bool current_is_port_3; | 1274 | bool current_is_port_3; |
1272 | 1275 | ||
1273 | if (dev->board.dont_use_port_3) | 1276 | /* |
1274 | is_port_3 = false; | 1277 | * Should this code check dev->port_3_switch_enabled first |
1278 | * to skip unnecessary reading of the register? | ||
1279 | * If yes, the flag dev->port_3_switch_enabled must be initialized | ||
1280 | * correctly. | ||
1281 | */ | ||
1282 | |||
1275 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | 1283 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, |
1276 | PWR_CTL_EN, value, 4); | 1284 | PWR_CTL_EN, value, 4); |
1277 | if (status < 0) | 1285 | if (status < 0) |
@@ -1288,12 +1296,13 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3) | |||
1288 | else | 1296 | else |
1289 | value[0] &= ~I2C_DEMOD_EN; | 1297 | value[0] &= ~I2C_DEMOD_EN; |
1290 | 1298 | ||
1291 | cx231xx_info("Changing the i2c master port to %d\n", | ||
1292 | is_port_3 ? 3 : 1); | ||
1293 | |||
1294 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | 1299 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, |
1295 | PWR_CTL_EN, value, 4); | 1300 | PWR_CTL_EN, value, 4); |
1296 | 1301 | ||
1302 | /* remember status of the switch for usage in is_tuner */ | ||
1303 | if (status >= 0) | ||
1304 | dev->port_3_switch_enabled = is_port_3; | ||
1305 | |||
1297 | return status; | 1306 | return status; |
1298 | 1307 | ||
1299 | } | 1308 | } |
@@ -1325,113 +1334,131 @@ void cx231xx_dump_HH_reg(struct cx231xx *dev) | |||
1325 | 1334 | ||
1326 | for (i = 0x100; i < 0x140; i++) { | 1335 | for (i = 0x100; i < 0x140; i++) { |
1327 | vid_blk_read_word(dev, i, &value); | 1336 | vid_blk_read_word(dev, i, &value); |
1328 | cx231xx_info("reg0x%x=0x%x\n", i, value); | 1337 | dev_dbg(dev->dev, "reg0x%x=0x%x\n", i, value); |
1329 | i = i+3; | 1338 | i = i+3; |
1330 | } | 1339 | } |
1331 | 1340 | ||
1332 | for (i = 0x300; i < 0x400; i++) { | 1341 | for (i = 0x300; i < 0x400; i++) { |
1333 | vid_blk_read_word(dev, i, &value); | 1342 | vid_blk_read_word(dev, i, &value); |
1334 | cx231xx_info("reg0x%x=0x%x\n", i, value); | 1343 | dev_dbg(dev->dev, "reg0x%x=0x%x\n", i, value); |
1335 | i = i+3; | 1344 | i = i+3; |
1336 | } | 1345 | } |
1337 | 1346 | ||
1338 | for (i = 0x400; i < 0x440; i++) { | 1347 | for (i = 0x400; i < 0x440; i++) { |
1339 | vid_blk_read_word(dev, i, &value); | 1348 | vid_blk_read_word(dev, i, &value); |
1340 | cx231xx_info("reg0x%x=0x%x\n", i, value); | 1349 | dev_dbg(dev->dev, "reg0x%x=0x%x\n", i, value); |
1341 | i = i+3; | 1350 | i = i+3; |
1342 | } | 1351 | } |
1343 | 1352 | ||
1344 | vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | 1353 | vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); |
1345 | cx231xx_info("AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); | 1354 | dev_dbg(dev->dev, "AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); |
1346 | vid_blk_write_word(dev, AFE_CTRL_C2HH_SRC_CTRL, 0x4485D390); | 1355 | vid_blk_write_word(dev, AFE_CTRL_C2HH_SRC_CTRL, 0x4485D390); |
1347 | vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | 1356 | vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); |
1348 | cx231xx_info("AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); | 1357 | dev_dbg(dev->dev, "AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); |
1349 | } | 1358 | } |
1350 | 1359 | ||
1351 | void cx231xx_dump_SC_reg(struct cx231xx *dev) | 1360 | #if 0 |
1361 | static void cx231xx_dump_SC_reg(struct cx231xx *dev) | ||
1352 | { | 1362 | { |
1353 | u8 value[4] = { 0, 0, 0, 0 }; | 1363 | u8 value[4] = { 0, 0, 0, 0 }; |
1354 | cx231xx_info("cx231xx_dump_SC_reg!\n"); | 1364 | dev_dbg(dev->dev, "%s!\n", __func__); |
1355 | 1365 | ||
1356 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, | 1366 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, |
1357 | value, 4); | 1367 | value, 4); |
1358 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", BOARD_CFG_STAT, value[0], | 1368 | dev_dbg(dev->dev, |
1359 | value[1], value[2], value[3]); | 1369 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", BOARD_CFG_STAT, value[0], |
1370 | value[1], value[2], value[3]); | ||
1360 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS_MODE_REG, | 1371 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS_MODE_REG, |
1361 | value, 4); | 1372 | value, 4); |
1362 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS_MODE_REG, value[0], | 1373 | dev_dbg(dev->dev, |
1363 | value[1], value[2], value[3]); | 1374 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS_MODE_REG, value[0], |
1375 | value[1], value[2], value[3]); | ||
1364 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_CFG_REG, | 1376 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_CFG_REG, |
1365 | value, 4); | 1377 | value, 4); |
1366 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_CFG_REG, value[0], | 1378 | dev_dbg(dev->dev, |
1367 | value[1], value[2], value[3]); | 1379 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_CFG_REG, value[0], |
1380 | value[1], value[2], value[3]); | ||
1368 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_LENGTH_REG, | 1381 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_LENGTH_REG, |
1369 | value, 4); | 1382 | value, 4); |
1370 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_LENGTH_REG, value[0], | 1383 | dev_dbg(dev->dev, |
1371 | value[1], value[2], value[3]); | 1384 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_LENGTH_REG, value[0], |
1385 | value[1], value[2], value[3]); | ||
1372 | 1386 | ||
1373 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_CFG_REG, | 1387 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_CFG_REG, |
1374 | value, 4); | 1388 | value, 4); |
1375 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_CFG_REG, value[0], | 1389 | dev_dbg(dev->dev, |
1376 | value[1], value[2], value[3]); | 1390 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_CFG_REG, value[0], |
1391 | value[1], value[2], value[3]); | ||
1377 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_LENGTH_REG, | 1392 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_LENGTH_REG, |
1378 | value, 4); | 1393 | value, 4); |
1379 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_LENGTH_REG, value[0], | 1394 | dev_dbg(dev->dev, |
1380 | value[1], value[2], value[3]); | 1395 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_LENGTH_REG, value[0], |
1396 | value[1], value[2], value[3]); | ||
1381 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, | 1397 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, |
1382 | value, 4); | 1398 | value, 4); |
1383 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", EP_MODE_SET, value[0], | 1399 | dev_dbg(dev->dev, |
1384 | value[1], value[2], value[3]); | 1400 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", EP_MODE_SET, value[0], |
1401 | value[1], value[2], value[3]); | ||
1385 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN1, | 1402 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN1, |
1386 | value, 4); | 1403 | value, 4); |
1387 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN1, value[0], | 1404 | dev_dbg(dev->dev, |
1388 | value[1], value[2], value[3]); | 1405 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN1, value[0], |
1406 | value[1], value[2], value[3]); | ||
1389 | 1407 | ||
1390 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN2, | 1408 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN2, |
1391 | value, 4); | 1409 | value, 4); |
1392 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN2, value[0], | 1410 | dev_dbg(dev->dev, |
1393 | value[1], value[2], value[3]); | 1411 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN2, value[0], |
1412 | value[1], value[2], value[3]); | ||
1394 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN3, | 1413 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN3, |
1395 | value, 4); | 1414 | value, 4); |
1396 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN3, value[0], | 1415 | dev_dbg(dev->dev, |
1397 | value[1], value[2], value[3]); | 1416 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN3, value[0], |
1417 | value[1], value[2], value[3]); | ||
1398 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK0, | 1418 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK0, |
1399 | value, 4); | 1419 | value, 4); |
1400 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK0, value[0], | 1420 | dev_dbg(dev->dev, |
1401 | value[1], value[2], value[3]); | 1421 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK0, value[0], |
1422 | value[1], value[2], value[3]); | ||
1402 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK1, | 1423 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK1, |
1403 | value, 4); | 1424 | value, 4); |
1404 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK1, value[0], | 1425 | dev_dbg(dev->dev, |
1405 | value[1], value[2], value[3]); | 1426 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK1, value[0], |
1427 | value[1], value[2], value[3]); | ||
1406 | 1428 | ||
1407 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK2, | 1429 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK2, |
1408 | value, 4); | 1430 | value, 4); |
1409 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK2, value[0], | 1431 | dev_dbg(dev->dev, |
1410 | value[1], value[2], value[3]); | 1432 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK2, value[0], |
1433 | value[1], value[2], value[3]); | ||
1411 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_GAIN, | 1434 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_GAIN, |
1412 | value, 4); | 1435 | value, 4); |
1413 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_GAIN, value[0], | 1436 | dev_dbg(dev->dev, |
1414 | value[1], value[2], value[3]); | 1437 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_GAIN, value[0], |
1438 | value[1], value[2], value[3]); | ||
1415 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_CAR_REG, | 1439 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_CAR_REG, |
1416 | value, 4); | 1440 | value, 4); |
1417 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_CAR_REG, value[0], | 1441 | dev_dbg(dev->dev, |
1418 | value[1], value[2], value[3]); | 1442 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_CAR_REG, value[0], |
1443 | value[1], value[2], value[3]); | ||
1419 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG1, | 1444 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG1, |
1420 | value, 4); | 1445 | value, 4); |
1421 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG1, value[0], | 1446 | dev_dbg(dev->dev, |
1422 | value[1], value[2], value[3]); | 1447 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG1, value[0], |
1448 | value[1], value[2], value[3]); | ||
1423 | 1449 | ||
1424 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG2, | 1450 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG2, |
1425 | value, 4); | 1451 | value, 4); |
1426 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG2, value[0], | 1452 | dev_dbg(dev->dev, |
1427 | value[1], value[2], value[3]); | 1453 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG2, value[0], |
1454 | value[1], value[2], value[3]); | ||
1428 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | 1455 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, |
1429 | value, 4); | 1456 | value, 4); |
1430 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, value[0], | 1457 | dev_dbg(dev->dev, |
1431 | value[1], value[2], value[3]); | 1458 | "reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, value[0], |
1432 | 1459 | value[1], value[2], value[3]); | |
1433 | |||
1434 | } | 1460 | } |
1461 | #endif | ||
1435 | 1462 | ||
1436 | void cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev) | 1463 | void cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev) |
1437 | 1464 | ||
@@ -1497,7 +1524,7 @@ void cx231xx_set_Colibri_For_LowIF(struct cx231xx *dev, u32 if_freq, | |||
1497 | u32 standard = 0; | 1524 | u32 standard = 0; |
1498 | u8 value[4] = { 0, 0, 0, 0 }; | 1525 | u8 value[4] = { 0, 0, 0, 0 }; |
1499 | 1526 | ||
1500 | cx231xx_info("Enter cx231xx_set_Colibri_For_LowIF()\n"); | 1527 | dev_dbg(dev->dev, "Enter cx231xx_set_Colibri_For_LowIF()\n"); |
1501 | value[0] = (u8) 0x6F; | 1528 | value[0] = (u8) 0x6F; |
1502 | value[1] = (u8) 0x6F; | 1529 | value[1] = (u8) 0x6F; |
1503 | value[2] = (u8) 0x6F; | 1530 | value[2] = (u8) 0x6F; |
@@ -1517,7 +1544,7 @@ void cx231xx_set_Colibri_For_LowIF(struct cx231xx *dev, u32 if_freq, | |||
1517 | colibri_carrier_offset = cx231xx_Get_Colibri_CarrierOffset(mode, | 1544 | colibri_carrier_offset = cx231xx_Get_Colibri_CarrierOffset(mode, |
1518 | standard); | 1545 | standard); |
1519 | 1546 | ||
1520 | cx231xx_info("colibri_carrier_offset=%d, standard=0x%x\n", | 1547 | dev_dbg(dev->dev, "colibri_carrier_offset=%d, standard=0x%x\n", |
1521 | colibri_carrier_offset, standard); | 1548 | colibri_carrier_offset, standard); |
1522 | 1549 | ||
1523 | /* Set the band Pass filter for DIF*/ | 1550 | /* Set the band Pass filter for DIF*/ |
@@ -1551,8 +1578,8 @@ void cx231xx_set_DIF_bandpass(struct cx231xx *dev, u32 if_freq, | |||
1551 | u64 pll_freq_u64 = 0; | 1578 | u64 pll_freq_u64 = 0; |
1552 | u32 i = 0; | 1579 | u32 i = 0; |
1553 | 1580 | ||
1554 | cx231xx_info("if_freq=%d;spectral_invert=0x%x;mode=0x%x\n", | 1581 | dev_dbg(dev->dev, "if_freq=%d;spectral_invert=0x%x;mode=0x%x\n", |
1555 | if_freq, spectral_invert, mode); | 1582 | if_freq, spectral_invert, mode); |
1556 | 1583 | ||
1557 | 1584 | ||
1558 | if (mode == TUNER_MODE_FM_RADIO) { | 1585 | if (mode == TUNER_MODE_FM_RADIO) { |
@@ -1595,8 +1622,7 @@ void cx231xx_set_DIF_bandpass(struct cx231xx *dev, u32 if_freq, | |||
1595 | if_freq = 16000000; | 1622 | if_freq = 16000000; |
1596 | } | 1623 | } |
1597 | 1624 | ||
1598 | cx231xx_info("Enter IF=%zu\n", | 1625 | dev_dbg(dev->dev, "Enter IF=%zu\n", ARRAY_SIZE(Dif_set_array)); |
1599 | ARRAY_SIZE(Dif_set_array)); | ||
1600 | for (i = 0; i < ARRAY_SIZE(Dif_set_array); i++) { | 1626 | for (i = 0; i < ARRAY_SIZE(Dif_set_array); i++) { |
1601 | if (Dif_set_array[i].if_freq == if_freq) { | 1627 | if (Dif_set_array[i].if_freq == if_freq) { |
1602 | vid_blk_write_word(dev, | 1628 | vid_blk_write_word(dev, |
@@ -1708,7 +1734,7 @@ int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard) | |||
1708 | u32 dif_misc_ctrl_value = 0; | 1734 | u32 dif_misc_ctrl_value = 0; |
1709 | u32 func_mode = 0; | 1735 | u32 func_mode = 0; |
1710 | 1736 | ||
1711 | cx231xx_info("%s: setStandard to %x\n", __func__, standard); | 1737 | dev_dbg(dev->dev, "%s: setStandard to %x\n", __func__, standard); |
1712 | 1738 | ||
1713 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, &dif_misc_ctrl_value); | 1739 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, &dif_misc_ctrl_value); |
1714 | if (standard != DIF_USE_BASEBAND) | 1740 | if (standard != DIF_USE_BASEBAND) |
@@ -2111,8 +2137,8 @@ int cx231xx_tuner_post_channel_change(struct cx231xx *dev) | |||
2111 | { | 2137 | { |
2112 | int status = 0; | 2138 | int status = 0; |
2113 | u32 dwval; | 2139 | u32 dwval; |
2114 | cx231xx_info("cx231xx_tuner_post_channel_change dev->tuner_type =0%d\n", | 2140 | dev_dbg(dev->dev, "%s: dev->tuner_type =0%d\n", |
2115 | dev->tuner_type); | 2141 | __func__, dev->tuner_type); |
2116 | /* Set the RF and IF k_agc values to 4 for PAL/NTSC and 8 for | 2142 | /* Set the RF and IF k_agc values to 4 for PAL/NTSC and 8 for |
2117 | * SECAM L/B/D standards */ | 2143 | * SECAM L/B/D standards */ |
2118 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); | 2144 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); |
@@ -2213,8 +2239,8 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2213 | if (dev->power_mode != mode) | 2239 | if (dev->power_mode != mode) |
2214 | dev->power_mode = mode; | 2240 | dev->power_mode = mode; |
2215 | else { | 2241 | else { |
2216 | cx231xx_info(" setPowerMode::mode = %d, No Change req.\n", | 2242 | dev_dbg(dev->dev, "%s: mode = %d, No Change req.\n", |
2217 | mode); | 2243 | __func__, mode); |
2218 | return 0; | 2244 | return 0; |
2219 | } | 2245 | } |
2220 | 2246 | ||
@@ -2264,7 +2290,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2264 | case POLARIS_AVMODE_ANALOGT_TV: | 2290 | case POLARIS_AVMODE_ANALOGT_TV: |
2265 | 2291 | ||
2266 | tmp |= PWR_DEMOD_EN; | 2292 | tmp |= PWR_DEMOD_EN; |
2267 | tmp |= (I2C_DEMOD_EN); | ||
2268 | value[0] = (u8) tmp; | 2293 | value[0] = (u8) tmp; |
2269 | value[1] = (u8) (tmp >> 8); | 2294 | value[1] = (u8) (tmp >> 8); |
2270 | value[2] = (u8) (tmp >> 16); | 2295 | value[2] = (u8) (tmp >> 16); |
@@ -2317,9 +2342,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2317 | } | 2342 | } |
2318 | 2343 | ||
2319 | if (dev->board.tuner_type != TUNER_ABSENT) { | 2344 | if (dev->board.tuner_type != TUNER_ABSENT) { |
2320 | /* Enable tuner */ | ||
2321 | cx231xx_enable_i2c_port_3(dev, true); | ||
2322 | |||
2323 | /* reset the Tuner */ | 2345 | /* reset the Tuner */ |
2324 | if (dev->board.tuner_gpio) | 2346 | if (dev->board.tuner_gpio) |
2325 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | 2347 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); |
@@ -2363,7 +2385,7 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2363 | } | 2385 | } |
2364 | 2386 | ||
2365 | tmp &= (~PWR_AV_MODE); | 2387 | tmp &= (~PWR_AV_MODE); |
2366 | tmp |= POLARIS_AVMODE_DIGITAL | I2C_DEMOD_EN; | 2388 | tmp |= POLARIS_AVMODE_DIGITAL; |
2367 | value[0] = (u8) tmp; | 2389 | value[0] = (u8) tmp; |
2368 | value[1] = (u8) (tmp >> 8); | 2390 | value[1] = (u8) (tmp >> 8); |
2369 | value[2] = (u8) (tmp >> 16); | 2391 | value[2] = (u8) (tmp >> 16); |
@@ -2384,15 +2406,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2384 | } | 2406 | } |
2385 | 2407 | ||
2386 | if (dev->board.tuner_type != TUNER_ABSENT) { | 2408 | if (dev->board.tuner_type != TUNER_ABSENT) { |
2387 | /* | ||
2388 | * Enable tuner | ||
2389 | * Hauppauge Exeter seems to need to do something different! | ||
2390 | */ | ||
2391 | if (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER) | ||
2392 | cx231xx_enable_i2c_port_3(dev, false); | ||
2393 | else | ||
2394 | cx231xx_enable_i2c_port_3(dev, true); | ||
2395 | |||
2396 | /* reset the Tuner */ | 2409 | /* reset the Tuner */ |
2397 | if (dev->board.tuner_gpio) | 2410 | if (dev->board.tuner_gpio) |
2398 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | 2411 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); |
@@ -2466,7 +2479,7 @@ int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask) | |||
2466 | u32 tmp = 0; | 2479 | u32 tmp = 0; |
2467 | int status = 0; | 2480 | int status = 0; |
2468 | 2481 | ||
2469 | cx231xx_info("cx231xx_start_stream():: ep_mask = %x\n", ep_mask); | 2482 | dev_dbg(dev->dev, "%s: ep_mask = %x\n", __func__, ep_mask); |
2470 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, | 2483 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, |
2471 | value, 4); | 2484 | value, 4); |
2472 | if (status < 0) | 2485 | if (status < 0) |
@@ -2491,7 +2504,7 @@ int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask) | |||
2491 | u32 tmp = 0; | 2504 | u32 tmp = 0; |
2492 | int status = 0; | 2505 | int status = 0; |
2493 | 2506 | ||
2494 | cx231xx_info("cx231xx_stop_stream():: ep_mask = %x\n", ep_mask); | 2507 | dev_dbg(dev->dev, "%s: ep_mask = %x\n", __func__, ep_mask); |
2495 | status = | 2508 | status = |
2496 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, value, 4); | 2509 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, value, 4); |
2497 | if (status < 0) | 2510 | if (status < 0) |
@@ -2519,61 +2532,72 @@ int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | |||
2519 | if (dev->udev->speed == USB_SPEED_HIGH) { | 2532 | if (dev->udev->speed == USB_SPEED_HIGH) { |
2520 | switch (media_type) { | 2533 | switch (media_type) { |
2521 | case Audio: | 2534 | case Audio: |
2522 | cx231xx_info("%s: Audio enter HANC\n", __func__); | 2535 | dev_dbg(dev->dev, |
2536 | "%s: Audio enter HANC\n", __func__); | ||
2523 | status = | 2537 | status = |
2524 | cx231xx_mode_register(dev, TS_MODE_REG, 0x9300); | 2538 | cx231xx_mode_register(dev, TS_MODE_REG, 0x9300); |
2525 | break; | 2539 | break; |
2526 | 2540 | ||
2527 | case Vbi: | 2541 | case Vbi: |
2528 | cx231xx_info("%s: set vanc registers\n", __func__); | 2542 | dev_dbg(dev->dev, |
2543 | "%s: set vanc registers\n", __func__); | ||
2529 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x300); | 2544 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x300); |
2530 | break; | 2545 | break; |
2531 | 2546 | ||
2532 | case Sliced_cc: | 2547 | case Sliced_cc: |
2533 | cx231xx_info("%s: set hanc registers\n", __func__); | 2548 | dev_dbg(dev->dev, |
2549 | "%s: set hanc registers\n", __func__); | ||
2534 | status = | 2550 | status = |
2535 | cx231xx_mode_register(dev, TS_MODE_REG, 0x1300); | 2551 | cx231xx_mode_register(dev, TS_MODE_REG, 0x1300); |
2536 | break; | 2552 | break; |
2537 | 2553 | ||
2538 | case Raw_Video: | 2554 | case Raw_Video: |
2539 | cx231xx_info("%s: set video registers\n", __func__); | 2555 | dev_dbg(dev->dev, |
2556 | "%s: set video registers\n", __func__); | ||
2540 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | 2557 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); |
2541 | break; | 2558 | break; |
2542 | 2559 | ||
2543 | case TS1_serial_mode: | 2560 | case TS1_serial_mode: |
2544 | cx231xx_info("%s: set ts1 registers", __func__); | 2561 | dev_dbg(dev->dev, |
2545 | 2562 | "%s: set ts1 registers", __func__); | |
2546 | if (dev->board.has_417) { | 2563 | |
2547 | cx231xx_info(" MPEG\n"); | 2564 | if (dev->board.has_417) { |
2548 | value &= 0xFFFFFFFC; | 2565 | dev_dbg(dev->dev, |
2549 | value |= 0x3; | 2566 | "%s: MPEG\n", __func__); |
2550 | 2567 | value &= 0xFFFFFFFC; | |
2551 | status = cx231xx_mode_register(dev, TS_MODE_REG, value); | 2568 | value |= 0x3; |
2552 | 2569 | ||
2553 | val[0] = 0x04; | 2570 | status = cx231xx_mode_register(dev, |
2554 | val[1] = 0xA3; | 2571 | TS_MODE_REG, value); |
2555 | val[2] = 0x3B; | 2572 | |
2556 | val[3] = 0x00; | 2573 | val[0] = 0x04; |
2557 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | 2574 | val[1] = 0xA3; |
2558 | TS1_CFG_REG, val, 4); | 2575 | val[2] = 0x3B; |
2559 | 2576 | val[3] = 0x00; | |
2560 | val[0] = 0x00; | 2577 | status = cx231xx_write_ctrl_reg(dev, |
2561 | val[1] = 0x08; | 2578 | VRT_SET_REGISTER, |
2562 | val[2] = 0x00; | 2579 | TS1_CFG_REG, val, 4); |
2563 | val[3] = 0x08; | 2580 | |
2564 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | 2581 | val[0] = 0x00; |
2565 | TS1_LENGTH_REG, val, 4); | 2582 | val[1] = 0x08; |
2566 | 2583 | val[2] = 0x00; | |
2567 | } else { | 2584 | val[3] = 0x08; |
2568 | cx231xx_info(" BDA\n"); | 2585 | status = cx231xx_write_ctrl_reg(dev, |
2569 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); | 2586 | VRT_SET_REGISTER, |
2570 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x010); | 2587 | TS1_LENGTH_REG, val, 4); |
2571 | } | 2588 | } else { |
2589 | dev_dbg(dev->dev, "%s: BDA\n", __func__); | ||
2590 | status = cx231xx_mode_register(dev, | ||
2591 | TS_MODE_REG, 0x101); | ||
2592 | status = cx231xx_mode_register(dev, | ||
2593 | TS1_CFG_REG, 0x010); | ||
2594 | } | ||
2572 | break; | 2595 | break; |
2573 | 2596 | ||
2574 | case TS1_parallel_mode: | 2597 | case TS1_parallel_mode: |
2575 | cx231xx_info("%s: set ts1 parallel mode registers\n", | 2598 | dev_dbg(dev->dev, |
2576 | __func__); | 2599 | "%s: set ts1 parallel mode registers\n", |
2600 | __func__); | ||
2577 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | 2601 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); |
2578 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x400); | 2602 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x400); |
2579 | break; | 2603 | break; |
@@ -2926,8 +2950,9 @@ int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev) | |||
2926 | (nCnt > 0)); | 2950 | (nCnt > 0)); |
2927 | 2951 | ||
2928 | if (nCnt == 0) | 2952 | if (nCnt == 0) |
2929 | cx231xx_info("No ACK after %d msec -GPIO I2C failed!", | 2953 | dev_dbg(dev->dev, |
2930 | nInit * 10); | 2954 | "No ACK after %d msec -GPIO I2C failed!", |
2955 | nInit * 10); | ||
2931 | 2956 | ||
2932 | /* | 2957 | /* |
2933 | * readAck | 2958 | * readAck |
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 791f00c6276b..ae05d591f228 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c | |||
@@ -20,12 +20,12 @@ | |||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "cx231xx.h" | ||
23 | #include <linux/init.h> | 24 | #include <linux/init.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
26 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
27 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
28 | #include <linux/usb.h> | ||
29 | #include <media/tuner.h> | 29 | #include <media/tuner.h> |
30 | #include <media/tveeprom.h> | 30 | #include <media/tveeprom.h> |
31 | #include <media/v4l2-common.h> | 31 | #include <media/v4l2-common.h> |
@@ -35,7 +35,6 @@ | |||
35 | #include "xc5000.h" | 35 | #include "xc5000.h" |
36 | #include "tda18271.h" | 36 | #include "tda18271.h" |
37 | 37 | ||
38 | #include "cx231xx.h" | ||
39 | 38 | ||
40 | static int tuner = -1; | 39 | static int tuner = -1; |
41 | module_param(tuner, int, 0444); | 40 | module_param(tuner, int, 0444); |
@@ -104,8 +103,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
104 | .ctl_pin_status_mask = 0xFFFFFFC4, | 103 | .ctl_pin_status_mask = 0xFFFFFFC4, |
105 | .agc_analog_digital_select_gpio = 0x0c, | 104 | .agc_analog_digital_select_gpio = 0x0c, |
106 | .gpio_pin_status_mask = 0x4001000, | 105 | .gpio_pin_status_mask = 0x4001000, |
107 | .tuner_i2c_master = 1, | 106 | .tuner_i2c_master = I2C_1_MUX_3, |
108 | .demod_i2c_master = 2, | 107 | .demod_i2c_master = I2C_2, |
109 | .has_dvb = 1, | 108 | .has_dvb = 1, |
110 | .demod_addr = 0x02, | 109 | .demod_addr = 0x02, |
111 | .norm = V4L2_STD_PAL, | 110 | .norm = V4L2_STD_PAL, |
@@ -144,8 +143,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
144 | .ctl_pin_status_mask = 0xFFFFFFC4, | 143 | .ctl_pin_status_mask = 0xFFFFFFC4, |
145 | .agc_analog_digital_select_gpio = 0x0c, | 144 | .agc_analog_digital_select_gpio = 0x0c, |
146 | .gpio_pin_status_mask = 0x4001000, | 145 | .gpio_pin_status_mask = 0x4001000, |
147 | .tuner_i2c_master = 1, | 146 | .tuner_i2c_master = I2C_1_MUX_3, |
148 | .demod_i2c_master = 2, | 147 | .demod_i2c_master = I2C_2, |
149 | .has_dvb = 1, | 148 | .has_dvb = 1, |
150 | .demod_addr = 0x32, | 149 | .demod_addr = 0x32, |
151 | .norm = V4L2_STD_NTSC, | 150 | .norm = V4L2_STD_NTSC, |
@@ -184,8 +183,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
184 | .ctl_pin_status_mask = 0xFFFFFFC4, | 183 | .ctl_pin_status_mask = 0xFFFFFFC4, |
185 | .agc_analog_digital_select_gpio = 0x1c, | 184 | .agc_analog_digital_select_gpio = 0x1c, |
186 | .gpio_pin_status_mask = 0x4001000, | 185 | .gpio_pin_status_mask = 0x4001000, |
187 | .tuner_i2c_master = 1, | 186 | .tuner_i2c_master = I2C_1_MUX_3, |
188 | .demod_i2c_master = 2, | 187 | .demod_i2c_master = I2C_2, |
189 | .has_dvb = 1, | 188 | .has_dvb = 1, |
190 | .demod_addr = 0x02, | 189 | .demod_addr = 0x02, |
191 | .norm = V4L2_STD_PAL, | 190 | .norm = V4L2_STD_PAL, |
@@ -225,8 +224,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
225 | .ctl_pin_status_mask = 0xFFFFFFC4, | 224 | .ctl_pin_status_mask = 0xFFFFFFC4, |
226 | .agc_analog_digital_select_gpio = 0x1c, | 225 | .agc_analog_digital_select_gpio = 0x1c, |
227 | .gpio_pin_status_mask = 0x4001000, | 226 | .gpio_pin_status_mask = 0x4001000, |
228 | .tuner_i2c_master = 1, | 227 | .tuner_i2c_master = I2C_1_MUX_3, |
229 | .demod_i2c_master = 2, | 228 | .demod_i2c_master = I2C_2, |
230 | .has_dvb = 1, | 229 | .has_dvb = 1, |
231 | .demod_addr = 0x02, | 230 | .demod_addr = 0x02, |
232 | .norm = V4L2_STD_PAL, | 231 | .norm = V4L2_STD_PAL, |
@@ -262,7 +261,6 @@ struct cx231xx_board cx231xx_boards[] = { | |||
262 | .norm = V4L2_STD_PAL, | 261 | .norm = V4L2_STD_PAL, |
263 | .no_alt_vanc = 1, | 262 | .no_alt_vanc = 1, |
264 | .external_av = 1, | 263 | .external_av = 1, |
265 | .dont_use_port_3 = 1, | ||
266 | /* Actually, it has a 417, but it isn't working correctly. | 264 | /* Actually, it has a 417, but it isn't working correctly. |
267 | * So set to 0 for now until someone can manage to get this | 265 | * So set to 0 for now until someone can manage to get this |
268 | * to work reliably. */ | 266 | * to work reliably. */ |
@@ -297,8 +295,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
297 | .ctl_pin_status_mask = 0xFFFFFFC4, | 295 | .ctl_pin_status_mask = 0xFFFFFFC4, |
298 | .agc_analog_digital_select_gpio = 0x0c, | 296 | .agc_analog_digital_select_gpio = 0x0c, |
299 | .gpio_pin_status_mask = 0x4001000, | 297 | .gpio_pin_status_mask = 0x4001000, |
300 | .tuner_i2c_master = 1, | 298 | .tuner_i2c_master = I2C_1_MUX_3, |
301 | .demod_i2c_master = 2, | 299 | .demod_i2c_master = I2C_2, |
302 | .has_dvb = 1, | 300 | .has_dvb = 1, |
303 | .demod_addr = 0x02, | 301 | .demod_addr = 0x02, |
304 | .norm = V4L2_STD_PAL, | 302 | .norm = V4L2_STD_PAL, |
@@ -325,8 +323,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
325 | .ctl_pin_status_mask = 0xFFFFFFC4, | 323 | .ctl_pin_status_mask = 0xFFFFFFC4, |
326 | .agc_analog_digital_select_gpio = 0x0c, | 324 | .agc_analog_digital_select_gpio = 0x0c, |
327 | .gpio_pin_status_mask = 0x4001000, | 325 | .gpio_pin_status_mask = 0x4001000, |
328 | .tuner_i2c_master = 1, | 326 | .tuner_i2c_master = I2C_1_MUX_3, |
329 | .demod_i2c_master = 2, | 327 | .demod_i2c_master = I2C_2, |
330 | .has_dvb = 1, | 328 | .has_dvb = 1, |
331 | .demod_addr = 0x32, | 329 | .demod_addr = 0x32, |
332 | .norm = V4L2_STD_NTSC, | 330 | .norm = V4L2_STD_NTSC, |
@@ -353,8 +351,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
353 | .ctl_pin_status_mask = 0xFFFFFFC4, | 351 | .ctl_pin_status_mask = 0xFFFFFFC4, |
354 | .agc_analog_digital_select_gpio = 0x0c, | 352 | .agc_analog_digital_select_gpio = 0x0c, |
355 | .gpio_pin_status_mask = 0x4001000, | 353 | .gpio_pin_status_mask = 0x4001000, |
356 | .tuner_i2c_master = 1, | 354 | .tuner_i2c_master = I2C_1_MUX_1, |
357 | .demod_i2c_master = 2, | 355 | .demod_i2c_master = I2C_2, |
358 | .has_dvb = 1, | 356 | .has_dvb = 1, |
359 | .demod_addr = 0x0e, | 357 | .demod_addr = 0x0e, |
360 | .norm = V4L2_STD_NTSC, | 358 | .norm = V4L2_STD_NTSC, |
@@ -390,7 +388,6 @@ struct cx231xx_board cx231xx_boards[] = { | |||
390 | .norm = V4L2_STD_NTSC, | 388 | .norm = V4L2_STD_NTSC, |
391 | .no_alt_vanc = 1, | 389 | .no_alt_vanc = 1, |
392 | .external_av = 1, | 390 | .external_av = 1, |
393 | .dont_use_port_3 = 1, | ||
394 | .input = {{ | 391 | .input = {{ |
395 | .type = CX231XX_VMUX_COMPOSITE1, | 392 | .type = CX231XX_VMUX_COMPOSITE1, |
396 | .vmux = CX231XX_VIN_2_1, | 393 | .vmux = CX231XX_VIN_2_1, |
@@ -418,9 +415,9 @@ struct cx231xx_board cx231xx_boards[] = { | |||
418 | .tuner_scl_gpio = -1, | 415 | .tuner_scl_gpio = -1, |
419 | .tuner_sda_gpio = -1, | 416 | .tuner_sda_gpio = -1, |
420 | .gpio_pin_status_mask = 0x4001000, | 417 | .gpio_pin_status_mask = 0x4001000, |
421 | .tuner_i2c_master = 2, | 418 | .tuner_i2c_master = I2C_2, |
422 | .demod_i2c_master = 1, | 419 | .demod_i2c_master = I2C_1_MUX_3, |
423 | .ir_i2c_master = 2, | 420 | .ir_i2c_master = I2C_2, |
424 | .has_dvb = 1, | 421 | .has_dvb = 1, |
425 | .demod_addr = 0x10, | 422 | .demod_addr = 0x10, |
426 | .norm = V4L2_STD_PAL_M, | 423 | .norm = V4L2_STD_PAL_M, |
@@ -456,9 +453,9 @@ struct cx231xx_board cx231xx_boards[] = { | |||
456 | .tuner_scl_gpio = -1, | 453 | .tuner_scl_gpio = -1, |
457 | .tuner_sda_gpio = -1, | 454 | .tuner_sda_gpio = -1, |
458 | .gpio_pin_status_mask = 0x4001000, | 455 | .gpio_pin_status_mask = 0x4001000, |
459 | .tuner_i2c_master = 2, | 456 | .tuner_i2c_master = I2C_2, |
460 | .demod_i2c_master = 1, | 457 | .demod_i2c_master = I2C_1_MUX_3, |
461 | .ir_i2c_master = 2, | 458 | .ir_i2c_master = I2C_2, |
462 | .has_dvb = 1, | 459 | .has_dvb = 1, |
463 | .demod_addr = 0x10, | 460 | .demod_addr = 0x10, |
464 | .norm = V4L2_STD_NTSC_M, | 461 | .norm = V4L2_STD_NTSC_M, |
@@ -494,9 +491,9 @@ struct cx231xx_board cx231xx_boards[] = { | |||
494 | .tuner_scl_gpio = -1, | 491 | .tuner_scl_gpio = -1, |
495 | .tuner_sda_gpio = -1, | 492 | .tuner_sda_gpio = -1, |
496 | .gpio_pin_status_mask = 0x4001000, | 493 | .gpio_pin_status_mask = 0x4001000, |
497 | .tuner_i2c_master = 2, | 494 | .tuner_i2c_master = I2C_2, |
498 | .demod_i2c_master = 1, | 495 | .demod_i2c_master = I2C_1_MUX_3, |
499 | .ir_i2c_master = 2, | 496 | .ir_i2c_master = I2C_2, |
500 | .rc_map_name = RC_MAP_PIXELVIEW_002T, | 497 | .rc_map_name = RC_MAP_PIXELVIEW_002T, |
501 | .has_dvb = 1, | 498 | .has_dvb = 1, |
502 | .demod_addr = 0x10, | 499 | .demod_addr = 0x10, |
@@ -532,7 +529,6 @@ struct cx231xx_board cx231xx_boards[] = { | |||
532 | .norm = V4L2_STD_NTSC, | 529 | .norm = V4L2_STD_NTSC, |
533 | .no_alt_vanc = 1, | 530 | .no_alt_vanc = 1, |
534 | .external_av = 1, | 531 | .external_av = 1, |
535 | .dont_use_port_3 = 1, | ||
536 | 532 | ||
537 | .input = {{ | 533 | .input = {{ |
538 | .type = CX231XX_VMUX_COMPOSITE1, | 534 | .type = CX231XX_VMUX_COMPOSITE1, |
@@ -587,7 +583,7 @@ struct cx231xx_board cx231xx_boards[] = { | |||
587 | .ctl_pin_status_mask = 0xFFFFFFC4, | 583 | .ctl_pin_status_mask = 0xFFFFFFC4, |
588 | .agc_analog_digital_select_gpio = 0x0c, | 584 | .agc_analog_digital_select_gpio = 0x0c, |
589 | .gpio_pin_status_mask = 0x4001000, | 585 | .gpio_pin_status_mask = 0x4001000, |
590 | .tuner_i2c_master = 1, | 586 | .tuner_i2c_master = I2C_1_MUX_3, |
591 | .norm = V4L2_STD_PAL, | 587 | .norm = V4L2_STD_PAL, |
592 | 588 | ||
593 | .input = {{ | 589 | .input = {{ |
@@ -622,7 +618,7 @@ struct cx231xx_board cx231xx_boards[] = { | |||
622 | .ctl_pin_status_mask = 0xFFFFFFC4, | 618 | .ctl_pin_status_mask = 0xFFFFFFC4, |
623 | .agc_analog_digital_select_gpio = 0x0c, | 619 | .agc_analog_digital_select_gpio = 0x0c, |
624 | .gpio_pin_status_mask = 0x4001000, | 620 | .gpio_pin_status_mask = 0x4001000, |
625 | .tuner_i2c_master = 1, | 621 | .tuner_i2c_master = I2C_1_MUX_3, |
626 | .norm = V4L2_STD_NTSC, | 622 | .norm = V4L2_STD_NTSC, |
627 | 623 | ||
628 | .input = {{ | 624 | .input = {{ |
@@ -656,7 +652,6 @@ struct cx231xx_board cx231xx_boards[] = { | |||
656 | .norm = V4L2_STD_NTSC, | 652 | .norm = V4L2_STD_NTSC, |
657 | .no_alt_vanc = 1, | 653 | .no_alt_vanc = 1, |
658 | .external_av = 1, | 654 | .external_av = 1, |
659 | .dont_use_port_3 = 1, | ||
660 | .input = {{ | 655 | .input = {{ |
661 | .type = CX231XX_VMUX_COMPOSITE1, | 656 | .type = CX231XX_VMUX_COMPOSITE1, |
662 | .vmux = CX231XX_VIN_2_1, | 657 | .vmux = CX231XX_VIN_2_1, |
@@ -677,13 +672,12 @@ struct cx231xx_board cx231xx_boards[] = { | |||
677 | .decoder = CX231XX_AVDECODER, | 672 | .decoder = CX231XX_AVDECODER, |
678 | .output_mode = OUT_MODE_VIP11, | 673 | .output_mode = OUT_MODE_VIP11, |
679 | .ctl_pin_status_mask = 0xFFFFFFC4, | 674 | .ctl_pin_status_mask = 0xFFFFFFC4, |
680 | .agc_analog_digital_select_gpio = 0x0c, | 675 | .agc_analog_digital_select_gpio = 0x0c, |
681 | /* According with PV CxPlrCAP.inf file */ | 676 | /* According with PV CxPlrCAP.inf file */ |
682 | .gpio_pin_status_mask = 0x4001000, | 677 | .gpio_pin_status_mask = 0x4001000, |
683 | .norm = V4L2_STD_NTSC, | 678 | .norm = V4L2_STD_NTSC, |
684 | .no_alt_vanc = 1, | 679 | .no_alt_vanc = 1, |
685 | .external_av = 1, | 680 | .external_av = 1, |
686 | .dont_use_port_3 = 1, | ||
687 | /*.has_417 = 1, */ | 681 | /*.has_417 = 1, */ |
688 | /* This board is believed to have a hardware encoding chip | 682 | /* This board is believed to have a hardware encoding chip |
689 | * supporting mpeg1/2/4, but as the 417 is apparently not | 683 | * supporting mpeg1/2/4, but as the 417 is apparently not |
@@ -718,8 +712,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
718 | .ctl_pin_status_mask = 0xFFFFFFC4, | 712 | .ctl_pin_status_mask = 0xFFFFFFC4, |
719 | .agc_analog_digital_select_gpio = 0x0c, | 713 | .agc_analog_digital_select_gpio = 0x0c, |
720 | .gpio_pin_status_mask = 0x4001000, | 714 | .gpio_pin_status_mask = 0x4001000, |
721 | .tuner_i2c_master = 1, | 715 | .tuner_i2c_master = I2C_1_MUX_3, |
722 | .demod_i2c_master = 2, | 716 | .demod_i2c_master = I2C_2, |
723 | .has_dvb = 1, | 717 | .has_dvb = 1, |
724 | .demod_addr = 0x0e, | 718 | .demod_addr = 0x0e, |
725 | .norm = V4L2_STD_PAL, | 719 | .norm = V4L2_STD_PAL, |
@@ -757,8 +751,8 @@ struct cx231xx_board cx231xx_boards[] = { | |||
757 | .ctl_pin_status_mask = 0xFFFFFFC4, | 751 | .ctl_pin_status_mask = 0xFFFFFFC4, |
758 | .agc_analog_digital_select_gpio = 0x0c, | 752 | .agc_analog_digital_select_gpio = 0x0c, |
759 | .gpio_pin_status_mask = 0x4001000, | 753 | .gpio_pin_status_mask = 0x4001000, |
760 | .tuner_i2c_master = 1, | 754 | .tuner_i2c_master = I2C_1_MUX_3, |
761 | .demod_i2c_master = 2, | 755 | .demod_i2c_master = I2C_2, |
762 | .has_dvb = 1, | 756 | .has_dvb = 1, |
763 | .demod_addr = 0x0e, | 757 | .demod_addr = 0x0e, |
764 | .norm = V4L2_STD_PAL, | 758 | .norm = V4L2_STD_PAL, |
@@ -861,9 +855,9 @@ int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) | |||
861 | 855 | ||
862 | if (dev->tuner_type == TUNER_XC5000) { | 856 | if (dev->tuner_type == TUNER_XC5000) { |
863 | if (command == XC5000_TUNER_RESET) { | 857 | if (command == XC5000_TUNER_RESET) { |
864 | cx231xx_info | 858 | dev_dbg(dev->dev, |
865 | ("Tuner CB: RESET: cmd %d : tuner type %d \n", | 859 | "Tuner CB: RESET: cmd %d : tuner type %d\n", |
866 | command, dev->tuner_type); | 860 | command, dev->tuner_type); |
867 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | 861 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
868 | 1); | 862 | 1); |
869 | msleep(10); | 863 | msleep(10); |
@@ -921,8 +915,8 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) | |||
921 | 915 | ||
922 | cx231xx_set_model(dev); | 916 | cx231xx_set_model(dev); |
923 | 917 | ||
924 | cx231xx_info("Identified as %s (card=%d)\n", | 918 | dev_info(dev->dev, "Identified as %s (card=%d)\n", |
925 | dev->board.name, dev->model); | 919 | dev->board.name, dev->model); |
926 | 920 | ||
927 | /* set the direction for GPIO pins */ | 921 | /* set the direction for GPIO pins */ |
928 | if (dev->board.tuner_gpio) { | 922 | if (dev->board.tuner_gpio) { |
@@ -980,25 +974,22 @@ static void cx231xx_config_tuner(struct cx231xx *dev) | |||
980 | 974 | ||
981 | } | 975 | } |
982 | 976 | ||
983 | static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len) | 977 | static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, |
978 | u8 *eedata, int len) | ||
984 | { | 979 | { |
985 | int ret = 0; | 980 | int ret = 0; |
986 | u8 addr = 0xa0 >> 1; | ||
987 | u8 start_offset = 0; | 981 | u8 start_offset = 0; |
988 | int len_todo = len; | 982 | int len_todo = len; |
989 | u8 *eedata_cur = eedata; | 983 | u8 *eedata_cur = eedata; |
990 | int i; | 984 | int i; |
991 | struct i2c_msg msg_write = { .addr = addr, .flags = 0, | 985 | struct i2c_msg msg_write = { .addr = client->addr, .flags = 0, |
992 | .buf = &start_offset, .len = 1 }; | 986 | .buf = &start_offset, .len = 1 }; |
993 | struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD }; | 987 | struct i2c_msg msg_read = { .addr = client->addr, .flags = I2C_M_RD }; |
994 | |||
995 | /* mutex_lock(&dev->i2c_lock); */ | ||
996 | cx231xx_enable_i2c_port_3(dev, false); | ||
997 | 988 | ||
998 | /* start reading at offset 0 */ | 989 | /* start reading at offset 0 */ |
999 | ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1); | 990 | ret = i2c_transfer(client->adapter, &msg_write, 1); |
1000 | if (ret < 0) { | 991 | if (ret < 0) { |
1001 | cx231xx_err("Can't read eeprom\n"); | 992 | dev_err(dev->dev, "Can't read eeprom\n"); |
1002 | return ret; | 993 | return ret; |
1003 | } | 994 | } |
1004 | 995 | ||
@@ -1006,20 +997,18 @@ static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len) | |||
1006 | msg_read.len = (len_todo > 64) ? 64 : len_todo; | 997 | msg_read.len = (len_todo > 64) ? 64 : len_todo; |
1007 | msg_read.buf = eedata_cur; | 998 | msg_read.buf = eedata_cur; |
1008 | 999 | ||
1009 | ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1); | 1000 | ret = i2c_transfer(client->adapter, &msg_read, 1); |
1010 | if (ret < 0) { | 1001 | if (ret < 0) { |
1011 | cx231xx_err("Can't read eeprom\n"); | 1002 | dev_err(dev->dev, "Can't read eeprom\n"); |
1012 | return ret; | 1003 | return ret; |
1013 | } | 1004 | } |
1014 | eedata_cur += msg_read.len; | 1005 | eedata_cur += msg_read.len; |
1015 | len_todo -= msg_read.len; | 1006 | len_todo -= msg_read.len; |
1016 | } | 1007 | } |
1017 | 1008 | ||
1018 | cx231xx_enable_i2c_port_3(dev, true); | ||
1019 | /* mutex_unlock(&dev->i2c_lock); */ | ||
1020 | |||
1021 | for (i = 0; i + 15 < len; i += 16) | 1009 | for (i = 0; i + 15 < len; i += 16) |
1022 | cx231xx_info("i2c eeprom %02x: %*ph\n", i, 16, &eedata[i]); | 1010 | dev_dbg(dev->dev, "i2c eeprom %02x: %*ph\n", |
1011 | i, 16, &eedata[i]); | ||
1023 | 1012 | ||
1024 | return 0; | 1013 | return 0; |
1025 | } | 1014 | } |
@@ -1036,22 +1025,26 @@ void cx231xx_card_setup(struct cx231xx *dev) | |||
1036 | /* request some modules */ | 1025 | /* request some modules */ |
1037 | if (dev->board.decoder == CX231XX_AVDECODER) { | 1026 | if (dev->board.decoder == CX231XX_AVDECODER) { |
1038 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, | 1027 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
1039 | &dev->i2c_bus[0].i2c_adap, | 1028 | cx231xx_get_i2c_adap(dev, I2C_0), |
1040 | "cx25840", 0x88 >> 1, NULL); | 1029 | "cx25840", 0x88 >> 1, NULL); |
1041 | if (dev->sd_cx25840 == NULL) | 1030 | if (dev->sd_cx25840 == NULL) |
1042 | cx231xx_info("cx25840 subdev registration failure\n"); | 1031 | dev_err(dev->dev, |
1032 | "cx25840 subdev registration failure\n"); | ||
1043 | cx25840_call(dev, core, load_fw); | 1033 | cx25840_call(dev, core, load_fw); |
1044 | 1034 | ||
1045 | } | 1035 | } |
1046 | 1036 | ||
1047 | /* Initialize the tuner */ | 1037 | /* Initialize the tuner */ |
1048 | if (dev->board.tuner_type != TUNER_ABSENT) { | 1038 | if (dev->board.tuner_type != TUNER_ABSENT) { |
1039 | struct i2c_adapter *tuner_i2c = cx231xx_get_i2c_adap(dev, | ||
1040 | dev->board.tuner_i2c_master); | ||
1049 | dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, | 1041 | dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
1050 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 1042 | tuner_i2c, |
1051 | "tuner", | 1043 | "tuner", |
1052 | dev->tuner_addr, NULL); | 1044 | dev->tuner_addr, NULL); |
1053 | if (dev->sd_tuner == NULL) | 1045 | if (dev->sd_tuner == NULL) |
1054 | cx231xx_info("tuner subdev registration failure\n"); | 1046 | dev_err(dev->dev, |
1047 | "tuner subdev registration failure\n"); | ||
1055 | else | 1048 | else |
1056 | cx231xx_config_tuner(dev); | 1049 | cx231xx_config_tuner(dev); |
1057 | } | 1050 | } |
@@ -1062,9 +1055,14 @@ void cx231xx_card_setup(struct cx231xx *dev) | |||
1062 | { | 1055 | { |
1063 | struct tveeprom tvee; | 1056 | struct tveeprom tvee; |
1064 | static u8 eeprom[256]; | 1057 | static u8 eeprom[256]; |
1058 | struct i2c_client client; | ||
1059 | |||
1060 | memset(&client, 0, sizeof(client)); | ||
1061 | client.adapter = cx231xx_get_i2c_adap(dev, I2C_1_MUX_1); | ||
1062 | client.addr = 0xa0 >> 1; | ||
1065 | 1063 | ||
1066 | read_eeprom(dev, eeprom, sizeof(eeprom)); | 1064 | read_eeprom(dev, &client, eeprom, sizeof(eeprom)); |
1067 | tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client, | 1065 | tveeprom_hauppauge_analog(&client, |
1068 | &tvee, eeprom + 0xc0); | 1066 | &tvee, eeprom + 0xc0); |
1069 | break; | 1067 | break; |
1070 | } | 1068 | } |
@@ -1152,7 +1150,7 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, | |||
1152 | /* Query cx231xx to find what pcb config it is related to */ | 1150 | /* Query cx231xx to find what pcb config it is related to */ |
1153 | retval = initialize_cx231xx(dev); | 1151 | retval = initialize_cx231xx(dev); |
1154 | if (retval < 0) { | 1152 | if (retval < 0) { |
1155 | cx231xx_errdev("Failed to read PCB config\n"); | 1153 | dev_err(dev->dev, "Failed to read PCB config\n"); |
1156 | return retval; | 1154 | return retval; |
1157 | } | 1155 | } |
1158 | 1156 | ||
@@ -1168,7 +1166,7 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, | |||
1168 | 1166 | ||
1169 | retval = cx231xx_config(dev); | 1167 | retval = cx231xx_config(dev); |
1170 | if (retval) { | 1168 | if (retval) { |
1171 | cx231xx_errdev("error configuring device\n"); | 1169 | dev_err(dev->dev, "error configuring device\n"); |
1172 | return -ENOMEM; | 1170 | return -ENOMEM; |
1173 | } | 1171 | } |
1174 | 1172 | ||
@@ -1178,8 +1176,9 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, | |||
1178 | /* register i2c bus */ | 1176 | /* register i2c bus */ |
1179 | retval = cx231xx_dev_init(dev); | 1177 | retval = cx231xx_dev_init(dev); |
1180 | if (retval) { | 1178 | if (retval) { |
1181 | cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", | 1179 | dev_err(dev->dev, |
1182 | __func__, retval); | 1180 | "%s: cx231xx_i2c_register - errCode [%d]!\n", |
1181 | __func__, retval); | ||
1183 | goto err_dev_init; | 1182 | goto err_dev_init; |
1184 | } | 1183 | } |
1185 | 1184 | ||
@@ -1200,8 +1199,8 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, | |||
1200 | 1199 | ||
1201 | retval = cx231xx_config(dev); | 1200 | retval = cx231xx_config(dev); |
1202 | if (retval) { | 1201 | if (retval) { |
1203 | cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", | 1202 | dev_err(dev->dev, "%s: cx231xx_config - errCode [%d]!\n", |
1204 | __func__, retval); | 1203 | __func__, retval); |
1205 | goto err_dev_init; | 1204 | goto err_dev_init; |
1206 | } | 1205 | } |
1207 | 1206 | ||
@@ -1217,11 +1216,11 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, | |||
1217 | cx231xx_add_into_devlist(dev); | 1216 | cx231xx_add_into_devlist(dev); |
1218 | 1217 | ||
1219 | if (dev->board.has_417) { | 1218 | if (dev->board.has_417) { |
1220 | printk(KERN_INFO "attach 417 %d\n", dev->model); | 1219 | dev_info(dev->dev, "attach 417 %d\n", dev->model); |
1221 | if (cx231xx_417_register(dev) < 0) { | 1220 | if (cx231xx_417_register(dev) < 0) { |
1222 | printk(KERN_ERR | 1221 | dev_err(dev->dev, |
1223 | "%s() Failed to register 417 on VID_B\n", | 1222 | "%s() Failed to register 417 on VID_B\n", |
1224 | __func__); | 1223 | __func__); |
1225 | } | 1224 | } |
1226 | } | 1225 | } |
1227 | 1226 | ||
@@ -1285,7 +1284,8 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, | |||
1285 | /* compute alternate max packet sizes for video */ | 1284 | /* compute alternate max packet sizes for video */ |
1286 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.video_index + 1; | 1285 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.video_index + 1; |
1287 | if (idx >= dev->max_iad_interface_count) { | 1286 | if (idx >= dev->max_iad_interface_count) { |
1288 | cx231xx_errdev("Video PCB interface #%d doesn't exist\n", idx); | 1287 | dev_err(dev->dev, |
1288 | "Video PCB interface #%d doesn't exist\n", idx); | ||
1289 | return -ENODEV; | 1289 | return -ENODEV; |
1290 | } | 1290 | } |
1291 | 1291 | ||
@@ -1294,28 +1294,29 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, | |||
1294 | dev->video_mode.end_point_addr = uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress; | 1294 | dev->video_mode.end_point_addr = uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress; |
1295 | dev->video_mode.num_alt = uif->num_altsetting; | 1295 | dev->video_mode.num_alt = uif->num_altsetting; |
1296 | 1296 | ||
1297 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | 1297 | dev_info(dev->dev, |
1298 | dev->video_mode.end_point_addr, | 1298 | "video EndPoint Addr 0x%x, Alternate settings: %i\n", |
1299 | dev->video_mode.num_alt); | 1299 | dev->video_mode.end_point_addr, |
1300 | dev->video_mode.num_alt); | ||
1300 | 1301 | ||
1301 | dev->video_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->video_mode.num_alt, GFP_KERNEL); | 1302 | dev->video_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->video_mode.num_alt, GFP_KERNEL); |
1302 | if (dev->video_mode.alt_max_pkt_size == NULL) { | 1303 | if (dev->video_mode.alt_max_pkt_size == NULL) |
1303 | cx231xx_errdev("out of memory!\n"); | ||
1304 | return -ENOMEM; | 1304 | return -ENOMEM; |
1305 | } | ||
1306 | 1305 | ||
1307 | for (i = 0; i < dev->video_mode.num_alt; i++) { | 1306 | for (i = 0; i < dev->video_mode.num_alt; i++) { |
1308 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.wMaxPacketSize); | 1307 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.wMaxPacketSize); |
1309 | dev->video_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1308 | dev->video_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1310 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 1309 | dev_dbg(dev->dev, |
1311 | dev->video_mode.alt_max_pkt_size[i]); | 1310 | "Alternate setting %i, max size= %i\n", i, |
1311 | dev->video_mode.alt_max_pkt_size[i]); | ||
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | /* VBI Init */ | 1314 | /* VBI Init */ |
1315 | 1315 | ||
1316 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index + 1; | 1316 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index + 1; |
1317 | if (idx >= dev->max_iad_interface_count) { | 1317 | if (idx >= dev->max_iad_interface_count) { |
1318 | cx231xx_errdev("VBI PCB interface #%d doesn't exist\n", idx); | 1318 | dev_err(dev->dev, |
1319 | "VBI PCB interface #%d doesn't exist\n", idx); | ||
1319 | return -ENODEV; | 1320 | return -ENODEV; |
1320 | } | 1321 | } |
1321 | uif = udev->actconfig->interface[idx]; | 1322 | uif = udev->actconfig->interface[idx]; |
@@ -1325,16 +1326,15 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, | |||
1325 | bEndpointAddress; | 1326 | bEndpointAddress; |
1326 | 1327 | ||
1327 | dev->vbi_mode.num_alt = uif->num_altsetting; | 1328 | dev->vbi_mode.num_alt = uif->num_altsetting; |
1328 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | 1329 | dev_info(dev->dev, |
1329 | dev->vbi_mode.end_point_addr, | 1330 | "VBI EndPoint Addr 0x%x, Alternate settings: %i\n", |
1330 | dev->vbi_mode.num_alt); | 1331 | dev->vbi_mode.end_point_addr, |
1332 | dev->vbi_mode.num_alt); | ||
1331 | 1333 | ||
1332 | /* compute alternate max packet sizes for vbi */ | 1334 | /* compute alternate max packet sizes for vbi */ |
1333 | dev->vbi_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->vbi_mode.num_alt, GFP_KERNEL); | 1335 | dev->vbi_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->vbi_mode.num_alt, GFP_KERNEL); |
1334 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | 1336 | if (dev->vbi_mode.alt_max_pkt_size == NULL) |
1335 | cx231xx_errdev("out of memory!\n"); | ||
1336 | return -ENOMEM; | 1337 | return -ENOMEM; |
1337 | } | ||
1338 | 1338 | ||
1339 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { | 1339 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { |
1340 | u16 tmp = | 1340 | u16 tmp = |
@@ -1342,8 +1342,9 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, | |||
1342 | desc.wMaxPacketSize); | 1342 | desc.wMaxPacketSize); |
1343 | dev->vbi_mode.alt_max_pkt_size[i] = | 1343 | dev->vbi_mode.alt_max_pkt_size[i] = |
1344 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1344 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1345 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 1345 | dev_dbg(dev->dev, |
1346 | dev->vbi_mode.alt_max_pkt_size[i]); | 1346 | "Alternate setting %i, max size= %i\n", i, |
1347 | dev->vbi_mode.alt_max_pkt_size[i]); | ||
1347 | } | 1348 | } |
1348 | 1349 | ||
1349 | /* Sliced CC VBI init */ | 1350 | /* Sliced CC VBI init */ |
@@ -1351,7 +1352,8 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, | |||
1351 | /* compute alternate max packet sizes for sliced CC */ | 1352 | /* compute alternate max packet sizes for sliced CC */ |
1352 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index + 1; | 1353 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index + 1; |
1353 | if (idx >= dev->max_iad_interface_count) { | 1354 | if (idx >= dev->max_iad_interface_count) { |
1354 | cx231xx_errdev("Sliced CC PCB interface #%d doesn't exist\n", idx); | 1355 | dev_err(dev->dev, |
1356 | "Sliced CC PCB interface #%d doesn't exist\n", idx); | ||
1355 | return -ENODEV; | 1357 | return -ENODEV; |
1356 | } | 1358 | } |
1357 | uif = udev->actconfig->interface[idx]; | 1359 | uif = udev->actconfig->interface[idx]; |
@@ -1361,23 +1363,22 @@ static int cx231xx_init_v4l2(struct cx231xx *dev, | |||
1361 | bEndpointAddress; | 1363 | bEndpointAddress; |
1362 | 1364 | ||
1363 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; | 1365 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; |
1364 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | 1366 | dev_info(dev->dev, |
1365 | dev->sliced_cc_mode.end_point_addr, | 1367 | "sliced CC EndPoint Addr 0x%x, Alternate settings: %i\n", |
1366 | dev->sliced_cc_mode.num_alt); | 1368 | dev->sliced_cc_mode.end_point_addr, |
1369 | dev->sliced_cc_mode.num_alt); | ||
1367 | dev->sliced_cc_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->sliced_cc_mode.num_alt, GFP_KERNEL); | 1370 | dev->sliced_cc_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->sliced_cc_mode.num_alt, GFP_KERNEL); |
1368 | 1371 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) | |
1369 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | ||
1370 | cx231xx_errdev("out of memory!\n"); | ||
1371 | return -ENOMEM; | 1372 | return -ENOMEM; |
1372 | } | ||
1373 | 1373 | ||
1374 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { | 1374 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { |
1375 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | 1375 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
1376 | desc.wMaxPacketSize); | 1376 | desc.wMaxPacketSize); |
1377 | dev->sliced_cc_mode.alt_max_pkt_size[i] = | 1377 | dev->sliced_cc_mode.alt_max_pkt_size[i] = |
1378 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1378 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1379 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 1379 | dev_dbg(dev->dev, |
1380 | dev->sliced_cc_mode.alt_max_pkt_size[i]); | 1380 | "Alternate setting %i, max size= %i\n", i, |
1381 | dev->sliced_cc_mode.alt_max_pkt_size[i]); | ||
1381 | } | 1382 | } |
1382 | 1383 | ||
1383 | return 0; | 1384 | return 0; |
@@ -1391,6 +1392,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1391 | const struct usb_device_id *id) | 1392 | const struct usb_device_id *id) |
1392 | { | 1393 | { |
1393 | struct usb_device *udev; | 1394 | struct usb_device *udev; |
1395 | struct device *d = &interface->dev; | ||
1394 | struct usb_interface *uif; | 1396 | struct usb_interface *uif; |
1395 | struct cx231xx *dev = NULL; | 1397 | struct cx231xx *dev = NULL; |
1396 | int retval = -ENODEV; | 1398 | int retval = -ENODEV; |
@@ -1401,6 +1403,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1401 | struct usb_interface_assoc_descriptor *assoc_desc; | 1403 | struct usb_interface_assoc_descriptor *assoc_desc; |
1402 | 1404 | ||
1403 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | 1405 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
1406 | udev = usb_get_dev(interface_to_usbdev(interface)); | ||
1404 | 1407 | ||
1405 | /* | 1408 | /* |
1406 | * Interface number 0 - IR interface (handled by mceusb driver) | 1409 | * Interface number 0 - IR interface (handled by mceusb driver) |
@@ -1414,18 +1417,16 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1414 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); | 1417 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); |
1415 | if (nr >= CX231XX_MAXBOARDS) { | 1418 | if (nr >= CX231XX_MAXBOARDS) { |
1416 | /* No free device slots */ | 1419 | /* No free device slots */ |
1417 | cx231xx_err(DRIVER_NAME ": Supports only %i devices.\n", | 1420 | dev_err(d, |
1418 | CX231XX_MAXBOARDS); | 1421 | "Supports only %i devices.\n", |
1422 | CX231XX_MAXBOARDS); | ||
1419 | return -ENOMEM; | 1423 | return -ENOMEM; |
1420 | } | 1424 | } |
1421 | } while (test_and_set_bit(nr, &cx231xx_devused)); | 1425 | } while (test_and_set_bit(nr, &cx231xx_devused)); |
1422 | 1426 | ||
1423 | udev = usb_get_dev(interface_to_usbdev(interface)); | ||
1424 | |||
1425 | /* allocate memory for our device state and initialize it */ | 1427 | /* allocate memory for our device state and initialize it */ |
1426 | dev = devm_kzalloc(&udev->dev, sizeof(*dev), GFP_KERNEL); | 1428 | dev = devm_kzalloc(&udev->dev, sizeof(*dev), GFP_KERNEL); |
1427 | if (dev == NULL) { | 1429 | if (dev == NULL) { |
1428 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); | ||
1429 | clear_bit(nr, &cx231xx_devused); | 1430 | clear_bit(nr, &cx231xx_devused); |
1430 | return -ENOMEM; | 1431 | return -ENOMEM; |
1431 | } | 1432 | } |
@@ -1434,6 +1435,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1434 | dev->devno = nr; | 1435 | dev->devno = nr; |
1435 | dev->model = id->driver_info; | 1436 | dev->model = id->driver_info; |
1436 | dev->video_mode.alt = -1; | 1437 | dev->video_mode.alt = -1; |
1438 | dev->dev = d; | ||
1437 | 1439 | ||
1438 | dev->interface_count++; | 1440 | dev->interface_count++; |
1439 | /* reset gpio dir and value */ | 1441 | /* reset gpio dir and value */ |
@@ -1472,14 +1474,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1472 | speed = "unknown"; | 1474 | speed = "unknown"; |
1473 | } | 1475 | } |
1474 | 1476 | ||
1475 | cx231xx_info("New device %s %s @ %s Mbps " | 1477 | dev_info(d, |
1476 | "(%04x:%04x) with %d interfaces\n", | 1478 | "New device %s %s @ %s Mbps (%04x:%04x) with %d interfaces\n", |
1477 | udev->manufacturer ? udev->manufacturer : "", | 1479 | udev->manufacturer ? udev->manufacturer : "", |
1478 | udev->product ? udev->product : "", | 1480 | udev->product ? udev->product : "", |
1479 | speed, | 1481 | speed, |
1480 | le16_to_cpu(udev->descriptor.idVendor), | 1482 | le16_to_cpu(udev->descriptor.idVendor), |
1481 | le16_to_cpu(udev->descriptor.idProduct), | 1483 | le16_to_cpu(udev->descriptor.idProduct), |
1482 | dev->max_iad_interface_count); | 1484 | dev->max_iad_interface_count); |
1483 | 1485 | ||
1484 | /* increment interface count */ | 1486 | /* increment interface count */ |
1485 | dev->interface_count++; | 1487 | dev->interface_count++; |
@@ -1489,13 +1491,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1489 | 1491 | ||
1490 | assoc_desc = udev->actconfig->intf_assoc[0]; | 1492 | assoc_desc = udev->actconfig->intf_assoc[0]; |
1491 | if (assoc_desc->bFirstInterface != ifnum) { | 1493 | if (assoc_desc->bFirstInterface != ifnum) { |
1492 | cx231xx_err(DRIVER_NAME ": Not found " | 1494 | dev_err(d, "Not found matching IAD interface\n"); |
1493 | "matching IAD interface\n"); | ||
1494 | retval = -ENODEV; | 1495 | retval = -ENODEV; |
1495 | goto err_if; | 1496 | goto err_if; |
1496 | } | 1497 | } |
1497 | 1498 | ||
1498 | cx231xx_info("registering interface %d\n", ifnum); | 1499 | dev_dbg(d, "registering interface %d\n", ifnum); |
1499 | 1500 | ||
1500 | /* save our data pointer in this interface device */ | 1501 | /* save our data pointer in this interface device */ |
1501 | usb_set_intfdata(interface, dev); | 1502 | usb_set_intfdata(interface, dev); |
@@ -1503,7 +1504,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1503 | /* Create v4l2 device */ | 1504 | /* Create v4l2 device */ |
1504 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | 1505 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); |
1505 | if (retval) { | 1506 | if (retval) { |
1506 | cx231xx_errdev("v4l2_device_register failed\n"); | 1507 | dev_err(d, "v4l2_device_register failed\n"); |
1507 | goto err_v4l2; | 1508 | goto err_v4l2; |
1508 | } | 1509 | } |
1509 | 1510 | ||
@@ -1520,7 +1521,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1520 | /* compute alternate max packet sizes for TS1 */ | 1521 | /* compute alternate max packet sizes for TS1 */ |
1521 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index + 1; | 1522 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index + 1; |
1522 | if (idx >= dev->max_iad_interface_count) { | 1523 | if (idx >= dev->max_iad_interface_count) { |
1523 | cx231xx_errdev("TS1 PCB interface #%d doesn't exist\n", idx); | 1524 | dev_err(d, "TS1 PCB interface #%d doesn't exist\n", |
1525 | idx); | ||
1524 | retval = -ENODEV; | 1526 | retval = -ENODEV; |
1525 | goto err_video_alt; | 1527 | goto err_video_alt; |
1526 | } | 1528 | } |
@@ -1531,13 +1533,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1531 | desc.bEndpointAddress; | 1533 | desc.bEndpointAddress; |
1532 | 1534 | ||
1533 | dev->ts1_mode.num_alt = uif->num_altsetting; | 1535 | dev->ts1_mode.num_alt = uif->num_altsetting; |
1534 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | 1536 | dev_info(d, |
1535 | dev->ts1_mode.end_point_addr, | 1537 | "TS EndPoint Addr 0x%x, Alternate settings: %i\n", |
1536 | dev->ts1_mode.num_alt); | 1538 | dev->ts1_mode.end_point_addr, |
1539 | dev->ts1_mode.num_alt); | ||
1537 | 1540 | ||
1538 | dev->ts1_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->ts1_mode.num_alt, GFP_KERNEL); | 1541 | dev->ts1_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->ts1_mode.num_alt, GFP_KERNEL); |
1539 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | 1542 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { |
1540 | cx231xx_errdev("out of memory!\n"); | ||
1541 | retval = -ENOMEM; | 1543 | retval = -ENOMEM; |
1542 | goto err_video_alt; | 1544 | goto err_video_alt; |
1543 | } | 1545 | } |
@@ -1548,8 +1550,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1548 | wMaxPacketSize); | 1550 | wMaxPacketSize); |
1549 | dev->ts1_mode.alt_max_pkt_size[i] = | 1551 | dev->ts1_mode.alt_max_pkt_size[i] = |
1550 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1552 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1551 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 1553 | dev_dbg(d, "Alternate setting %i, max size= %i\n", |
1552 | dev->ts1_mode.alt_max_pkt_size[i]); | 1554 | i, dev->ts1_mode.alt_max_pkt_size[i]); |
1553 | } | 1555 | } |
1554 | } | 1556 | } |
1555 | 1557 | ||
@@ -1613,10 +1615,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
1613 | wake_up_interruptible_all(&dev->open); | 1615 | wake_up_interruptible_all(&dev->open); |
1614 | 1616 | ||
1615 | if (dev->users) { | 1617 | if (dev->users) { |
1616 | cx231xx_warn | 1618 | dev_warn(dev->dev, |
1617 | ("device %s is open! Deregistration and memory " | 1619 | "device %s is open! Deregistration and memory deallocation are deferred on close.\n", |
1618 | "deallocation are deferred on close.\n", | 1620 | video_device_node_name(dev->vdev)); |
1619 | video_device_node_name(dev->vdev)); | ||
1620 | 1621 | ||
1621 | /* Even having users, it is safe to remove the RC i2c driver */ | 1622 | /* Even having users, it is safe to remove the RC i2c driver */ |
1622 | cx231xx_ir_exit(dev); | 1623 | cx231xx_ir_exit(dev); |
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c index 180103e48036..4a3f28c4e8d3 100644 --- a/drivers/media/usb/cx231xx/cx231xx-core.c +++ b/drivers/media/usb/cx231xx/cx231xx-core.c | |||
@@ -20,16 +20,15 @@ | |||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "cx231xx.h" | ||
23 | #include <linux/init.h> | 24 | #include <linux/init.h> |
24 | #include <linux/list.h> | 25 | #include <linux/list.h> |
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
27 | #include <linux/usb.h> | ||
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <media/v4l2-common.h> | 29 | #include <media/v4l2-common.h> |
30 | #include <media/tuner.h> | 30 | #include <media/tuner.h> |
31 | 31 | ||
32 | #include "cx231xx.h" | ||
33 | #include "cx231xx-reg.h" | 32 | #include "cx231xx-reg.h" |
34 | 33 | ||
35 | /* #define ENABLE_DEBUG_ISOC_FRAMES */ | 34 | /* #define ENABLE_DEBUG_ISOC_FRAMES */ |
@@ -99,10 +98,10 @@ int cx231xx_register_extension(struct cx231xx_ops *ops) | |||
99 | 98 | ||
100 | mutex_lock(&cx231xx_devlist_mutex); | 99 | mutex_lock(&cx231xx_devlist_mutex); |
101 | list_add_tail(&ops->next, &cx231xx_extension_devlist); | 100 | list_add_tail(&ops->next, &cx231xx_extension_devlist); |
102 | list_for_each_entry(dev, &cx231xx_devlist, devlist) | 101 | list_for_each_entry(dev, &cx231xx_devlist, devlist) { |
103 | ops->init(dev); | 102 | ops->init(dev); |
104 | 103 | dev_info(dev->dev, "%s initialized\n", ops->name); | |
105 | printk(KERN_INFO DRIVER_NAME ": %s initialized\n", ops->name); | 104 | } |
106 | mutex_unlock(&cx231xx_devlist_mutex); | 105 | mutex_unlock(&cx231xx_devlist_mutex); |
107 | return 0; | 106 | return 0; |
108 | } | 107 | } |
@@ -113,11 +112,11 @@ void cx231xx_unregister_extension(struct cx231xx_ops *ops) | |||
113 | struct cx231xx *dev = NULL; | 112 | struct cx231xx *dev = NULL; |
114 | 113 | ||
115 | mutex_lock(&cx231xx_devlist_mutex); | 114 | mutex_lock(&cx231xx_devlist_mutex); |
116 | list_for_each_entry(dev, &cx231xx_devlist, devlist) | 115 | list_for_each_entry(dev, &cx231xx_devlist, devlist) { |
117 | ops->fini(dev); | 116 | ops->fini(dev); |
117 | dev_info(dev->dev, "%s removed\n", ops->name); | ||
118 | } | ||
118 | 119 | ||
119 | |||
120 | printk(KERN_INFO DRIVER_NAME ": %s removed\n", ops->name); | ||
121 | list_del(&ops->next); | 120 | list_del(&ops->next); |
122 | mutex_unlock(&cx231xx_devlist_mutex); | 121 | mutex_unlock(&cx231xx_devlist_mutex); |
123 | } | 122 | } |
@@ -227,10 +226,9 @@ int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, | |||
227 | 226 | ||
228 | /* call common vendor command request */ | 227 | /* call common vendor command request */ |
229 | status = cx231xx_send_vendor_cmd(dev, &ven_req); | 228 | status = cx231xx_send_vendor_cmd(dev, &ven_req); |
230 | if (status < 0) { | 229 | if (status < 0 && !dev->i2c_scan_running) { |
231 | cx231xx_info | 230 | dev_err(dev->dev, "%s: failed with status -%d\n", |
232 | ("UsbInterface::sendCommand, failed with status -%d\n", | 231 | __func__, status); |
233 | status); | ||
234 | } | 232 | } |
235 | 233 | ||
236 | return status; | 234 | return status; |
@@ -524,9 +522,9 @@ int cx231xx_set_video_alternate(struct cx231xx *dev) | |||
524 | usb_set_interface(dev->udev, usb_interface_index, | 522 | usb_set_interface(dev->udev, usb_interface_index, |
525 | dev->video_mode.alt); | 523 | dev->video_mode.alt); |
526 | if (errCode < 0) { | 524 | if (errCode < 0) { |
527 | cx231xx_errdev | 525 | dev_err(dev->dev, |
528 | ("cannot change alt number to %d (error=%i)\n", | 526 | "cannot change alt number to %d (error=%i)\n", |
529 | dev->video_mode.alt, errCode); | 527 | dev->video_mode.alt, errCode); |
530 | return errCode; | 528 | return errCode; |
531 | } | 529 | } |
532 | } | 530 | } |
@@ -600,9 +598,9 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) | |||
600 | } | 598 | } |
601 | 599 | ||
602 | if (alt > 0 && max_pkt_size == 0) { | 600 | if (alt > 0 && max_pkt_size == 0) { |
603 | cx231xx_errdev | 601 | dev_err(dev->dev, |
604 | ("can't change interface %d alt no. to %d: Max. Pkt size = 0\n", | 602 | "can't change interface %d alt no. to %d: Max. Pkt size = 0\n", |
605 | usb_interface_index, alt); | 603 | usb_interface_index, alt); |
606 | /*To workaround error number=-71 on EP0 for videograbber, | 604 | /*To workaround error number=-71 on EP0 for videograbber, |
607 | need add following codes.*/ | 605 | need add following codes.*/ |
608 | if (dev->board.no_alt_vanc) | 606 | if (dev->board.no_alt_vanc) |
@@ -616,9 +614,9 @@ int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) | |||
616 | if (usb_interface_index > 0) { | 614 | if (usb_interface_index > 0) { |
617 | status = usb_set_interface(dev->udev, usb_interface_index, alt); | 615 | status = usb_set_interface(dev->udev, usb_interface_index, alt); |
618 | if (status < 0) { | 616 | if (status < 0) { |
619 | cx231xx_errdev | 617 | dev_err(dev->dev, |
620 | ("can't change interface %d alt no. to %d (err=%i)\n", | 618 | "can't change interface %d alt no. to %d (err=%i)\n", |
621 | usb_interface_index, alt, status); | 619 | usb_interface_index, alt, status); |
622 | return status; | 620 | return status; |
623 | } | 621 | } |
624 | } | 622 | } |
@@ -767,18 +765,17 @@ int cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size) | |||
767 | u32 *buffer; | 765 | u32 *buffer; |
768 | 766 | ||
769 | buffer = kzalloc(4096, GFP_KERNEL); | 767 | buffer = kzalloc(4096, GFP_KERNEL); |
770 | if (buffer == NULL) { | 768 | if (buffer == NULL) |
771 | cx231xx_info("out of mem\n"); | ||
772 | return -ENOMEM; | 769 | return -ENOMEM; |
773 | } | ||
774 | memcpy(&buffer[0], firmware, 4096); | 770 | memcpy(&buffer[0], firmware, 4096); |
775 | 771 | ||
776 | ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5), | 772 | ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5), |
777 | buffer, 4096, &actlen, 2000); | 773 | buffer, 4096, &actlen, 2000); |
778 | 774 | ||
779 | if (ret) | 775 | if (ret) |
780 | cx231xx_info("bulk message failed: %d (%d/%d)", ret, | 776 | dev_err(dev->dev, |
781 | size, actlen); | 777 | "bulk message failed: %d (%d/%d)", ret, |
778 | size, actlen); | ||
782 | else { | 779 | else { |
783 | errCode = actlen != size ? -1 : 0; | 780 | errCode = actlen != size ? -1 : 0; |
784 | } | 781 | } |
@@ -987,12 +984,8 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
987 | cx231xx_uninit_isoc(dev); | 984 | cx231xx_uninit_isoc(dev); |
988 | 985 | ||
989 | dma_q->p_left_data = kzalloc(4096, GFP_KERNEL); | 986 | dma_q->p_left_data = kzalloc(4096, GFP_KERNEL); |
990 | if (dma_q->p_left_data == NULL) { | 987 | if (dma_q->p_left_data == NULL) |
991 | cx231xx_info("out of mem\n"); | ||
992 | return -ENOMEM; | 988 | return -ENOMEM; |
993 | } | ||
994 | |||
995 | |||
996 | 989 | ||
997 | dev->video_mode.isoc_ctl.isoc_copy = isoc_copy; | 990 | dev->video_mode.isoc_ctl.isoc_copy = isoc_copy; |
998 | dev->video_mode.isoc_ctl.num_bufs = num_bufs; | 991 | dev->video_mode.isoc_ctl.num_bufs = num_bufs; |
@@ -1018,14 +1011,16 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
1018 | dev->video_mode.isoc_ctl.urb = | 1011 | dev->video_mode.isoc_ctl.urb = |
1019 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1012 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); |
1020 | if (!dev->video_mode.isoc_ctl.urb) { | 1013 | if (!dev->video_mode.isoc_ctl.urb) { |
1021 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | 1014 | dev_err(dev->dev, |
1015 | "cannot alloc memory for usb buffers\n"); | ||
1022 | return -ENOMEM; | 1016 | return -ENOMEM; |
1023 | } | 1017 | } |
1024 | 1018 | ||
1025 | dev->video_mode.isoc_ctl.transfer_buffer = | 1019 | dev->video_mode.isoc_ctl.transfer_buffer = |
1026 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1020 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); |
1027 | if (!dev->video_mode.isoc_ctl.transfer_buffer) { | 1021 | if (!dev->video_mode.isoc_ctl.transfer_buffer) { |
1028 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | 1022 | dev_err(dev->dev, |
1023 | "cannot allocate memory for usbtransfer\n"); | ||
1029 | kfree(dev->video_mode.isoc_ctl.urb); | 1024 | kfree(dev->video_mode.isoc_ctl.urb); |
1030 | return -ENOMEM; | 1025 | return -ENOMEM; |
1031 | } | 1026 | } |
@@ -1045,7 +1040,8 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
1045 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | 1040 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { |
1046 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); | 1041 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); |
1047 | if (!urb) { | 1042 | if (!urb) { |
1048 | cx231xx_err("cannot alloc isoc_ctl.urb %i\n", i); | 1043 | dev_err(dev->dev, |
1044 | "cannot alloc isoc_ctl.urb %i\n", i); | ||
1049 | cx231xx_uninit_isoc(dev); | 1045 | cx231xx_uninit_isoc(dev); |
1050 | return -ENOMEM; | 1046 | return -ENOMEM; |
1051 | } | 1047 | } |
@@ -1055,10 +1051,10 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
1055 | usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, | 1051 | usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, |
1056 | &urb->transfer_dma); | 1052 | &urb->transfer_dma); |
1057 | if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { | 1053 | if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { |
1058 | cx231xx_err("unable to allocate %i bytes for transfer" | 1054 | dev_err(dev->dev, |
1059 | " buffer %i%s\n", | 1055 | "unable to allocate %i bytes for transfer buffer %i%s\n", |
1060 | sb_size, i, | 1056 | sb_size, i, |
1061 | in_interrupt() ? " while in int" : ""); | 1057 | in_interrupt() ? " while in int" : ""); |
1062 | cx231xx_uninit_isoc(dev); | 1058 | cx231xx_uninit_isoc(dev); |
1063 | return -ENOMEM; | 1059 | return -ENOMEM; |
1064 | } | 1060 | } |
@@ -1090,8 +1086,9 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
1090 | rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], | 1086 | rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], |
1091 | GFP_ATOMIC); | 1087 | GFP_ATOMIC); |
1092 | if (rc) { | 1088 | if (rc) { |
1093 | cx231xx_err("submit of urb %i failed (error=%i)\n", i, | 1089 | dev_err(dev->dev, |
1094 | rc); | 1090 | "submit of urb %i failed (error=%i)\n", i, |
1091 | rc); | ||
1095 | cx231xx_uninit_isoc(dev); | 1092 | cx231xx_uninit_isoc(dev); |
1096 | return rc; | 1093 | return rc; |
1097 | } | 1094 | } |
@@ -1151,14 +1148,16 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | |||
1151 | dev->video_mode.bulk_ctl.urb = | 1148 | dev->video_mode.bulk_ctl.urb = |
1152 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1149 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); |
1153 | if (!dev->video_mode.bulk_ctl.urb) { | 1150 | if (!dev->video_mode.bulk_ctl.urb) { |
1154 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | 1151 | dev_err(dev->dev, |
1152 | "cannot alloc memory for usb buffers\n"); | ||
1155 | return -ENOMEM; | 1153 | return -ENOMEM; |
1156 | } | 1154 | } |
1157 | 1155 | ||
1158 | dev->video_mode.bulk_ctl.transfer_buffer = | 1156 | dev->video_mode.bulk_ctl.transfer_buffer = |
1159 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1157 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); |
1160 | if (!dev->video_mode.bulk_ctl.transfer_buffer) { | 1158 | if (!dev->video_mode.bulk_ctl.transfer_buffer) { |
1161 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | 1159 | dev_err(dev->dev, |
1160 | "cannot allocate memory for usbtransfer\n"); | ||
1162 | kfree(dev->video_mode.bulk_ctl.urb); | 1161 | kfree(dev->video_mode.bulk_ctl.urb); |
1163 | return -ENOMEM; | 1162 | return -ENOMEM; |
1164 | } | 1163 | } |
@@ -1178,7 +1177,8 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | |||
1178 | for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { | 1177 | for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { |
1179 | urb = usb_alloc_urb(0, GFP_KERNEL); | 1178 | urb = usb_alloc_urb(0, GFP_KERNEL); |
1180 | if (!urb) { | 1179 | if (!urb) { |
1181 | cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i); | 1180 | dev_err(dev->dev, |
1181 | "cannot alloc bulk_ctl.urb %i\n", i); | ||
1182 | cx231xx_uninit_bulk(dev); | 1182 | cx231xx_uninit_bulk(dev); |
1183 | return -ENOMEM; | 1183 | return -ENOMEM; |
1184 | } | 1184 | } |
@@ -1189,10 +1189,10 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | |||
1189 | usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, | 1189 | usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, |
1190 | &urb->transfer_dma); | 1190 | &urb->transfer_dma); |
1191 | if (!dev->video_mode.bulk_ctl.transfer_buffer[i]) { | 1191 | if (!dev->video_mode.bulk_ctl.transfer_buffer[i]) { |
1192 | cx231xx_err("unable to allocate %i bytes for transfer" | 1192 | dev_err(dev->dev, |
1193 | " buffer %i%s\n", | 1193 | "unable to allocate %i bytes for transfer buffer %i%s\n", |
1194 | sb_size, i, | 1194 | sb_size, i, |
1195 | in_interrupt() ? " while in int" : ""); | 1195 | in_interrupt() ? " while in int" : ""); |
1196 | cx231xx_uninit_bulk(dev); | 1196 | cx231xx_uninit_bulk(dev); |
1197 | return -ENOMEM; | 1197 | return -ENOMEM; |
1198 | } | 1198 | } |
@@ -1212,8 +1212,8 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | |||
1212 | rc = usb_submit_urb(dev->video_mode.bulk_ctl.urb[i], | 1212 | rc = usb_submit_urb(dev->video_mode.bulk_ctl.urb[i], |
1213 | GFP_ATOMIC); | 1213 | GFP_ATOMIC); |
1214 | if (rc) { | 1214 | if (rc) { |
1215 | cx231xx_err("submit of urb %i failed (error=%i)\n", i, | 1215 | dev_err(dev->dev, |
1216 | rc); | 1216 | "submit of urb %i failed (error=%i)\n", i, rc); |
1217 | cx231xx_uninit_bulk(dev); | 1217 | cx231xx_uninit_bulk(dev); |
1218 | return rc; | 1218 | return rc; |
1219 | } | 1219 | } |
@@ -1300,6 +1300,15 @@ int cx231xx_dev_init(struct cx231xx *dev) | |||
1300 | cx231xx_i2c_register(&dev->i2c_bus[1]); | 1300 | cx231xx_i2c_register(&dev->i2c_bus[1]); |
1301 | cx231xx_i2c_register(&dev->i2c_bus[2]); | 1301 | cx231xx_i2c_register(&dev->i2c_bus[2]); |
1302 | 1302 | ||
1303 | cx231xx_i2c_mux_register(dev, 0); | ||
1304 | cx231xx_i2c_mux_register(dev, 1); | ||
1305 | |||
1306 | /* scan the real bus segments in the order of physical port numbers */ | ||
1307 | cx231xx_do_i2c_scan(dev, I2C_0); | ||
1308 | cx231xx_do_i2c_scan(dev, I2C_1_MUX_1); | ||
1309 | cx231xx_do_i2c_scan(dev, I2C_2); | ||
1310 | cx231xx_do_i2c_scan(dev, I2C_1_MUX_3); | ||
1311 | |||
1303 | /* init hardware */ | 1312 | /* init hardware */ |
1304 | /* Note : with out calling set power mode function, | 1313 | /* Note : with out calling set power mode function, |
1305 | afe can not be set up correctly */ | 1314 | afe can not be set up correctly */ |
@@ -1307,18 +1316,18 @@ int cx231xx_dev_init(struct cx231xx *dev) | |||
1307 | errCode = cx231xx_set_power_mode(dev, | 1316 | errCode = cx231xx_set_power_mode(dev, |
1308 | POLARIS_AVMODE_ENXTERNAL_AV); | 1317 | POLARIS_AVMODE_ENXTERNAL_AV); |
1309 | if (errCode < 0) { | 1318 | if (errCode < 0) { |
1310 | cx231xx_errdev | 1319 | dev_err(dev->dev, |
1311 | ("%s: Failed to set Power - errCode [%d]!\n", | 1320 | "%s: Failed to set Power - errCode [%d]!\n", |
1312 | __func__, errCode); | 1321 | __func__, errCode); |
1313 | return errCode; | 1322 | return errCode; |
1314 | } | 1323 | } |
1315 | } else { | 1324 | } else { |
1316 | errCode = cx231xx_set_power_mode(dev, | 1325 | errCode = cx231xx_set_power_mode(dev, |
1317 | POLARIS_AVMODE_ANALOGT_TV); | 1326 | POLARIS_AVMODE_ANALOGT_TV); |
1318 | if (errCode < 0) { | 1327 | if (errCode < 0) { |
1319 | cx231xx_errdev | 1328 | dev_err(dev->dev, |
1320 | ("%s: Failed to set Power - errCode [%d]!\n", | 1329 | "%s: Failed to set Power - errCode [%d]!\n", |
1321 | __func__, errCode); | 1330 | __func__, errCode); |
1322 | return errCode; | 1331 | return errCode; |
1323 | } | 1332 | } |
1324 | } | 1333 | } |
@@ -1331,42 +1340,43 @@ int cx231xx_dev_init(struct cx231xx *dev) | |||
1331 | /* initialize Colibri block */ | 1340 | /* initialize Colibri block */ |
1332 | errCode = cx231xx_afe_init_super_block(dev, 0x23c); | 1341 | errCode = cx231xx_afe_init_super_block(dev, 0x23c); |
1333 | if (errCode < 0) { | 1342 | if (errCode < 0) { |
1334 | cx231xx_errdev | 1343 | dev_err(dev->dev, |
1335 | ("%s: cx231xx_afe init super block - errCode [%d]!\n", | 1344 | "%s: cx231xx_afe init super block - errCode [%d]!\n", |
1336 | __func__, errCode); | 1345 | __func__, errCode); |
1337 | return errCode; | 1346 | return errCode; |
1338 | } | 1347 | } |
1339 | errCode = cx231xx_afe_init_channels(dev); | 1348 | errCode = cx231xx_afe_init_channels(dev); |
1340 | if (errCode < 0) { | 1349 | if (errCode < 0) { |
1341 | cx231xx_errdev | 1350 | dev_err(dev->dev, |
1342 | ("%s: cx231xx_afe init channels - errCode [%d]!\n", | 1351 | "%s: cx231xx_afe init channels - errCode [%d]!\n", |
1343 | __func__, errCode); | 1352 | __func__, errCode); |
1344 | return errCode; | 1353 | return errCode; |
1345 | } | 1354 | } |
1346 | 1355 | ||
1347 | /* Set DIF in By pass mode */ | 1356 | /* Set DIF in By pass mode */ |
1348 | errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | 1357 | errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); |
1349 | if (errCode < 0) { | 1358 | if (errCode < 0) { |
1350 | cx231xx_errdev | 1359 | dev_err(dev->dev, |
1351 | ("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", | 1360 | "%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", |
1352 | __func__, errCode); | 1361 | __func__, errCode); |
1353 | return errCode; | 1362 | return errCode; |
1354 | } | 1363 | } |
1355 | 1364 | ||
1356 | /* I2S block related functions */ | 1365 | /* I2S block related functions */ |
1357 | errCode = cx231xx_i2s_blk_initialize(dev); | 1366 | errCode = cx231xx_i2s_blk_initialize(dev); |
1358 | if (errCode < 0) { | 1367 | if (errCode < 0) { |
1359 | cx231xx_errdev | 1368 | dev_err(dev->dev, |
1360 | ("%s: cx231xx_i2s block initialize - errCode [%d]!\n", | 1369 | "%s: cx231xx_i2s block initialize - errCode [%d]!\n", |
1361 | __func__, errCode); | 1370 | __func__, errCode); |
1362 | return errCode; | 1371 | return errCode; |
1363 | } | 1372 | } |
1364 | 1373 | ||
1365 | /* init control pins */ | 1374 | /* init control pins */ |
1366 | errCode = cx231xx_init_ctrl_pin_status(dev); | 1375 | errCode = cx231xx_init_ctrl_pin_status(dev); |
1367 | if (errCode < 0) { | 1376 | if (errCode < 0) { |
1368 | cx231xx_errdev("%s: cx231xx_init ctrl pins - errCode [%d]!\n", | 1377 | dev_err(dev->dev, |
1369 | __func__, errCode); | 1378 | "%s: cx231xx_init ctrl pins - errCode [%d]!\n", |
1379 | __func__, errCode); | ||
1370 | return errCode; | 1380 | return errCode; |
1371 | } | 1381 | } |
1372 | 1382 | ||
@@ -1391,9 +1401,9 @@ int cx231xx_dev_init(struct cx231xx *dev) | |||
1391 | break; | 1401 | break; |
1392 | } | 1402 | } |
1393 | if (errCode < 0) { | 1403 | if (errCode < 0) { |
1394 | cx231xx_errdev | 1404 | dev_err(dev->dev, |
1395 | ("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", | 1405 | "%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", |
1396 | __func__, errCode); | 1406 | __func__, errCode); |
1397 | return errCode; | 1407 | return errCode; |
1398 | } | 1408 | } |
1399 | 1409 | ||
@@ -1404,9 +1414,7 @@ int cx231xx_dev_init(struct cx231xx *dev) | |||
1404 | if (dev->board.has_dvb) | 1414 | if (dev->board.has_dvb) |
1405 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | 1415 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); |
1406 | 1416 | ||
1407 | /* set the I2C master port to 3 on channel 1 */ | 1417 | errCode = 0; |
1408 | errCode = cx231xx_enable_i2c_port_3(dev, true); | ||
1409 | |||
1410 | return errCode; | 1418 | return errCode; |
1411 | } | 1419 | } |
1412 | EXPORT_SYMBOL_GPL(cx231xx_dev_init); | 1420 | EXPORT_SYMBOL_GPL(cx231xx_dev_init); |
@@ -1414,6 +1422,8 @@ EXPORT_SYMBOL_GPL(cx231xx_dev_init); | |||
1414 | void cx231xx_dev_uninit(struct cx231xx *dev) | 1422 | void cx231xx_dev_uninit(struct cx231xx *dev) |
1415 | { | 1423 | { |
1416 | /* Un Initialize I2C bus */ | 1424 | /* Un Initialize I2C bus */ |
1425 | cx231xx_i2c_mux_unregister(dev, 1); | ||
1426 | cx231xx_i2c_mux_unregister(dev, 0); | ||
1417 | cx231xx_i2c_unregister(&dev->i2c_bus[2]); | 1427 | cx231xx_i2c_unregister(&dev->i2c_bus[2]); |
1418 | cx231xx_i2c_unregister(&dev->i2c_bus[1]); | 1428 | cx231xx_i2c_unregister(&dev->i2c_bus[1]); |
1419 | cx231xx_i2c_unregister(&dev->i2c_bus[0]); | 1429 | cx231xx_i2c_unregister(&dev->i2c_bus[0]); |
@@ -1468,9 +1478,8 @@ int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val, | |||
1468 | /* call common vendor command request */ | 1478 | /* call common vendor command request */ |
1469 | status = cx231xx_send_vendor_cmd(dev, &ven_req); | 1479 | status = cx231xx_send_vendor_cmd(dev, &ven_req); |
1470 | if (status < 0) { | 1480 | if (status < 0) { |
1471 | cx231xx_info | 1481 | dev_err(dev->dev, "%s: failed with status -%d\n", |
1472 | ("UsbInterface::sendCommand, failed with status -%d\n", | 1482 | __func__, status); |
1473 | status); | ||
1474 | } | 1483 | } |
1475 | 1484 | ||
1476 | return status; | 1485 | return status; |
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index 6c7b5e250eed..dd600b994e69 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c | |||
@@ -19,11 +19,10 @@ | |||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "cx231xx.h" | ||
22 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
24 | #include <linux/usb.h> | ||
25 | 25 | ||
26 | #include "cx231xx.h" | ||
27 | #include <media/v4l2-common.h> | 26 | #include <media/v4l2-common.h> |
28 | #include <media/videobuf-vmalloc.h> | 27 | #include <media/videobuf-vmalloc.h> |
29 | 28 | ||
@@ -46,11 +45,6 @@ MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | |||
46 | 45 | ||
47 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 46 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
48 | 47 | ||
49 | #define dprintk(level, fmt, arg...) do { \ | ||
50 | if (debug >= level) \ | ||
51 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ | ||
52 | } while (0) | ||
53 | |||
54 | #define CX231XX_DVB_NUM_BUFS 5 | 48 | #define CX231XX_DVB_NUM_BUFS 5 |
55 | #define CX231XX_DVB_MAX_PACKETSIZE 564 | 49 | #define CX231XX_DVB_MAX_PACKETSIZE 564 |
56 | #define CX231XX_DVB_MAX_PACKETS 64 | 50 | #define CX231XX_DVB_MAX_PACKETS 64 |
@@ -197,9 +191,11 @@ static inline void print_err_status(struct cx231xx *dev, int packet, int status) | |||
197 | break; | 191 | break; |
198 | } | 192 | } |
199 | if (packet < 0) { | 193 | if (packet < 0) { |
200 | dprintk(1, "URB status %d [%s].\n", status, errmsg); | 194 | dev_dbg(dev->dev, |
195 | "URB status %d [%s].\n", status, errmsg); | ||
201 | } else { | 196 | } else { |
202 | dprintk(1, "URB packet %d, status %d [%s].\n", | 197 | dev_dbg(dev->dev, |
198 | "URB packet %d, status %d [%s].\n", | ||
203 | packet, status, errmsg); | 199 | packet, status, errmsg); |
204 | } | 200 | } |
205 | } | 201 | } |
@@ -265,12 +261,8 @@ static int start_streaming(struct cx231xx_dvb *dvb) | |||
265 | struct cx231xx *dev = dvb->adapter.priv; | 261 | struct cx231xx *dev = dvb->adapter.priv; |
266 | 262 | ||
267 | if (dev->USE_ISO) { | 263 | if (dev->USE_ISO) { |
268 | cx231xx_info("DVB transfer mode is ISO.\n"); | 264 | dev_dbg(dev->dev, "DVB transfer mode is ISO.\n"); |
269 | mutex_lock(&dev->i2c_lock); | ||
270 | cx231xx_enable_i2c_port_3(dev, false); | ||
271 | cx231xx_set_alt_setting(dev, INDEX_TS1, 4); | 265 | cx231xx_set_alt_setting(dev, INDEX_TS1, 4); |
272 | cx231xx_enable_i2c_port_3(dev, true); | ||
273 | mutex_unlock(&dev->i2c_lock); | ||
274 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | 266 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
275 | if (rc < 0) | 267 | if (rc < 0) |
276 | return rc; | 268 | return rc; |
@@ -280,7 +272,7 @@ static int start_streaming(struct cx231xx_dvb *dvb) | |||
280 | dev->ts1_mode.max_pkt_size, | 272 | dev->ts1_mode.max_pkt_size, |
281 | dvb_isoc_copy); | 273 | dvb_isoc_copy); |
282 | } else { | 274 | } else { |
283 | cx231xx_info("DVB transfer mode is BULK.\n"); | 275 | dev_dbg(dev->dev, "DVB transfer mode is BULK.\n"); |
284 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | 276 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); |
285 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | 277 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
286 | if (rc < 0) | 278 | if (rc < 0) |
@@ -378,24 +370,24 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev) | |||
378 | struct xc5000_config cfg; | 370 | struct xc5000_config cfg; |
379 | 371 | ||
380 | memset(&cfg, 0, sizeof(cfg)); | 372 | memset(&cfg, 0, sizeof(cfg)); |
381 | cfg.i2c_adap = &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap; | 373 | cfg.i2c_adap = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master); |
382 | cfg.i2c_addr = addr; | 374 | cfg.i2c_addr = addr; |
383 | 375 | ||
384 | if (!dev->dvb->frontend) { | 376 | if (!dev->dvb->frontend) { |
385 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | 377 | dev_err(dev->dev, "%s/2: dvb frontend not attached. " |
386 | "Can't attach xc5000\n", dev->name); | 378 | "Can't attach xc5000\n", dev->name); |
387 | return -EINVAL; | 379 | return -EINVAL; |
388 | } | 380 | } |
389 | 381 | ||
390 | fe = dvb_attach(xc5000_attach, dev->dvb->frontend, &cfg); | 382 | fe = dvb_attach(xc5000_attach, dev->dvb->frontend, &cfg); |
391 | if (!fe) { | 383 | if (!fe) { |
392 | printk(KERN_ERR "%s/2: xc5000 attach failed\n", dev->name); | 384 | dev_err(dev->dev, "%s/2: xc5000 attach failed\n", dev->name); |
393 | dvb_frontend_detach(dev->dvb->frontend); | 385 | dvb_frontend_detach(dev->dvb->frontend); |
394 | dev->dvb->frontend = NULL; | 386 | dev->dvb->frontend = NULL; |
395 | return -EINVAL; | 387 | return -EINVAL; |
396 | } | 388 | } |
397 | 389 | ||
398 | printk(KERN_INFO "%s/2: xc5000 attached\n", dev->name); | 390 | dev_info(dev->dev, "%s/2: xc5000 attached\n", dev->name); |
399 | 391 | ||
400 | return 0; | 392 | return 0; |
401 | } | 393 | } |
@@ -434,16 +426,17 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev) | |||
434 | 426 | ||
435 | if (dops->init != NULL && !dev->xc_fw_load_done) { | 427 | if (dops->init != NULL && !dev->xc_fw_load_done) { |
436 | 428 | ||
437 | cx231xx_info("Reloading firmware for XC5000\n"); | 429 | dev_dbg(dev->dev, |
430 | "Reloading firmware for XC5000\n"); | ||
438 | status = dops->init(dev->dvb->frontend); | 431 | status = dops->init(dev->dvb->frontend); |
439 | if (status == 0) { | 432 | if (status == 0) { |
440 | dev->xc_fw_load_done = 1; | 433 | dev->xc_fw_load_done = 1; |
441 | cx231xx_info | 434 | dev_dbg(dev->dev, |
442 | ("XC5000 firmware download completed\n"); | 435 | "XC5000 firmware download completed\n"); |
443 | } else { | 436 | } else { |
444 | dev->xc_fw_load_done = 0; | 437 | dev->xc_fw_load_done = 0; |
445 | cx231xx_info | 438 | dev_dbg(dev->dev, |
446 | ("XC5000 firmware download failed !!!\n"); | 439 | "XC5000 firmware download failed !!!\n"); |
447 | } | 440 | } |
448 | } | 441 | } |
449 | 442 | ||
@@ -466,7 +459,7 @@ static int register_dvb(struct cx231xx_dvb *dvb, | |||
466 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, | 459 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, |
467 | adapter_nr); | 460 | adapter_nr); |
468 | if (result < 0) { | 461 | if (result < 0) { |
469 | printk(KERN_WARNING | 462 | dev_warn(dev->dev, |
470 | "%s: dvb_register_adapter failed (errno = %d)\n", | 463 | "%s: dvb_register_adapter failed (errno = %d)\n", |
471 | dev->name, result); | 464 | dev->name, result); |
472 | goto fail_adapter; | 465 | goto fail_adapter; |
@@ -480,7 +473,7 @@ static int register_dvb(struct cx231xx_dvb *dvb, | |||
480 | /* register frontend */ | 473 | /* register frontend */ |
481 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | 474 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); |
482 | if (result < 0) { | 475 | if (result < 0) { |
483 | printk(KERN_WARNING | 476 | dev_warn(dev->dev, |
484 | "%s: dvb_register_frontend failed (errno = %d)\n", | 477 | "%s: dvb_register_frontend failed (errno = %d)\n", |
485 | dev->name, result); | 478 | dev->name, result); |
486 | goto fail_frontend; | 479 | goto fail_frontend; |
@@ -498,7 +491,8 @@ static int register_dvb(struct cx231xx_dvb *dvb, | |||
498 | 491 | ||
499 | result = dvb_dmx_init(&dvb->demux); | 492 | result = dvb_dmx_init(&dvb->demux); |
500 | if (result < 0) { | 493 | if (result < 0) { |
501 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", | 494 | dev_warn(dev->dev, |
495 | "%s: dvb_dmx_init failed (errno = %d)\n", | ||
502 | dev->name, result); | 496 | dev->name, result); |
503 | goto fail_dmx; | 497 | goto fail_dmx; |
504 | } | 498 | } |
@@ -508,15 +502,16 @@ static int register_dvb(struct cx231xx_dvb *dvb, | |||
508 | dvb->dmxdev.capabilities = 0; | 502 | dvb->dmxdev.capabilities = 0; |
509 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | 503 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); |
510 | if (result < 0) { | 504 | if (result < 0) { |
511 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", | 505 | dev_warn(dev->dev, |
512 | dev->name, result); | 506 | "%s: dvb_dmxdev_init failed (errno = %d)\n", |
507 | dev->name, result); | ||
513 | goto fail_dmxdev; | 508 | goto fail_dmxdev; |
514 | } | 509 | } |
515 | 510 | ||
516 | dvb->fe_hw.source = DMX_FRONTEND_0; | 511 | dvb->fe_hw.source = DMX_FRONTEND_0; |
517 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); | 512 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
518 | if (result < 0) { | 513 | if (result < 0) { |
519 | printk(KERN_WARNING | 514 | dev_warn(dev->dev, |
520 | "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", | 515 | "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", |
521 | dev->name, result); | 516 | dev->name, result); |
522 | goto fail_fe_hw; | 517 | goto fail_fe_hw; |
@@ -525,17 +520,17 @@ static int register_dvb(struct cx231xx_dvb *dvb, | |||
525 | dvb->fe_mem.source = DMX_MEMORY_FE; | 520 | dvb->fe_mem.source = DMX_MEMORY_FE; |
526 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); | 521 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
527 | if (result < 0) { | 522 | if (result < 0) { |
528 | printk(KERN_WARNING | 523 | dev_warn(dev->dev, |
529 | "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", | 524 | "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", |
530 | dev->name, result); | 525 | dev->name, result); |
531 | goto fail_fe_mem; | 526 | goto fail_fe_mem; |
532 | } | 527 | } |
533 | 528 | ||
534 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); | 529 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
535 | if (result < 0) { | 530 | if (result < 0) { |
536 | printk(KERN_WARNING | 531 | dev_warn(dev->dev, |
537 | "%s: connect_frontend failed (errno = %d)\n", dev->name, | 532 | "%s: connect_frontend failed (errno = %d)\n", |
538 | result); | 533 | dev->name, result); |
539 | goto fail_fe_conn; | 534 | goto fail_fe_conn; |
540 | } | 535 | } |
541 | 536 | ||
@@ -583,6 +578,8 @@ static int dvb_init(struct cx231xx *dev) | |||
583 | { | 578 | { |
584 | int result = 0; | 579 | int result = 0; |
585 | struct cx231xx_dvb *dvb; | 580 | struct cx231xx_dvb *dvb; |
581 | struct i2c_adapter *tuner_i2c; | ||
582 | struct i2c_adapter *demod_i2c; | ||
586 | 583 | ||
587 | if (!dev->board.has_dvb) { | 584 | if (!dev->board.has_dvb) { |
588 | /* This device does not support the extension */ | 585 | /* This device does not support the extension */ |
@@ -592,13 +589,16 @@ static int dvb_init(struct cx231xx *dev) | |||
592 | dvb = kzalloc(sizeof(struct cx231xx_dvb), GFP_KERNEL); | 589 | dvb = kzalloc(sizeof(struct cx231xx_dvb), GFP_KERNEL); |
593 | 590 | ||
594 | if (dvb == NULL) { | 591 | if (dvb == NULL) { |
595 | printk(KERN_INFO "cx231xx_dvb: memory allocation failed\n"); | 592 | dev_info(dev->dev, |
593 | "cx231xx_dvb: memory allocation failed\n"); | ||
596 | return -ENOMEM; | 594 | return -ENOMEM; |
597 | } | 595 | } |
598 | dev->dvb = dvb; | 596 | dev->dvb = dvb; |
599 | dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq; | 597 | dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq; |
600 | dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner; | 598 | dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner; |
601 | 599 | ||
600 | tuner_i2c = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master); | ||
601 | demod_i2c = cx231xx_get_i2c_adap(dev, dev->board.demod_i2c_master); | ||
602 | mutex_lock(&dev->lock); | 602 | mutex_lock(&dev->lock); |
603 | cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | 603 | cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
604 | cx231xx_demod_reset(dev); | 604 | cx231xx_demod_reset(dev); |
@@ -609,11 +609,11 @@ static int dvb_init(struct cx231xx *dev) | |||
609 | 609 | ||
610 | dev->dvb->frontend = dvb_attach(s5h1432_attach, | 610 | dev->dvb->frontend = dvb_attach(s5h1432_attach, |
611 | &dvico_s5h1432_config, | 611 | &dvico_s5h1432_config, |
612 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | 612 | demod_i2c); |
613 | 613 | ||
614 | if (dev->dvb->frontend == NULL) { | 614 | if (dev->dvb->frontend == NULL) { |
615 | printk(DRIVER_NAME | 615 | dev_err(dev->dev, |
616 | ": Failed to attach s5h1432 front end\n"); | 616 | "Failed to attach s5h1432 front end\n"); |
617 | result = -EINVAL; | 617 | result = -EINVAL; |
618 | goto out_free; | 618 | goto out_free; |
619 | } | 619 | } |
@@ -622,7 +622,7 @@ static int dvb_init(struct cx231xx *dev) | |||
622 | dvb->frontend->callback = cx231xx_tuner_callback; | 622 | dvb->frontend->callback = cx231xx_tuner_callback; |
623 | 623 | ||
624 | if (!dvb_attach(xc5000_attach, dev->dvb->frontend, | 624 | if (!dvb_attach(xc5000_attach, dev->dvb->frontend, |
625 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 625 | tuner_i2c, |
626 | &cnxt_rde250_tunerconfig)) { | 626 | &cnxt_rde250_tunerconfig)) { |
627 | result = -EINVAL; | 627 | result = -EINVAL; |
628 | goto out_free; | 628 | goto out_free; |
@@ -634,11 +634,11 @@ static int dvb_init(struct cx231xx *dev) | |||
634 | 634 | ||
635 | dev->dvb->frontend = dvb_attach(s5h1411_attach, | 635 | dev->dvb->frontend = dvb_attach(s5h1411_attach, |
636 | &xc5000_s5h1411_config, | 636 | &xc5000_s5h1411_config, |
637 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | 637 | demod_i2c); |
638 | 638 | ||
639 | if (dev->dvb->frontend == NULL) { | 639 | if (dev->dvb->frontend == NULL) { |
640 | printk(DRIVER_NAME | 640 | dev_err(dev->dev, |
641 | ": Failed to attach s5h1411 front end\n"); | 641 | "Failed to attach s5h1411 front end\n"); |
642 | result = -EINVAL; | 642 | result = -EINVAL; |
643 | goto out_free; | 643 | goto out_free; |
644 | } | 644 | } |
@@ -647,7 +647,7 @@ static int dvb_init(struct cx231xx *dev) | |||
647 | dvb->frontend->callback = cx231xx_tuner_callback; | 647 | dvb->frontend->callback = cx231xx_tuner_callback; |
648 | 648 | ||
649 | if (!dvb_attach(xc5000_attach, dev->dvb->frontend, | 649 | if (!dvb_attach(xc5000_attach, dev->dvb->frontend, |
650 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 650 | tuner_i2c, |
651 | &cnxt_rdu250_tunerconfig)) { | 651 | &cnxt_rdu250_tunerconfig)) { |
652 | result = -EINVAL; | 652 | result = -EINVAL; |
653 | goto out_free; | 653 | goto out_free; |
@@ -657,11 +657,11 @@ static int dvb_init(struct cx231xx *dev) | |||
657 | 657 | ||
658 | dev->dvb->frontend = dvb_attach(s5h1432_attach, | 658 | dev->dvb->frontend = dvb_attach(s5h1432_attach, |
659 | &dvico_s5h1432_config, | 659 | &dvico_s5h1432_config, |
660 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | 660 | demod_i2c); |
661 | 661 | ||
662 | if (dev->dvb->frontend == NULL) { | 662 | if (dev->dvb->frontend == NULL) { |
663 | printk(DRIVER_NAME | 663 | dev_err(dev->dev, |
664 | ": Failed to attach s5h1432 front end\n"); | 664 | "Failed to attach s5h1432 front end\n"); |
665 | result = -EINVAL; | 665 | result = -EINVAL; |
666 | goto out_free; | 666 | goto out_free; |
667 | } | 667 | } |
@@ -670,7 +670,7 @@ static int dvb_init(struct cx231xx *dev) | |||
670 | dvb->frontend->callback = cx231xx_tuner_callback; | 670 | dvb->frontend->callback = cx231xx_tuner_callback; |
671 | 671 | ||
672 | if (!dvb_attach(tda18271_attach, dev->dvb->frontend, | 672 | if (!dvb_attach(tda18271_attach, dev->dvb->frontend, |
673 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 673 | 0x60, tuner_i2c, |
674 | &cnxt_rde253s_tunerconfig)) { | 674 | &cnxt_rde253s_tunerconfig)) { |
675 | result = -EINVAL; | 675 | result = -EINVAL; |
676 | goto out_free; | 676 | goto out_free; |
@@ -681,11 +681,11 @@ static int dvb_init(struct cx231xx *dev) | |||
681 | 681 | ||
682 | dev->dvb->frontend = dvb_attach(s5h1411_attach, | 682 | dev->dvb->frontend = dvb_attach(s5h1411_attach, |
683 | &tda18271_s5h1411_config, | 683 | &tda18271_s5h1411_config, |
684 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | 684 | demod_i2c); |
685 | 685 | ||
686 | if (dev->dvb->frontend == NULL) { | 686 | if (dev->dvb->frontend == NULL) { |
687 | printk(DRIVER_NAME | 687 | dev_err(dev->dev, |
688 | ": Failed to attach s5h1411 front end\n"); | 688 | "Failed to attach s5h1411 front end\n"); |
689 | result = -EINVAL; | 689 | result = -EINVAL; |
690 | goto out_free; | 690 | goto out_free; |
691 | } | 691 | } |
@@ -694,7 +694,7 @@ static int dvb_init(struct cx231xx *dev) | |||
694 | dvb->frontend->callback = cx231xx_tuner_callback; | 694 | dvb->frontend->callback = cx231xx_tuner_callback; |
695 | 695 | ||
696 | if (!dvb_attach(tda18271_attach, dev->dvb->frontend, | 696 | if (!dvb_attach(tda18271_attach, dev->dvb->frontend, |
697 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 697 | 0x60, tuner_i2c, |
698 | &cnxt_rde253s_tunerconfig)) { | 698 | &cnxt_rde253s_tunerconfig)) { |
699 | result = -EINVAL; | 699 | result = -EINVAL; |
700 | goto out_free; | 700 | goto out_free; |
@@ -702,16 +702,17 @@ static int dvb_init(struct cx231xx *dev) | |||
702 | break; | 702 | break; |
703 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | 703 | case CX231XX_BOARD_HAUPPAUGE_EXETER: |
704 | 704 | ||
705 | printk(KERN_INFO "%s: looking for tuner / demod on i2c bus: %d\n", | 705 | dev_info(dev->dev, |
706 | __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap)); | 706 | "%s: looking for tuner / demod on i2c bus: %d\n", |
707 | __func__, i2c_adapter_id(tuner_i2c)); | ||
707 | 708 | ||
708 | dev->dvb->frontend = dvb_attach(lgdt3305_attach, | 709 | dev->dvb->frontend = dvb_attach(lgdt3305_attach, |
709 | &hcw_lgdt3305_config, | 710 | &hcw_lgdt3305_config, |
710 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap); | 711 | tuner_i2c); |
711 | 712 | ||
712 | if (dev->dvb->frontend == NULL) { | 713 | if (dev->dvb->frontend == NULL) { |
713 | printk(DRIVER_NAME | 714 | dev_err(dev->dev, |
714 | ": Failed to attach LG3305 front end\n"); | 715 | "Failed to attach LG3305 front end\n"); |
715 | result = -EINVAL; | 716 | result = -EINVAL; |
716 | goto out_free; | 717 | goto out_free; |
717 | } | 718 | } |
@@ -720,7 +721,7 @@ static int dvb_init(struct cx231xx *dev) | |||
720 | dvb->frontend->callback = cx231xx_tuner_callback; | 721 | dvb->frontend->callback = cx231xx_tuner_callback; |
721 | 722 | ||
722 | dvb_attach(tda18271_attach, dev->dvb->frontend, | 723 | dvb_attach(tda18271_attach, dev->dvb->frontend, |
723 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 724 | 0x60, tuner_i2c, |
724 | &hcw_tda18271_config); | 725 | &hcw_tda18271_config); |
725 | break; | 726 | break; |
726 | 727 | ||
@@ -728,12 +729,12 @@ static int dvb_init(struct cx231xx *dev) | |||
728 | 729 | ||
729 | dev->dvb->frontend = dvb_attach(si2165_attach, | 730 | dev->dvb->frontend = dvb_attach(si2165_attach, |
730 | &hauppauge_930C_HD_1113xx_si2165_config, | 731 | &hauppauge_930C_HD_1113xx_si2165_config, |
731 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap | 732 | tuner_i2c |
732 | ); | 733 | ); |
733 | 734 | ||
734 | if (dev->dvb->frontend == NULL) { | 735 | if (dev->dvb->frontend == NULL) { |
735 | printk(DRIVER_NAME | 736 | dev_err(dev->dev, |
736 | ": Failed to attach SI2165 front end\n"); | 737 | "Failed to attach SI2165 front end\n"); |
737 | result = -EINVAL; | 738 | result = -EINVAL; |
738 | goto out_free; | 739 | goto out_free; |
739 | } | 740 | } |
@@ -745,7 +746,7 @@ static int dvb_init(struct cx231xx *dev) | |||
745 | 746 | ||
746 | dvb_attach(tda18271_attach, dev->dvb->frontend, | 747 | dvb_attach(tda18271_attach, dev->dvb->frontend, |
747 | 0x60, | 748 | 0x60, |
748 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 749 | tuner_i2c, |
749 | &hcw_tda18271_config); | 750 | &hcw_tda18271_config); |
750 | 751 | ||
751 | dev->cx231xx_reset_analog_tuner = NULL; | 752 | dev->cx231xx_reset_analog_tuner = NULL; |
@@ -761,12 +762,12 @@ static int dvb_init(struct cx231xx *dev) | |||
761 | 762 | ||
762 | dev->dvb->frontend = dvb_attach(si2165_attach, | 763 | dev->dvb->frontend = dvb_attach(si2165_attach, |
763 | &pctv_quatro_stick_1114xx_si2165_config, | 764 | &pctv_quatro_stick_1114xx_si2165_config, |
764 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap | 765 | tuner_i2c |
765 | ); | 766 | ); |
766 | 767 | ||
767 | if (dev->dvb->frontend == NULL) { | 768 | if (dev->dvb->frontend == NULL) { |
768 | printk(DRIVER_NAME | 769 | dev_err(dev->dev, |
769 | ": Failed to attach SI2165 front end\n"); | 770 | "Failed to attach SI2165 front end\n"); |
770 | result = -EINVAL; | 771 | result = -EINVAL; |
771 | goto out_free; | 772 | goto out_free; |
772 | } | 773 | } |
@@ -786,7 +787,7 @@ static int dvb_init(struct cx231xx *dev) | |||
786 | request_module("si2157"); | 787 | request_module("si2157"); |
787 | 788 | ||
788 | client = i2c_new_device( | 789 | client = i2c_new_device( |
789 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 790 | tuner_i2c, |
790 | &info); | 791 | &info); |
791 | if (client == NULL || client->dev.driver == NULL) { | 792 | if (client == NULL || client->dev.driver == NULL) { |
792 | dvb_frontend_detach(dev->dvb->frontend); | 793 | dvb_frontend_detach(dev->dvb->frontend); |
@@ -810,16 +811,17 @@ static int dvb_init(struct cx231xx *dev) | |||
810 | case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: | 811 | case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: |
811 | case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID: | 812 | case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID: |
812 | 813 | ||
813 | printk(KERN_INFO "%s: looking for demod on i2c bus: %d\n", | 814 | dev_info(dev->dev, |
814 | __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap)); | 815 | "%s: looking for demod on i2c bus: %d\n", |
816 | __func__, i2c_adapter_id(tuner_i2c)); | ||
815 | 817 | ||
816 | dev->dvb->frontend = dvb_attach(mb86a20s_attach, | 818 | dev->dvb->frontend = dvb_attach(mb86a20s_attach, |
817 | &pv_mb86a20s_config, | 819 | &pv_mb86a20s_config, |
818 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | 820 | demod_i2c); |
819 | 821 | ||
820 | if (dev->dvb->frontend == NULL) { | 822 | if (dev->dvb->frontend == NULL) { |
821 | printk(DRIVER_NAME | 823 | dev_err(dev->dev, |
822 | ": Failed to attach mb86a20s demod\n"); | 824 | "Failed to attach mb86a20s demod\n"); |
823 | result = -EINVAL; | 825 | result = -EINVAL; |
824 | goto out_free; | 826 | goto out_free; |
825 | } | 827 | } |
@@ -828,30 +830,31 @@ static int dvb_init(struct cx231xx *dev) | |||
828 | dvb->frontend->callback = cx231xx_tuner_callback; | 830 | dvb->frontend->callback = cx231xx_tuner_callback; |
829 | 831 | ||
830 | dvb_attach(tda18271_attach, dev->dvb->frontend, | 832 | dvb_attach(tda18271_attach, dev->dvb->frontend, |
831 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | 833 | 0x60, tuner_i2c, |
832 | &pv_tda18271_config); | 834 | &pv_tda18271_config); |
833 | break; | 835 | break; |
834 | 836 | ||
835 | default: | 837 | default: |
836 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | 838 | dev_err(dev->dev, |
837 | " isn't supported yet\n", dev->name); | 839 | "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", |
840 | dev->name); | ||
838 | break; | 841 | break; |
839 | } | 842 | } |
840 | if (NULL == dvb->frontend) { | 843 | if (NULL == dvb->frontend) { |
841 | printk(KERN_ERR | 844 | dev_err(dev->dev, |
842 | "%s/2: frontend initialization failed\n", dev->name); | 845 | "%s/2: frontend initialization failed\n", dev->name); |
843 | result = -EINVAL; | 846 | result = -EINVAL; |
844 | goto out_free; | 847 | goto out_free; |
845 | } | 848 | } |
846 | 849 | ||
847 | /* register everything */ | 850 | /* register everything */ |
848 | result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); | 851 | result = register_dvb(dvb, THIS_MODULE, dev, dev->dev); |
849 | 852 | ||
850 | if (result < 0) | 853 | if (result < 0) |
851 | goto out_free; | 854 | goto out_free; |
852 | 855 | ||
853 | 856 | ||
854 | printk(KERN_INFO "Successfully loaded cx231xx-dvb\n"); | 857 | dev_info(dev->dev, "Successfully loaded cx231xx-dvb\n"); |
855 | 858 | ||
856 | ret: | 859 | ret: |
857 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | 860 | cx231xx_set_mode(dev, CX231XX_SUSPEND); |
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c index 7c0f797f1057..a29c345b027d 100644 --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c | |||
@@ -20,14 +20,14 @@ | |||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "cx231xx.h" | ||
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
25 | #include <linux/usb.h> | ||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/i2c-mux.h> | ||
27 | #include <media/v4l2-common.h> | 28 | #include <media/v4l2-common.h> |
28 | #include <media/tuner.h> | 29 | #include <media/tuner.h> |
29 | 30 | ||
30 | #include "cx231xx.h" | ||
31 | 31 | ||
32 | /* ----------------------------------------------------------- */ | 32 | /* ----------------------------------------------------------- */ |
33 | 33 | ||
@@ -54,10 +54,19 @@ do { \ | |||
54 | } \ | 54 | } \ |
55 | } while (0) | 55 | } while (0) |
56 | 56 | ||
57 | static inline int get_real_i2c_port(struct cx231xx *dev, int bus_nr) | ||
58 | { | ||
59 | if (bus_nr == 1) | ||
60 | return dev->port_3_switch_enabled ? I2C_1_MUX_3 : I2C_1_MUX_1; | ||
61 | return bus_nr; | ||
62 | } | ||
63 | |||
57 | static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus, | 64 | static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus, |
58 | const struct i2c_msg *msg, int tuner_type) | 65 | const struct i2c_msg *msg, int tuner_type) |
59 | { | 66 | { |
60 | if (bus->nr != dev->board.tuner_i2c_master) | 67 | int i2c_port = get_real_i2c_port(dev, bus->nr); |
68 | |||
69 | if (i2c_port != dev->board.tuner_i2c_master) | ||
61 | return false; | 70 | return false; |
62 | 71 | ||
63 | if (msg->addr != dev->board.tuner_addr) | 72 | if (msg->addr != dev->board.tuner_addr) |
@@ -340,14 +349,15 @@ static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap, | |||
340 | struct cx231xx *dev = bus->dev; | 349 | struct cx231xx *dev = bus->dev; |
341 | struct cx231xx_i2c_xfer_data req_data; | 350 | struct cx231xx_i2c_xfer_data req_data; |
342 | int status = 0; | 351 | int status = 0; |
352 | u8 buf[1]; | ||
343 | 353 | ||
344 | /* prepare xfer_data struct */ | 354 | /* prepare xfer_data struct */ |
345 | req_data.dev_addr = msg->addr; | 355 | req_data.dev_addr = msg->addr; |
346 | req_data.direction = msg->flags; | 356 | req_data.direction = I2C_M_RD; |
347 | req_data.saddr_len = 0; | 357 | req_data.saddr_len = 0; |
348 | req_data.saddr_dat = 0; | 358 | req_data.saddr_dat = 0; |
349 | req_data.buf_size = 0; | 359 | req_data.buf_size = 1; |
350 | req_data.p_buffer = NULL; | 360 | req_data.p_buffer = buf; |
351 | 361 | ||
352 | /* usb send command */ | 362 | /* usb send command */ |
353 | status = dev->cx231xx_send_usb_command(bus, &req_data); | 363 | status = dev->cx231xx_send_usb_command(bus, &req_data); |
@@ -455,17 +465,14 @@ static struct i2c_adapter cx231xx_adap_template = { | |||
455 | .algo = &cx231xx_algo, | 465 | .algo = &cx231xx_algo, |
456 | }; | 466 | }; |
457 | 467 | ||
458 | static struct i2c_client cx231xx_client_template = { | ||
459 | .name = "cx231xx internal", | ||
460 | }; | ||
461 | |||
462 | /* ----------------------------------------------------------- */ | 468 | /* ----------------------------------------------------------- */ |
463 | 469 | ||
464 | /* | 470 | /* |
465 | * i2c_devs | 471 | * i2c_devs |
466 | * incomplete list of known devices | 472 | * incomplete list of known devices |
467 | */ | 473 | */ |
468 | static char *i2c_devs[128] = { | 474 | static const char *i2c_devs[128] = { |
475 | [0x20 >> 1] = "demod", | ||
469 | [0x60 >> 1] = "colibri", | 476 | [0x60 >> 1] = "colibri", |
470 | [0x88 >> 1] = "hammerhead", | 477 | [0x88 >> 1] = "hammerhead", |
471 | [0x8e >> 1] = "CIR", | 478 | [0x8e >> 1] = "CIR", |
@@ -480,22 +487,34 @@ static char *i2c_devs[128] = { | |||
480 | * cx231xx_do_i2c_scan() | 487 | * cx231xx_do_i2c_scan() |
481 | * check i2c address range for devices | 488 | * check i2c address range for devices |
482 | */ | 489 | */ |
483 | void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c) | 490 | void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port) |
484 | { | 491 | { |
485 | unsigned char buf; | 492 | unsigned char buf; |
486 | int i, rc; | 493 | int i, rc; |
494 | struct i2c_client client; | ||
495 | |||
496 | if (!i2c_scan) | ||
497 | return; | ||
498 | |||
499 | /* Don't generate I2C errors during scan */ | ||
500 | dev->i2c_scan_running = true; | ||
501 | |||
502 | memset(&client, 0, sizeof(client)); | ||
503 | client.adapter = cx231xx_get_i2c_adap(dev, i2c_port); | ||
487 | 504 | ||
488 | cx231xx_info(": Checking for I2C devices ..\n"); | ||
489 | for (i = 0; i < 128; i++) { | 505 | for (i = 0; i < 128; i++) { |
490 | c->addr = i; | 506 | client.addr = i; |
491 | rc = i2c_master_recv(c, &buf, 0); | 507 | rc = i2c_master_recv(&client, &buf, 0); |
492 | if (rc < 0) | 508 | if (rc < 0) |
493 | continue; | 509 | continue; |
494 | cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n", | 510 | dev_info(dev->dev, |
495 | dev->name, i << 1, | 511 | "i2c scan: found device @ port %d addr 0x%x [%s]\n", |
496 | i2c_devs[i] ? i2c_devs[i] : "???"); | 512 | i2c_port, |
513 | i << 1, | ||
514 | i2c_devs[i] ? i2c_devs[i] : "???"); | ||
497 | } | 515 | } |
498 | cx231xx_info(": Completed Checking for I2C devices.\n"); | 516 | |
517 | dev->i2c_scan_running = false; | ||
499 | } | 518 | } |
500 | 519 | ||
501 | /* | 520 | /* |
@@ -509,23 +528,17 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) | |||
509 | BUG_ON(!dev->cx231xx_send_usb_command); | 528 | BUG_ON(!dev->cx231xx_send_usb_command); |
510 | 529 | ||
511 | bus->i2c_adap = cx231xx_adap_template; | 530 | bus->i2c_adap = cx231xx_adap_template; |
512 | bus->i2c_client = cx231xx_client_template; | 531 | bus->i2c_adap.dev.parent = dev->dev; |
513 | bus->i2c_adap.dev.parent = &dev->udev->dev; | ||
514 | 532 | ||
515 | strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); | 533 | snprintf(bus->i2c_adap.name, sizeof(bus->i2c_adap.name), "%s-%d", bus->dev->name, bus->nr); |
516 | 534 | ||
517 | bus->i2c_adap.algo_data = bus; | 535 | bus->i2c_adap.algo_data = bus; |
518 | i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); | 536 | i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); |
519 | i2c_add_adapter(&bus->i2c_adap); | 537 | i2c_add_adapter(&bus->i2c_adap); |
520 | 538 | ||
521 | bus->i2c_client.adapter = &bus->i2c_adap; | 539 | if (0 != bus->i2c_rc) |
522 | 540 | dev_warn(dev->dev, | |
523 | if (0 == bus->i2c_rc) { | 541 | "i2c bus %d register FAILED\n", bus->nr); |
524 | if (i2c_scan) | ||
525 | cx231xx_do_i2c_scan(dev, &bus->i2c_client); | ||
526 | } else | ||
527 | cx231xx_warn("%s: i2c bus %d register FAILED\n", | ||
528 | dev->name, bus->nr); | ||
529 | 542 | ||
530 | return bus->i2c_rc; | 543 | return bus->i2c_rc; |
531 | } | 544 | } |
@@ -539,3 +552,62 @@ int cx231xx_i2c_unregister(struct cx231xx_i2c *bus) | |||
539 | i2c_del_adapter(&bus->i2c_adap); | 552 | i2c_del_adapter(&bus->i2c_adap); |
540 | return 0; | 553 | return 0; |
541 | } | 554 | } |
555 | |||
556 | /* | ||
557 | * cx231xx_i2c_mux_select() | ||
558 | * switch i2c master number 1 between port1 and port3 | ||
559 | */ | ||
560 | static int cx231xx_i2c_mux_select(struct i2c_adapter *adap, | ||
561 | void *mux_priv, u32 chan_id) | ||
562 | { | ||
563 | struct cx231xx *dev = mux_priv; | ||
564 | |||
565 | return cx231xx_enable_i2c_port_3(dev, chan_id); | ||
566 | } | ||
567 | |||
568 | int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no) | ||
569 | { | ||
570 | struct i2c_adapter *i2c_parent = &dev->i2c_bus[1].i2c_adap; | ||
571 | /* what is the correct mux_dev? */ | ||
572 | struct device *mux_dev = dev->dev; | ||
573 | |||
574 | dev->i2c_mux_adap[mux_no] = i2c_add_mux_adapter(i2c_parent, | ||
575 | mux_dev, | ||
576 | dev /* mux_priv */, | ||
577 | 0, | ||
578 | mux_no /* chan_id */, | ||
579 | 0 /* class */, | ||
580 | &cx231xx_i2c_mux_select, | ||
581 | NULL); | ||
582 | |||
583 | if (!dev->i2c_mux_adap[mux_no]) | ||
584 | dev_warn(dev->dev, | ||
585 | "i2c mux %d register FAILED\n", mux_no); | ||
586 | |||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | void cx231xx_i2c_mux_unregister(struct cx231xx *dev, int mux_no) | ||
591 | { | ||
592 | i2c_del_mux_adapter(dev->i2c_mux_adap[mux_no]); | ||
593 | dev->i2c_mux_adap[mux_no] = NULL; | ||
594 | } | ||
595 | |||
596 | struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port) | ||
597 | { | ||
598 | switch (i2c_port) { | ||
599 | case I2C_0: | ||
600 | return &dev->i2c_bus[0].i2c_adap; | ||
601 | case I2C_1: | ||
602 | return &dev->i2c_bus[1].i2c_adap; | ||
603 | case I2C_2: | ||
604 | return &dev->i2c_bus[2].i2c_adap; | ||
605 | case I2C_1_MUX_1: | ||
606 | return dev->i2c_mux_adap[0]; | ||
607 | case I2C_1_MUX_3: | ||
608 | return dev->i2c_mux_adap[1]; | ||
609 | default: | ||
610 | return NULL; | ||
611 | } | ||
612 | } | ||
613 | EXPORT_SYMBOL_GPL(cx231xx_get_i2c_adap); | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c index 05f0434919d4..15d8d1b5f05c 100644 --- a/drivers/media/usb/cx231xx/cx231xx-input.c +++ b/drivers/media/usb/cx231xx/cx231xx-input.c | |||
@@ -19,7 +19,6 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "cx231xx.h" | 21 | #include "cx231xx.h" |
22 | #include <linux/usb.h> | ||
23 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
24 | #include <linux/bitrev.h> | 23 | #include <linux/bitrev.h> |
25 | 24 | ||
@@ -63,7 +62,7 @@ int cx231xx_ir_init(struct cx231xx *dev) | |||
63 | struct i2c_board_info info; | 62 | struct i2c_board_info info; |
64 | u8 ir_i2c_bus; | 63 | u8 ir_i2c_bus; |
65 | 64 | ||
66 | dev_dbg(&dev->udev->dev, "%s\n", __func__); | 65 | dev_dbg(dev->dev, "%s\n", __func__); |
67 | 66 | ||
68 | /* Only initialize if a rc keycode map is defined */ | 67 | /* Only initialize if a rc keycode map is defined */ |
69 | if (!cx231xx_boards[dev->model].rc_map_name) | 68 | if (!cx231xx_boards[dev->model].rc_map_name) |
@@ -98,9 +97,10 @@ int cx231xx_ir_init(struct cx231xx *dev) | |||
98 | 97 | ||
99 | /* Load and bind ir-kbd-i2c */ | 98 | /* Load and bind ir-kbd-i2c */ |
100 | ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master; | 99 | ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master; |
101 | dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n", | 100 | dev_dbg(dev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n", |
102 | ir_i2c_bus, info.addr); | 101 | ir_i2c_bus, info.addr); |
103 | dev->ir_i2c_client = i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info); | 102 | dev->ir_i2c_client = i2c_new_device( |
103 | cx231xx_get_i2c_adap(dev, ir_i2c_bus), &info); | ||
104 | 104 | ||
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c index 3052c4c20229..5bc74149fcb9 100644 --- a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c +++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c | |||
@@ -703,9 +703,9 @@ int initialize_cx231xx(struct cx231xx *dev) | |||
703 | _current_scenario_idx = INDEX_BUSPOWER_DIF_ONLY; | 703 | _current_scenario_idx = INDEX_BUSPOWER_DIF_ONLY; |
704 | break; | 704 | break; |
705 | default: | 705 | default: |
706 | cx231xx_info("bad config in buspower!!!!\n"); | 706 | dev_err(dev->dev, |
707 | cx231xx_info("config_info=%x\n", | 707 | "bad config in buspower!!!!\nconfig_info=%x\n", |
708 | (config_info & BUSPOWER_MASK)); | 708 | config_info & BUSPOWER_MASK); |
709 | return 1; | 709 | return 1; |
710 | } | 710 | } |
711 | } else { /* self-power */ | 711 | } else { /* self-power */ |
@@ -768,9 +768,9 @@ int initialize_cx231xx(struct cx231xx *dev) | |||
768 | _current_scenario_idx = INDEX_SELFPOWER_COMPRESSOR; | 768 | _current_scenario_idx = INDEX_SELFPOWER_COMPRESSOR; |
769 | break; | 769 | break; |
770 | default: | 770 | default: |
771 | cx231xx_info("bad senario!!!!!\n"); | 771 | dev_err(dev->dev, |
772 | cx231xx_info("config_info=%x\n", | 772 | "bad senario!!!!!\nconfig_info=%x\n", |
773 | (config_info & SELFPOWER_MASK)); | 773 | config_info & SELFPOWER_MASK); |
774 | return -ENODEV; | 774 | return -ENODEV; |
775 | } | 775 | } |
776 | } | 776 | } |
@@ -781,18 +781,29 @@ int initialize_cx231xx(struct cx231xx *dev) | |||
781 | sizeof(struct pcb_config)); | 781 | sizeof(struct pcb_config)); |
782 | 782 | ||
783 | if (pcb_debug) { | 783 | if (pcb_debug) { |
784 | cx231xx_info("SC(0x00) register = 0x%x\n", config_info); | 784 | dev_info(dev->dev, |
785 | cx231xx_info("scenario %d\n", | 785 | "SC(0x00) register = 0x%x\n", config_info); |
786 | (dev->current_pcb_config.index) + 1); | 786 | dev_info(dev->dev, |
787 | cx231xx_info("type=%x\n", dev->current_pcb_config.type); | 787 | "scenario %d\n", |
788 | cx231xx_info("mode=%x\n", dev->current_pcb_config.mode); | 788 | (dev->current_pcb_config.index) + 1); |
789 | cx231xx_info("speed=%x\n", dev->current_pcb_config.speed); | 789 | dev_info(dev->dev, |
790 | cx231xx_info("ts1_source=%x\n", | 790 | "type=%x\n", |
791 | dev->current_pcb_config.ts1_source); | 791 | dev->current_pcb_config.type); |
792 | cx231xx_info("ts2_source=%x\n", | 792 | dev_info(dev->dev, |
793 | dev->current_pcb_config.ts2_source); | 793 | "mode=%x\n", |
794 | cx231xx_info("analog_source=%x\n", | 794 | dev->current_pcb_config.mode); |
795 | dev->current_pcb_config.analog_source); | 795 | dev_info(dev->dev, |
796 | "speed=%x\n", | ||
797 | dev->current_pcb_config.speed); | ||
798 | dev_info(dev->dev, | ||
799 | "ts1_source=%x\n", | ||
800 | dev->current_pcb_config.ts1_source); | ||
801 | dev_info(dev->dev, | ||
802 | "ts2_source=%x\n", | ||
803 | dev->current_pcb_config.ts2_source); | ||
804 | dev_info(dev->dev, | ||
805 | "analog_source=%x\n", | ||
806 | dev->current_pcb_config.analog_source); | ||
796 | } | 807 | } |
797 | 808 | ||
798 | return 0; | 809 | return 0; |
diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c index c02794274f51..80261ac40208 100644 --- a/drivers/media/usb/cx231xx/cx231xx-vbi.c +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c | |||
@@ -19,12 +19,12 @@ | |||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "cx231xx.h" | ||
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
23 | #include <linux/list.h> | 24 | #include <linux/list.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
26 | #include <linux/bitmap.h> | 27 | #include <linux/bitmap.h> |
27 | #include <linux/usb.h> | ||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
@@ -35,7 +35,6 @@ | |||
35 | #include <media/msp3400.h> | 35 | #include <media/msp3400.h> |
36 | #include <media/tuner.h> | 36 | #include <media/tuner.h> |
37 | 37 | ||
38 | #include "cx231xx.h" | ||
39 | #include "cx231xx-vbi.h" | 38 | #include "cx231xx-vbi.h" |
40 | 39 | ||
41 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | 40 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) |
@@ -69,11 +68,12 @@ static inline void print_err_status(struct cx231xx *dev, int packet, int status) | |||
69 | break; | 68 | break; |
70 | } | 69 | } |
71 | if (packet < 0) { | 70 | if (packet < 0) { |
72 | cx231xx_err("URB status %d [%s].\n", status, | 71 | dev_err(dev->dev, |
73 | errmsg); | 72 | "URB status %d [%s].\n", status, errmsg); |
74 | } else { | 73 | } else { |
75 | cx231xx_err("URB packet %d, status %d [%s].\n", | 74 | dev_err(dev->dev, |
76 | packet, status, errmsg); | 75 | "URB packet %d, status %d [%s].\n", |
76 | packet, status, errmsg); | ||
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
@@ -316,8 +316,8 @@ static void cx231xx_irq_vbi_callback(struct urb *urb) | |||
316 | case -ESHUTDOWN: | 316 | case -ESHUTDOWN: |
317 | return; | 317 | return; |
318 | default: /* error */ | 318 | default: /* error */ |
319 | cx231xx_err("urb completition error %d.\n", | 319 | dev_err(dev->dev, |
320 | urb->status); | 320 | "urb completition error %d.\n", urb->status); |
321 | break; | 321 | break; |
322 | } | 322 | } |
323 | 323 | ||
@@ -331,8 +331,8 @@ static void cx231xx_irq_vbi_callback(struct urb *urb) | |||
331 | 331 | ||
332 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); | 332 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); |
333 | if (urb->status) { | 333 | if (urb->status) { |
334 | cx231xx_err("urb resubmit failed (error=%i)\n", | 334 | dev_err(dev->dev, "urb resubmit failed (error=%i)\n", |
335 | urb->status); | 335 | urb->status); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
@@ -344,7 +344,7 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) | |||
344 | struct urb *urb; | 344 | struct urb *urb; |
345 | int i; | 345 | int i; |
346 | 346 | ||
347 | cx231xx_info("called cx231xx_uninit_vbi_isoc\n"); | 347 | dev_dbg(dev->dev, "called cx231xx_uninit_vbi_isoc\n"); |
348 | 348 | ||
349 | dev->vbi_mode.bulk_ctl.nfields = -1; | 349 | dev->vbi_mode.bulk_ctl.nfields = -1; |
350 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { | 350 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { |
@@ -393,7 +393,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
393 | struct urb *urb; | 393 | struct urb *urb; |
394 | int rc; | 394 | int rc; |
395 | 395 | ||
396 | cx231xx_info("called cx231xx_vbi_isoc\n"); | 396 | dev_dbg(dev->dev, "called cx231xx_vbi_isoc\n"); |
397 | 397 | ||
398 | /* De-allocates all pending stuff */ | 398 | /* De-allocates all pending stuff */ |
399 | cx231xx_uninit_vbi_isoc(dev); | 399 | cx231xx_uninit_vbi_isoc(dev); |
@@ -419,14 +419,16 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
419 | dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs, | 419 | dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs, |
420 | GFP_KERNEL); | 420 | GFP_KERNEL); |
421 | if (!dev->vbi_mode.bulk_ctl.urb) { | 421 | if (!dev->vbi_mode.bulk_ctl.urb) { |
422 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | 422 | dev_err(dev->dev, |
423 | "cannot alloc memory for usb buffers\n"); | ||
423 | return -ENOMEM; | 424 | return -ENOMEM; |
424 | } | 425 | } |
425 | 426 | ||
426 | dev->vbi_mode.bulk_ctl.transfer_buffer = | 427 | dev->vbi_mode.bulk_ctl.transfer_buffer = |
427 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 428 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); |
428 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer) { | 429 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer) { |
429 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | 430 | dev_err(dev->dev, |
431 | "cannot allocate memory for usbtransfer\n"); | ||
430 | kfree(dev->vbi_mode.bulk_ctl.urb); | 432 | kfree(dev->vbi_mode.bulk_ctl.urb); |
431 | return -ENOMEM; | 433 | return -ENOMEM; |
432 | } | 434 | } |
@@ -441,7 +443,8 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
441 | 443 | ||
442 | urb = usb_alloc_urb(0, GFP_KERNEL); | 444 | urb = usb_alloc_urb(0, GFP_KERNEL); |
443 | if (!urb) { | 445 | if (!urb) { |
444 | cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i); | 446 | dev_err(dev->dev, |
447 | "cannot alloc bulk_ctl.urb %i\n", i); | ||
445 | cx231xx_uninit_vbi_isoc(dev); | 448 | cx231xx_uninit_vbi_isoc(dev); |
446 | return -ENOMEM; | 449 | return -ENOMEM; |
447 | } | 450 | } |
@@ -451,9 +454,10 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
451 | dev->vbi_mode.bulk_ctl.transfer_buffer[i] = | 454 | dev->vbi_mode.bulk_ctl.transfer_buffer[i] = |
452 | kzalloc(sb_size, GFP_KERNEL); | 455 | kzalloc(sb_size, GFP_KERNEL); |
453 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer[i]) { | 456 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer[i]) { |
454 | cx231xx_err("unable to allocate %i bytes for transfer" | 457 | dev_err(dev->dev, |
455 | " buffer %i%s\n", sb_size, i, | 458 | "unable to allocate %i bytes for transfer buffer %i%s\n", |
456 | in_interrupt() ? " while in int" : ""); | 459 | sb_size, i, |
460 | in_interrupt() ? " while in int" : ""); | ||
457 | cx231xx_uninit_vbi_isoc(dev); | 461 | cx231xx_uninit_vbi_isoc(dev); |
458 | return -ENOMEM; | 462 | return -ENOMEM; |
459 | } | 463 | } |
@@ -470,8 +474,8 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
470 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { | 474 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { |
471 | rc = usb_submit_urb(dev->vbi_mode.bulk_ctl.urb[i], GFP_ATOMIC); | 475 | rc = usb_submit_urb(dev->vbi_mode.bulk_ctl.urb[i], GFP_ATOMIC); |
472 | if (rc) { | 476 | if (rc) { |
473 | cx231xx_err("submit of urb %i failed (error=%i)\n", i, | 477 | dev_err(dev->dev, |
474 | rc); | 478 | "submit of urb %i failed (error=%i)\n", i, rc); |
475 | cx231xx_uninit_vbi_isoc(dev); | 479 | cx231xx_uninit_vbi_isoc(dev); |
476 | return rc; | 480 | return rc; |
477 | } | 481 | } |
@@ -522,7 +526,7 @@ static inline void vbi_buffer_filled(struct cx231xx *dev, | |||
522 | struct cx231xx_buffer *buf) | 526 | struct cx231xx_buffer *buf) |
523 | { | 527 | { |
524 | /* Advice that buffer was filled */ | 528 | /* Advice that buffer was filled */ |
525 | /* cx231xx_info("[%p/%d] wakeup\n", buf, buf->vb.i); */ | 529 | /* dev_dbg(dev->dev, "[%p/%d] wakeup\n", buf, buf->vb.i); */ |
526 | 530 | ||
527 | buf->vb.state = VIDEOBUF_DONE; | 531 | buf->vb.state = VIDEOBUF_DONE; |
528 | buf->vb.field_count++; | 532 | buf->vb.field_count++; |
@@ -614,7 +618,7 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, | |||
614 | char *outp; | 618 | char *outp; |
615 | 619 | ||
616 | if (list_empty(&dma_q->active)) { | 620 | if (list_empty(&dma_q->active)) { |
617 | cx231xx_err("No active queue to serve\n"); | 621 | dev_err(dev->dev, "No active queue to serve\n"); |
618 | dev->vbi_mode.bulk_ctl.buf = NULL; | 622 | dev->vbi_mode.bulk_ctl.buf = NULL; |
619 | *buf = NULL; | 623 | *buf = NULL; |
620 | return; | 624 | return; |
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index 3b3ada6562ca..53ca12c1ff69 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c | |||
@@ -22,12 +22,12 @@ | |||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "cx231xx.h" | ||
25 | #include <linux/init.h> | 26 | #include <linux/init.h> |
26 | #include <linux/list.h> | 27 | #include <linux/list.h> |
27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
28 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
29 | #include <linux/bitmap.h> | 30 | #include <linux/bitmap.h> |
30 | #include <linux/usb.h> | ||
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
@@ -41,10 +41,9 @@ | |||
41 | 41 | ||
42 | #include "dvb_frontend.h" | 42 | #include "dvb_frontend.h" |
43 | 43 | ||
44 | #include "cx231xx.h" | ||
45 | #include "cx231xx-vbi.h" | 44 | #include "cx231xx-vbi.h" |
46 | 45 | ||
47 | #define CX231XX_VERSION "0.0.2" | 46 | #define CX231XX_VERSION "0.0.3" |
48 | 47 | ||
49 | #define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>" | 48 | #define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>" |
50 | #define DRIVER_DESC "Conexant cx231xx based USB video device driver" | 49 | #define DRIVER_DESC "Conexant cx231xx based USB video device driver" |
@@ -737,8 +736,9 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | |||
737 | if (!dev->video_mode.bulk_ctl.num_bufs) | 736 | if (!dev->video_mode.bulk_ctl.num_bufs) |
738 | urb_init = 1; | 737 | urb_init = 1; |
739 | } | 738 | } |
740 | /*cx231xx_info("urb_init=%d dev->video_mode.max_pkt_size=%d\n", | 739 | dev_dbg(dev->dev, |
741 | urb_init, dev->video_mode.max_pkt_size);*/ | 740 | "urb_init=%d dev->video_mode.max_pkt_size=%d\n", |
741 | urb_init, dev->video_mode.max_pkt_size); | ||
742 | if (urb_init) { | 742 | if (urb_init) { |
743 | dev->mode_tv = 0; | 743 | dev->mode_tv = 0; |
744 | if (dev->USE_ISO) | 744 | if (dev->USE_ISO) |
@@ -809,7 +809,7 @@ void video_mux(struct cx231xx *dev, int index) | |||
809 | 809 | ||
810 | cx231xx_set_audio_input(dev, dev->ctl_ainput); | 810 | cx231xx_set_audio_input(dev, dev->ctl_ainput); |
811 | 811 | ||
812 | cx231xx_info("video_mux : %d\n", index); | 812 | dev_dbg(dev->dev, "video_mux : %d\n", index); |
813 | 813 | ||
814 | /* do mode control overrides if required */ | 814 | /* do mode control overrides if required */ |
815 | cx231xx_do_mode_ctrl_overrides(dev); | 815 | cx231xx_do_mode_ctrl_overrides(dev); |
@@ -861,7 +861,7 @@ static void res_free(struct cx231xx_fh *fh) | |||
861 | static int check_dev(struct cx231xx *dev) | 861 | static int check_dev(struct cx231xx *dev) |
862 | { | 862 | { |
863 | if (dev->state & DEV_DISCONNECTED) { | 863 | if (dev->state & DEV_DISCONNECTED) { |
864 | cx231xx_errdev("v4l2 ioctl: device not present\n"); | 864 | dev_err(dev->dev, "v4l2 ioctl: device not present\n"); |
865 | return -ENODEV; | 865 | return -ENODEV; |
866 | } | 866 | } |
867 | return 0; | 867 | return 0; |
@@ -953,12 +953,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
953 | return -EINVAL; | 953 | return -EINVAL; |
954 | 954 | ||
955 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | 955 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { |
956 | cx231xx_errdev("%s queue busy\n", __func__); | 956 | dev_err(dev->dev, "%s: queue busy\n", __func__); |
957 | return -EBUSY; | 957 | return -EBUSY; |
958 | } | 958 | } |
959 | 959 | ||
960 | if (dev->stream_on && !fh->stream_on) { | 960 | if (dev->stream_on && !fh->stream_on) { |
961 | cx231xx_errdev("%s device in use by another fh\n", __func__); | 961 | dev_err(dev->dev, |
962 | "%s: device in use by another fh\n", __func__); | ||
962 | return -EBUSY; | 963 | return -EBUSY; |
963 | } | 964 | } |
964 | 965 | ||
@@ -967,7 +968,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
967 | dev->height = f->fmt.pix.height; | 968 | dev->height = f->fmt.pix.height; |
968 | dev->format = fmt; | 969 | dev->format = fmt; |
969 | 970 | ||
970 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); | 971 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); |
971 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); | 972 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); |
972 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); | 973 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); |
973 | 974 | ||
@@ -1012,7 +1013,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) | |||
1012 | resolution (since a standard change effects things like the number | 1013 | resolution (since a standard change effects things like the number |
1013 | of lines in VACT, etc) */ | 1014 | of lines in VACT, etc) */ |
1014 | memset(&mbus_fmt, 0, sizeof(mbus_fmt)); | 1015 | memset(&mbus_fmt, 0, sizeof(mbus_fmt)); |
1015 | mbus_fmt.code = V4L2_MBUS_FMT_FIXED; | 1016 | mbus_fmt.code = MEDIA_BUS_FMT_FIXED; |
1016 | mbus_fmt.width = dev->width; | 1017 | mbus_fmt.width = dev->width; |
1017 | mbus_fmt.height = dev->height; | 1018 | mbus_fmt.height = dev->height; |
1018 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); | 1019 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); |
@@ -1176,9 +1177,9 @@ int cx231xx_s_frequency(struct file *file, void *priv, | |||
1176 | int rc; | 1177 | int rc; |
1177 | u32 if_frequency = 5400000; | 1178 | u32 if_frequency = 5400000; |
1178 | 1179 | ||
1179 | cx231xx_info("Enter vidioc_s_frequency()f->frequency=%d;f->type=%d\n", | 1180 | dev_dbg(dev->dev, |
1180 | f->frequency, f->type); | 1181 | "Enter vidioc_s_frequency()f->frequency=%d;f->type=%d\n", |
1181 | /*cx231xx_info("f->type: 1-radio 2-analogTV 3-digitalTV\n");*/ | 1182 | f->frequency, f->type); |
1182 | 1183 | ||
1183 | rc = check_dev(dev); | 1184 | rc = check_dev(dev); |
1184 | if (rc < 0) | 1185 | if (rc < 0) |
@@ -1213,13 +1214,14 @@ int cx231xx_s_frequency(struct file *file, void *priv, | |||
1213 | else if (dev->norm & V4L2_STD_SECAM_LC) | 1214 | else if (dev->norm & V4L2_STD_SECAM_LC) |
1214 | if_frequency = 1250000; /*1.25MHz */ | 1215 | if_frequency = 1250000; /*1.25MHz */ |
1215 | 1216 | ||
1216 | cx231xx_info("if_frequency is set to %d\n", if_frequency); | 1217 | dev_dbg(dev->dev, |
1218 | "if_frequency is set to %d\n", if_frequency); | ||
1217 | cx231xx_set_Colibri_For_LowIF(dev, if_frequency, 1, 1); | 1219 | cx231xx_set_Colibri_For_LowIF(dev, if_frequency, 1, 1); |
1218 | 1220 | ||
1219 | update_HH_register_after_set_DIF(dev); | 1221 | update_HH_register_after_set_DIF(dev); |
1220 | } | 1222 | } |
1221 | 1223 | ||
1222 | cx231xx_info("Set New FREQUENCY to %d\n", f->frequency); | 1224 | dev_dbg(dev->dev, "Set New FREQUENCY to %d\n", f->frequency); |
1223 | 1225 | ||
1224 | return rc; | 1226 | return rc; |
1225 | } | 1227 | } |
@@ -1523,7 +1525,8 @@ static int vidioc_s_fmt_vbi_cap(struct file *file, void *priv, | |||
1523 | struct cx231xx *dev = fh->dev; | 1525 | struct cx231xx *dev = fh->dev; |
1524 | 1526 | ||
1525 | if (dev->vbi_stream_on && !fh->stream_on) { | 1527 | if (dev->vbi_stream_on && !fh->stream_on) { |
1526 | cx231xx_errdev("%s device in use by another fh\n", __func__); | 1528 | dev_err(dev->dev, |
1529 | "%s device in use by another fh\n", __func__); | ||
1527 | return -EBUSY; | 1530 | return -EBUSY; |
1528 | } | 1531 | } |
1529 | return vidioc_try_fmt_vbi_cap(file, priv, f); | 1532 | return vidioc_try_fmt_vbi_cap(file, priv, f); |
@@ -1642,17 +1645,15 @@ static int cx231xx_v4l2_open(struct file *filp) | |||
1642 | #if 0 | 1645 | #if 0 |
1643 | errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | 1646 | errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); |
1644 | if (errCode < 0) { | 1647 | if (errCode < 0) { |
1645 | cx231xx_errdev | 1648 | dev_err(dev->dev, |
1646 | ("Device locked on digital mode. Can't open analog\n"); | 1649 | "Device locked on digital mode. Can't open analog\n"); |
1647 | return -EBUSY; | 1650 | return -EBUSY; |
1648 | } | 1651 | } |
1649 | #endif | 1652 | #endif |
1650 | 1653 | ||
1651 | fh = kzalloc(sizeof(struct cx231xx_fh), GFP_KERNEL); | 1654 | fh = kzalloc(sizeof(struct cx231xx_fh), GFP_KERNEL); |
1652 | if (!fh) { | 1655 | if (!fh) |
1653 | cx231xx_errdev("cx231xx-video.c: Out of memory?!\n"); | ||
1654 | return -ENOMEM; | 1656 | return -ENOMEM; |
1655 | } | ||
1656 | if (mutex_lock_interruptible(&dev->lock)) { | 1657 | if (mutex_lock_interruptible(&dev->lock)) { |
1657 | kfree(fh); | 1658 | kfree(fh); |
1658 | return -ERESTARTSYS; | 1659 | return -ERESTARTSYS; |
@@ -1736,8 +1737,8 @@ void cx231xx_release_analog_resources(struct cx231xx *dev) | |||
1736 | dev->radio_dev = NULL; | 1737 | dev->radio_dev = NULL; |
1737 | } | 1738 | } |
1738 | if (dev->vbi_dev) { | 1739 | if (dev->vbi_dev) { |
1739 | cx231xx_info("V4L2 device %s deregistered\n", | 1740 | dev_info(dev->dev, "V4L2 device %s deregistered\n", |
1740 | video_device_node_name(dev->vbi_dev)); | 1741 | video_device_node_name(dev->vbi_dev)); |
1741 | if (video_is_registered(dev->vbi_dev)) | 1742 | if (video_is_registered(dev->vbi_dev)) |
1742 | video_unregister_device(dev->vbi_dev); | 1743 | video_unregister_device(dev->vbi_dev); |
1743 | else | 1744 | else |
@@ -1745,8 +1746,8 @@ void cx231xx_release_analog_resources(struct cx231xx *dev) | |||
1745 | dev->vbi_dev = NULL; | 1746 | dev->vbi_dev = NULL; |
1746 | } | 1747 | } |
1747 | if (dev->vdev) { | 1748 | if (dev->vdev) { |
1748 | cx231xx_info("V4L2 device %s deregistered\n", | 1749 | dev_info(dev->dev, "V4L2 device %s deregistered\n", |
1749 | video_device_node_name(dev->vdev)); | 1750 | video_device_node_name(dev->vdev)); |
1750 | 1751 | ||
1751 | if (dev->board.has_417) | 1752 | if (dev->board.has_417) |
1752 | cx231xx_417_unregister(dev); | 1753 | cx231xx_417_unregister(dev); |
@@ -2080,8 +2081,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) | |||
2080 | { | 2081 | { |
2081 | int ret; | 2082 | int ret; |
2082 | 2083 | ||
2083 | cx231xx_info("%s: v4l2 driver version %s\n", | 2084 | dev_info(dev->dev, "v4l2 driver version %s\n", CX231XX_VERSION); |
2084 | dev->name, CX231XX_VERSION); | ||
2085 | 2085 | ||
2086 | /* set default norm */ | 2086 | /* set default norm */ |
2087 | dev->norm = V4L2_STD_PAL; | 2087 | dev->norm = V4L2_STD_PAL; |
@@ -2119,7 +2119,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) | |||
2119 | /* allocate and fill video video_device struct */ | 2119 | /* allocate and fill video video_device struct */ |
2120 | dev->vdev = cx231xx_vdev_init(dev, &cx231xx_video_template, "video"); | 2120 | dev->vdev = cx231xx_vdev_init(dev, &cx231xx_video_template, "video"); |
2121 | if (!dev->vdev) { | 2121 | if (!dev->vdev) { |
2122 | cx231xx_errdev("cannot allocate video_device.\n"); | 2122 | dev_err(dev->dev, "cannot allocate video_device.\n"); |
2123 | return -ENODEV; | 2123 | return -ENODEV; |
2124 | } | 2124 | } |
2125 | 2125 | ||
@@ -2128,13 +2128,14 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) | |||
2128 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | 2128 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, |
2129 | video_nr[dev->devno]); | 2129 | video_nr[dev->devno]); |
2130 | if (ret) { | 2130 | if (ret) { |
2131 | cx231xx_errdev("unable to register video device (error=%i).\n", | 2131 | dev_err(dev->dev, |
2132 | ret); | 2132 | "unable to register video device (error=%i).\n", |
2133 | ret); | ||
2133 | return ret; | 2134 | return ret; |
2134 | } | 2135 | } |
2135 | 2136 | ||
2136 | cx231xx_info("%s/0: registered device %s [v4l2]\n", | 2137 | dev_info(dev->dev, "Registered video device %s [v4l2]\n", |
2137 | dev->name, video_device_node_name(dev->vdev)); | 2138 | video_device_node_name(dev->vdev)); |
2138 | 2139 | ||
2139 | /* Initialize VBI template */ | 2140 | /* Initialize VBI template */ |
2140 | cx231xx_vbi_template = cx231xx_video_template; | 2141 | cx231xx_vbi_template = cx231xx_video_template; |
@@ -2144,7 +2145,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) | |||
2144 | dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi"); | 2145 | dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi"); |
2145 | 2146 | ||
2146 | if (!dev->vbi_dev) { | 2147 | if (!dev->vbi_dev) { |
2147 | cx231xx_errdev("cannot allocate video_device.\n"); | 2148 | dev_err(dev->dev, "cannot allocate video_device.\n"); |
2148 | return -ENODEV; | 2149 | return -ENODEV; |
2149 | } | 2150 | } |
2150 | dev->vbi_dev->ctrl_handler = &dev->ctrl_handler; | 2151 | dev->vbi_dev->ctrl_handler = &dev->ctrl_handler; |
@@ -2152,34 +2153,32 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) | |||
2152 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | 2153 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, |
2153 | vbi_nr[dev->devno]); | 2154 | vbi_nr[dev->devno]); |
2154 | if (ret < 0) { | 2155 | if (ret < 0) { |
2155 | cx231xx_errdev("unable to register vbi device\n"); | 2156 | dev_err(dev->dev, "unable to register vbi device\n"); |
2156 | return ret; | 2157 | return ret; |
2157 | } | 2158 | } |
2158 | 2159 | ||
2159 | cx231xx_info("%s/0: registered device %s\n", | 2160 | dev_info(dev->dev, "Registered VBI device %s\n", |
2160 | dev->name, video_device_node_name(dev->vbi_dev)); | 2161 | video_device_node_name(dev->vbi_dev)); |
2161 | 2162 | ||
2162 | if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) { | 2163 | if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) { |
2163 | dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template, | 2164 | dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template, |
2164 | "radio"); | 2165 | "radio"); |
2165 | if (!dev->radio_dev) { | 2166 | if (!dev->radio_dev) { |
2166 | cx231xx_errdev("cannot allocate video_device.\n"); | 2167 | dev_err(dev->dev, |
2168 | "cannot allocate video_device.\n"); | ||
2167 | return -ENODEV; | 2169 | return -ENODEV; |
2168 | } | 2170 | } |
2169 | dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; | 2171 | dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; |
2170 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, | 2172 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, |
2171 | radio_nr[dev->devno]); | 2173 | radio_nr[dev->devno]); |
2172 | if (ret < 0) { | 2174 | if (ret < 0) { |
2173 | cx231xx_errdev("can't register radio device\n"); | 2175 | dev_err(dev->dev, |
2176 | "can't register radio device\n"); | ||
2174 | return ret; | 2177 | return ret; |
2175 | } | 2178 | } |
2176 | cx231xx_info("Registered radio device as %s\n", | 2179 | dev_info(dev->dev, "Registered radio device as %s\n", |
2177 | video_device_node_name(dev->radio_dev)); | 2180 | video_device_node_name(dev->radio_dev)); |
2178 | } | 2181 | } |
2179 | 2182 | ||
2180 | cx231xx_info("V4L2 device registered as %s and %s\n", | ||
2181 | video_device_node_name(dev->vdev), | ||
2182 | video_device_node_name(dev->vbi_dev)); | ||
2183 | |||
2184 | return 0; | 2183 | return 0; |
2185 | } | 2184 | } |
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h index aeb1bf42b88d..f9e262eb0db9 100644 --- a/drivers/media/usb/cx231xx/cx231xx.h +++ b/drivers/media/usb/cx231xx/cx231xx.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/workqueue.h> | 29 | #include <linux/workqueue.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | #include <linux/usb.h> | ||
31 | 32 | ||
32 | #include <media/cx2341x.h> | 33 | #include <media/cx2341x.h> |
33 | 34 | ||
@@ -322,10 +323,11 @@ enum cx231xx_decoder { | |||
322 | }; | 323 | }; |
323 | 324 | ||
324 | enum CX231XX_I2C_MASTER_PORT { | 325 | enum CX231XX_I2C_MASTER_PORT { |
325 | I2C_0 = 0, | 326 | I2C_0 = 0, /* master 0 - internal connection */ |
326 | I2C_1 = 1, | 327 | I2C_1 = 1, /* master 1 - used with mux */ |
327 | I2C_2 = 2, | 328 | I2C_2 = 2, /* master 2 */ |
328 | I2C_3 = 3 | 329 | I2C_1_MUX_1 = 3, /* master 1 - port 1 (I2C_DEMOD_EN = 0) */ |
330 | I2C_1_MUX_3 = 4 /* master 1 - port 3 (I2C_DEMOD_EN = 1) */ | ||
329 | }; | 331 | }; |
330 | 332 | ||
331 | struct cx231xx_board { | 333 | struct cx231xx_board { |
@@ -367,7 +369,6 @@ struct cx231xx_board { | |||
367 | unsigned int valid:1; | 369 | unsigned int valid:1; |
368 | unsigned int no_alt_vanc:1; | 370 | unsigned int no_alt_vanc:1; |
369 | unsigned int external_av:1; | 371 | unsigned int external_av:1; |
370 | unsigned int dont_use_port_3:1; | ||
371 | 372 | ||
372 | unsigned char xclk, i2c_speed; | 373 | unsigned char xclk, i2c_speed; |
373 | 374 | ||
@@ -472,7 +473,6 @@ struct cx231xx_i2c { | |||
472 | 473 | ||
473 | /* i2c i/o */ | 474 | /* i2c i/o */ |
474 | struct i2c_adapter i2c_adap; | 475 | struct i2c_adapter i2c_adap; |
475 | struct i2c_client i2c_client; | ||
476 | u32 i2c_rc; | 476 | u32 i2c_rc; |
477 | 477 | ||
478 | /* different settings for each bus */ | 478 | /* different settings for each bus */ |
@@ -597,6 +597,7 @@ struct cx231xx { | |||
597 | char name[30]; /* name (including minor) of the device */ | 597 | char name[30]; /* name (including minor) of the device */ |
598 | int model; /* index in the device_data struct */ | 598 | int model; /* index in the device_data struct */ |
599 | int devno; /* marks the number of this device */ | 599 | int devno; /* marks the number of this device */ |
600 | struct device *dev; /* pointer to USB interface's dev */ | ||
600 | 601 | ||
601 | struct cx231xx_board board; | 602 | struct cx231xx_board board; |
602 | 603 | ||
@@ -609,6 +610,8 @@ struct cx231xx { | |||
609 | unsigned int has_audio_class:1; | 610 | unsigned int has_audio_class:1; |
610 | unsigned int has_alsa_audio:1; | 611 | unsigned int has_alsa_audio:1; |
611 | 612 | ||
613 | unsigned int i2c_scan_running:1; /* true only during i2c_scan */ | ||
614 | |||
612 | struct cx231xx_fmt *format; | 615 | struct cx231xx_fmt *format; |
613 | 616 | ||
614 | struct v4l2_device v4l2_dev; | 617 | struct v4l2_device v4l2_dev; |
@@ -628,7 +631,10 @@ struct cx231xx { | |||
628 | 631 | ||
629 | /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ | 632 | /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ |
630 | struct cx231xx_i2c i2c_bus[3]; | 633 | struct cx231xx_i2c i2c_bus[3]; |
634 | struct i2c_adapter *i2c_mux_adap[2]; | ||
635 | |||
631 | unsigned int xc_fw_load_done:1; | 636 | unsigned int xc_fw_load_done:1; |
637 | unsigned int port_3_switch_enabled:1; | ||
632 | /* locks */ | 638 | /* locks */ |
633 | struct mutex gpio_i2c_lock; | 639 | struct mutex gpio_i2c_lock; |
634 | struct mutex i2c_lock; | 640 | struct mutex i2c_lock; |
@@ -751,9 +757,12 @@ int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq); | |||
751 | int cx231xx_reset_analog_tuner(struct cx231xx *dev); | 757 | int cx231xx_reset_analog_tuner(struct cx231xx *dev); |
752 | 758 | ||
753 | /* Provided by cx231xx-i2c.c */ | 759 | /* Provided by cx231xx-i2c.c */ |
754 | void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c); | 760 | void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port); |
755 | int cx231xx_i2c_register(struct cx231xx_i2c *bus); | 761 | int cx231xx_i2c_register(struct cx231xx_i2c *bus); |
756 | int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); | 762 | int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); |
763 | int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no); | ||
764 | void cx231xx_i2c_mux_unregister(struct cx231xx *dev, int mux_no); | ||
765 | struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port); | ||
757 | 766 | ||
758 | /* Internal block control functions */ | 767 | /* Internal block control functions */ |
759 | int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, | 768 | int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, |
@@ -802,7 +811,6 @@ void cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev); | |||
802 | void reset_s5h1432_demod(struct cx231xx *dev); | 811 | void reset_s5h1432_demod(struct cx231xx *dev); |
803 | void cx231xx_dump_HH_reg(struct cx231xx *dev); | 812 | void cx231xx_dump_HH_reg(struct cx231xx *dev); |
804 | void update_HH_register_after_set_DIF(struct cx231xx *dev); | 813 | void update_HH_register_after_set_DIF(struct cx231xx *dev); |
805 | void cx231xx_dump_SC_reg(struct cx231xx *dev); | ||
806 | 814 | ||
807 | 815 | ||
808 | 816 | ||
@@ -976,23 +984,6 @@ void cx231xx_ir_exit(struct cx231xx *dev); | |||
976 | #define cx231xx_ir_exit(dev) (0) | 984 | #define cx231xx_ir_exit(dev) (0) |
977 | #endif | 985 | #endif |
978 | 986 | ||
979 | |||
980 | /* printk macros */ | ||
981 | |||
982 | #define cx231xx_err(fmt, arg...) do {\ | ||
983 | printk(KERN_ERR fmt , ##arg); } while (0) | ||
984 | |||
985 | #define cx231xx_errdev(fmt, arg...) do {\ | ||
986 | printk(KERN_ERR "%s: "fmt,\ | ||
987 | dev->name , ##arg); } while (0) | ||
988 | |||
989 | #define cx231xx_info(fmt, arg...) do {\ | ||
990 | printk(KERN_INFO "%s: "fmt,\ | ||
991 | dev->name , ##arg); } while (0) | ||
992 | #define cx231xx_warn(fmt, arg...) do {\ | ||
993 | printk(KERN_WARNING "%s: "fmt,\ | ||
994 | dev->name , ##arg); } while (0) | ||
995 | |||
996 | static inline unsigned int norm_maxw(struct cx231xx *dev) | 987 | static inline unsigned int norm_maxw(struct cx231xx *dev) |
997 | { | 988 | { |
998 | if (dev->board.max_range_640_480) | 989 | if (dev->board.max_range_640_480) |
diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig b/drivers/media/usb/dvb-usb-v2/Kconfig index 5b34323ad207..0982e734fab5 100644 --- a/drivers/media/usb/dvb-usb-v2/Kconfig +++ b/drivers/media/usb/dvb-usb-v2/Kconfig | |||
@@ -145,6 +145,9 @@ config DVB_USB_DVBSKY | |||
145 | tristate "DVBSky USB support" | 145 | tristate "DVBSky USB support" |
146 | depends on DVB_USB_V2 | 146 | depends on DVB_USB_V2 |
147 | select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT | 147 | select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT |
148 | select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT | ||
148 | select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT | 149 | select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT |
150 | select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT | ||
151 | select DVB_SP2 if MEDIA_SUBDRV_AUTOSELECT | ||
149 | help | 152 | help |
150 | Say Y here to support the USB receivers from DVBSky. | 153 | Say Y here to support the USB receivers from DVBSky. |
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index 1896ab218b11..80a29f5377ea 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c | |||
@@ -1171,6 +1171,7 @@ static int it930x_frontend_attach(struct dvb_usb_adapter *adap) | |||
1171 | 1171 | ||
1172 | dev_dbg(&d->udev->dev, "adap->id=%d\n", adap->id); | 1172 | dev_dbg(&d->udev->dev, "adap->id=%d\n", adap->id); |
1173 | 1173 | ||
1174 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
1174 | si2168_config.i2c_adapter = &adapter; | 1175 | si2168_config.i2c_adapter = &adapter; |
1175 | si2168_config.fe = &adap->fe[0]; | 1176 | si2168_config.fe = &adap->fe[0]; |
1176 | si2168_config.ts_mode = SI2168_TS_SERIAL; | 1177 | si2168_config.ts_mode = SI2168_TS_SERIAL; |
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c index 34688c89df11..9b5add4499e3 100644 --- a/drivers/media/usb/dvb-usb-v2/dvbsky.c +++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c | |||
@@ -21,10 +21,17 @@ | |||
21 | #include "dvb_usb.h" | 21 | #include "dvb_usb.h" |
22 | #include "m88ds3103.h" | 22 | #include "m88ds3103.h" |
23 | #include "m88ts2022.h" | 23 | #include "m88ts2022.h" |
24 | #include "sp2.h" | ||
25 | #include "si2168.h" | ||
26 | #include "si2157.h" | ||
24 | 27 | ||
25 | #define DVBSKY_MSG_DELAY 0/*2000*/ | 28 | #define DVBSKY_MSG_DELAY 0/*2000*/ |
26 | #define DVBSKY_BUF_LEN 64 | 29 | #define DVBSKY_BUF_LEN 64 |
27 | 30 | ||
31 | static int dvb_usb_dvbsky_disable_rc; | ||
32 | module_param_named(disable_rc, dvb_usb_dvbsky_disable_rc, int, 0644); | ||
33 | MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver."); | ||
34 | |||
28 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 35 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
29 | 36 | ||
30 | struct dvbsky_state { | 37 | struct dvbsky_state { |
@@ -32,7 +39,9 @@ struct dvbsky_state { | |||
32 | u8 ibuf[DVBSKY_BUF_LEN]; | 39 | u8 ibuf[DVBSKY_BUF_LEN]; |
33 | u8 obuf[DVBSKY_BUF_LEN]; | 40 | u8 obuf[DVBSKY_BUF_LEN]; |
34 | u8 last_lock; | 41 | u8 last_lock; |
42 | struct i2c_client *i2c_client_demod; | ||
35 | struct i2c_client *i2c_client_tuner; | 43 | struct i2c_client *i2c_client_tuner; |
44 | struct i2c_client *i2c_client_ci; | ||
36 | 45 | ||
37 | /* fe hook functions*/ | 46 | /* fe hook functions*/ |
38 | int (*fe_set_voltage)(struct dvb_frontend *fe, | 47 | int (*fe_set_voltage)(struct dvb_frontend *fe, |
@@ -96,8 +105,7 @@ static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 gport, u8 value) | |||
96 | obuf[2] = value; | 105 | obuf[2] = value; |
97 | ret = dvbsky_usb_generic_rw(d, obuf, 3, ibuf, 1); | 106 | ret = dvbsky_usb_generic_rw(d, obuf, 3, ibuf, 1); |
98 | if (ret) | 107 | if (ret) |
99 | dev_err(&d->udev->dev, "%s: %s() failed=%d\n", | 108 | dev_err(&d->udev->dev, "failed=%d\n", ret); |
100 | KBUILD_MODNAME, __func__, ret); | ||
101 | return ret; | 109 | return ret; |
102 | } | 110 | } |
103 | 111 | ||
@@ -114,7 +122,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
114 | 122 | ||
115 | if (num > 2) { | 123 | if (num > 2) { |
116 | dev_err(&d->udev->dev, | 124 | dev_err(&d->udev->dev, |
117 | "dvbsky_usb: too many i2c messages[%d] than 2.", num); | 125 | "too many i2c messages[%d], max 2.", num); |
118 | ret = -EOPNOTSUPP; | 126 | ret = -EOPNOTSUPP; |
119 | goto i2c_error; | 127 | goto i2c_error; |
120 | } | 128 | } |
@@ -122,7 +130,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
122 | if (num == 1) { | 130 | if (num == 1) { |
123 | if (msg[0].len > 60) { | 131 | if (msg[0].len > 60) { |
124 | dev_err(&d->udev->dev, | 132 | dev_err(&d->udev->dev, |
125 | "dvbsky_usb: too many i2c bytes[%d] than 60.", | 133 | "too many i2c bytes[%d], max 60.", |
126 | msg[0].len); | 134 | msg[0].len); |
127 | ret = -EOPNOTSUPP; | 135 | ret = -EOPNOTSUPP; |
128 | goto i2c_error; | 136 | goto i2c_error; |
@@ -136,8 +144,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
136 | ret = dvbsky_usb_generic_rw(d, obuf, 4, | 144 | ret = dvbsky_usb_generic_rw(d, obuf, 4, |
137 | ibuf, msg[0].len + 1); | 145 | ibuf, msg[0].len + 1); |
138 | if (ret) | 146 | if (ret) |
139 | dev_err(&d->udev->dev, "%s: %s() failed=%d\n", | 147 | dev_err(&d->udev->dev, "failed=%d\n", ret); |
140 | KBUILD_MODNAME, __func__, ret); | ||
141 | if (!ret) | 148 | if (!ret) |
142 | memcpy(msg[0].buf, &ibuf[1], msg[0].len); | 149 | memcpy(msg[0].buf, &ibuf[1], msg[0].len); |
143 | } else { | 150 | } else { |
@@ -149,13 +156,12 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
149 | ret = dvbsky_usb_generic_rw(d, obuf, | 156 | ret = dvbsky_usb_generic_rw(d, obuf, |
150 | msg[0].len + 3, ibuf, 1); | 157 | msg[0].len + 3, ibuf, 1); |
151 | if (ret) | 158 | if (ret) |
152 | dev_err(&d->udev->dev, "%s: %s() failed=%d\n", | 159 | dev_err(&d->udev->dev, "failed=%d\n", ret); |
153 | KBUILD_MODNAME, __func__, ret); | ||
154 | } | 160 | } |
155 | } else { | 161 | } else { |
156 | if ((msg[0].len > 60) || (msg[1].len > 60)) { | 162 | if ((msg[0].len > 60) || (msg[1].len > 60)) { |
157 | dev_err(&d->udev->dev, | 163 | dev_err(&d->udev->dev, |
158 | "dvbsky_usb: too many i2c bytes[w-%d][r-%d] than 60.", | 164 | "too many i2c bytes[w-%d][r-%d], max 60.", |
159 | msg[0].len, msg[1].len); | 165 | msg[0].len, msg[1].len); |
160 | ret = -EOPNOTSUPP; | 166 | ret = -EOPNOTSUPP; |
161 | goto i2c_error; | 167 | goto i2c_error; |
@@ -169,8 +175,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
169 | ret = dvbsky_usb_generic_rw(d, obuf, | 175 | ret = dvbsky_usb_generic_rw(d, obuf, |
170 | msg[0].len + 4, ibuf, msg[1].len + 1); | 176 | msg[0].len + 4, ibuf, msg[1].len + 1); |
171 | if (ret) | 177 | if (ret) |
172 | dev_err(&d->udev->dev, "%s: %s() failed=%d\n", | 178 | dev_err(&d->udev->dev, "failed=%d\n", ret); |
173 | KBUILD_MODNAME, __func__, ret); | ||
174 | 179 | ||
175 | if (!ret) | 180 | if (!ret) |
176 | memcpy(msg[1].buf, &ibuf[1], msg[1].len); | 181 | memcpy(msg[1].buf, &ibuf[1], msg[1].len); |
@@ -201,8 +206,7 @@ static int dvbsky_rc_query(struct dvb_usb_device *d) | |||
201 | obuf[0] = 0x10; | 206 | obuf[0] = 0x10; |
202 | ret = dvbsky_usb_generic_rw(d, obuf, 1, ibuf, 2); | 207 | ret = dvbsky_usb_generic_rw(d, obuf, 1, ibuf, 2); |
203 | if (ret) | 208 | if (ret) |
204 | dev_err(&d->udev->dev, "%s: %s() failed=%d\n", | 209 | dev_err(&d->udev->dev, "failed=%d\n", ret); |
205 | KBUILD_MODNAME, __func__, ret); | ||
206 | if (ret == 0) | 210 | if (ret == 0) |
207 | code = (ibuf[0] << 8) | ibuf[1]; | 211 | code = (ibuf[0] << 8) | ibuf[1]; |
208 | if (code != 0xffff) { | 212 | if (code != 0xffff) { |
@@ -218,6 +222,11 @@ static int dvbsky_rc_query(struct dvb_usb_device *d) | |||
218 | 222 | ||
219 | static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | 223 | static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) |
220 | { | 224 | { |
225 | if (dvb_usb_dvbsky_disable_rc) { | ||
226 | rc->map_name = NULL; | ||
227 | return 0; | ||
228 | } | ||
229 | |||
221 | rc->allowed_protos = RC_BIT_RC5; | 230 | rc->allowed_protos = RC_BIT_RC5; |
222 | rc->query = dvbsky_rc_query; | 231 | rc->query = dvbsky_rc_query; |
223 | rc->interval = 300; | 232 | rc->interval = 300; |
@@ -265,8 +274,6 @@ static int dvbsky_read_mac_addr(struct dvb_usb_adapter *adap, u8 mac[6]) | |||
265 | if (i2c_transfer(&d->i2c_adap, msg, 2) == 2) | 274 | if (i2c_transfer(&d->i2c_adap, msg, 2) == 2) |
266 | memcpy(mac, ibuf, 6); | 275 | memcpy(mac, ibuf, 6); |
267 | 276 | ||
268 | dev_info(&d->udev->dev, "dvbsky_usb MAC address=%pM\n", mac); | ||
269 | |||
270 | return 0; | 277 | return 0; |
271 | } | 278 | } |
272 | 279 | ||
@@ -362,6 +369,300 @@ fail_attach: | |||
362 | return ret; | 369 | return ret; |
363 | } | 370 | } |
364 | 371 | ||
372 | static int dvbsky_usb_ci_set_voltage(struct dvb_frontend *fe, | ||
373 | fe_sec_voltage_t voltage) | ||
374 | { | ||
375 | struct dvb_usb_device *d = fe_to_d(fe); | ||
376 | struct dvbsky_state *state = d_to_priv(d); | ||
377 | u8 value; | ||
378 | |||
379 | if (voltage == SEC_VOLTAGE_OFF) | ||
380 | value = 0; | ||
381 | else | ||
382 | value = 1; | ||
383 | dvbsky_gpio_ctrl(d, 0x00, value); | ||
384 | |||
385 | return state->fe_set_voltage(fe, voltage); | ||
386 | } | ||
387 | |||
388 | static int dvbsky_ci_ctrl(void *priv, u8 read, int addr, | ||
389 | u8 data, int *mem) | ||
390 | { | ||
391 | struct dvb_usb_device *d = priv; | ||
392 | int ret = 0; | ||
393 | u8 command[4], respond[2], command_size, respond_size; | ||
394 | |||
395 | command[1] = (u8)((addr >> 8) & 0xff); /*high part of address*/ | ||
396 | command[2] = (u8)(addr & 0xff); /*low part of address*/ | ||
397 | if (read) { | ||
398 | command[0] = 0x71; | ||
399 | command_size = 3; | ||
400 | respond_size = 2; | ||
401 | } else { | ||
402 | command[0] = 0x70; | ||
403 | command[3] = data; | ||
404 | command_size = 4; | ||
405 | respond_size = 1; | ||
406 | } | ||
407 | ret = dvbsky_usb_generic_rw(d, command, command_size, | ||
408 | respond, respond_size); | ||
409 | if (ret) | ||
410 | goto err; | ||
411 | if (read) | ||
412 | *mem = respond[1]; | ||
413 | return ret; | ||
414 | err: | ||
415 | dev_err(&d->udev->dev, "ci control failed=%d\n", ret); | ||
416 | return ret; | ||
417 | } | ||
418 | |||
419 | static const struct m88ds3103_config dvbsky_s960c_m88ds3103_config = { | ||
420 | .i2c_addr = 0x68, | ||
421 | .clock = 27000000, | ||
422 | .i2c_wr_max = 33, | ||
423 | .clock_out = 0, | ||
424 | .ts_mode = M88DS3103_TS_CI, | ||
425 | .ts_clk = 10000, | ||
426 | .ts_clk_pol = 1, | ||
427 | .agc = 0x99, | ||
428 | .lnb_hv_pol = 0, | ||
429 | .lnb_en_pol = 1, | ||
430 | }; | ||
431 | |||
432 | static int dvbsky_s960c_attach(struct dvb_usb_adapter *adap) | ||
433 | { | ||
434 | struct dvbsky_state *state = adap_to_priv(adap); | ||
435 | struct dvb_usb_device *d = adap_to_d(adap); | ||
436 | int ret = 0; | ||
437 | /* demod I2C adapter */ | ||
438 | struct i2c_adapter *i2c_adapter; | ||
439 | struct i2c_client *client_tuner, *client_ci; | ||
440 | struct i2c_board_info info; | ||
441 | struct sp2_config sp2_config; | ||
442 | struct m88ts2022_config m88ts2022_config = { | ||
443 | .clock = 27000000, | ||
444 | }; | ||
445 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
446 | |||
447 | /* attach demod */ | ||
448 | adap->fe[0] = dvb_attach(m88ds3103_attach, | ||
449 | &dvbsky_s960c_m88ds3103_config, | ||
450 | &d->i2c_adap, | ||
451 | &i2c_adapter); | ||
452 | if (!adap->fe[0]) { | ||
453 | dev_err(&d->udev->dev, "dvbsky_s960ci_attach fail.\n"); | ||
454 | ret = -ENODEV; | ||
455 | goto fail_attach; | ||
456 | } | ||
457 | |||
458 | /* attach tuner */ | ||
459 | m88ts2022_config.fe = adap->fe[0]; | ||
460 | strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE); | ||
461 | info.addr = 0x60; | ||
462 | info.platform_data = &m88ts2022_config; | ||
463 | request_module("m88ts2022"); | ||
464 | client_tuner = i2c_new_device(i2c_adapter, &info); | ||
465 | if (client_tuner == NULL || client_tuner->dev.driver == NULL) { | ||
466 | ret = -ENODEV; | ||
467 | goto fail_tuner_device; | ||
468 | } | ||
469 | |||
470 | if (!try_module_get(client_tuner->dev.driver->owner)) { | ||
471 | ret = -ENODEV; | ||
472 | goto fail_tuner_module; | ||
473 | } | ||
474 | |||
475 | /* attach ci controller */ | ||
476 | memset(&sp2_config, 0, sizeof(sp2_config)); | ||
477 | sp2_config.dvb_adap = &adap->dvb_adap; | ||
478 | sp2_config.priv = d; | ||
479 | sp2_config.ci_control = dvbsky_ci_ctrl; | ||
480 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
481 | strlcpy(info.type, "sp2", I2C_NAME_SIZE); | ||
482 | info.addr = 0x40; | ||
483 | info.platform_data = &sp2_config; | ||
484 | request_module("sp2"); | ||
485 | client_ci = i2c_new_device(&d->i2c_adap, &info); | ||
486 | if (client_ci == NULL || client_ci->dev.driver == NULL) { | ||
487 | ret = -ENODEV; | ||
488 | goto fail_ci_device; | ||
489 | } | ||
490 | |||
491 | if (!try_module_get(client_ci->dev.driver->owner)) { | ||
492 | ret = -ENODEV; | ||
493 | goto fail_ci_module; | ||
494 | } | ||
495 | |||
496 | /* delegate signal strength measurement to tuner */ | ||
497 | adap->fe[0]->ops.read_signal_strength = | ||
498 | adap->fe[0]->ops.tuner_ops.get_rf_strength; | ||
499 | |||
500 | /* hook fe: need to resync the slave fifo when signal locks. */ | ||
501 | state->fe_read_status = adap->fe[0]->ops.read_status; | ||
502 | adap->fe[0]->ops.read_status = dvbsky_usb_read_status; | ||
503 | |||
504 | /* hook fe: LNB off/on is control by Cypress usb chip. */ | ||
505 | state->fe_set_voltage = adap->fe[0]->ops.set_voltage; | ||
506 | adap->fe[0]->ops.set_voltage = dvbsky_usb_ci_set_voltage; | ||
507 | |||
508 | state->i2c_client_tuner = client_tuner; | ||
509 | state->i2c_client_ci = client_ci; | ||
510 | return ret; | ||
511 | fail_ci_module: | ||
512 | i2c_unregister_device(client_ci); | ||
513 | fail_ci_device: | ||
514 | module_put(client_tuner->dev.driver->owner); | ||
515 | fail_tuner_module: | ||
516 | i2c_unregister_device(client_tuner); | ||
517 | fail_tuner_device: | ||
518 | dvb_frontend_detach(adap->fe[0]); | ||
519 | fail_attach: | ||
520 | return ret; | ||
521 | } | ||
522 | |||
523 | static int dvbsky_t680c_attach(struct dvb_usb_adapter *adap) | ||
524 | { | ||
525 | struct dvbsky_state *state = adap_to_priv(adap); | ||
526 | struct dvb_usb_device *d = adap_to_d(adap); | ||
527 | int ret = 0; | ||
528 | struct i2c_adapter *i2c_adapter; | ||
529 | struct i2c_client *client_demod, *client_tuner, *client_ci; | ||
530 | struct i2c_board_info info; | ||
531 | struct si2168_config si2168_config; | ||
532 | struct si2157_config si2157_config; | ||
533 | struct sp2_config sp2_config; | ||
534 | |||
535 | /* attach demod */ | ||
536 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
537 | si2168_config.i2c_adapter = &i2c_adapter; | ||
538 | si2168_config.fe = &adap->fe[0]; | ||
539 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | ||
540 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
541 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); | ||
542 | info.addr = 0x64; | ||
543 | info.platform_data = &si2168_config; | ||
544 | |||
545 | request_module(info.type); | ||
546 | client_demod = i2c_new_device(&d->i2c_adap, &info); | ||
547 | if (client_demod == NULL || | ||
548 | client_demod->dev.driver == NULL) | ||
549 | goto fail_demod_device; | ||
550 | if (!try_module_get(client_demod->dev.driver->owner)) | ||
551 | goto fail_demod_module; | ||
552 | |||
553 | /* attach tuner */ | ||
554 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
555 | si2157_config.fe = adap->fe[0]; | ||
556 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
557 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); | ||
558 | info.addr = 0x60; | ||
559 | info.platform_data = &si2157_config; | ||
560 | |||
561 | request_module(info.type); | ||
562 | client_tuner = i2c_new_device(i2c_adapter, &info); | ||
563 | if (client_tuner == NULL || | ||
564 | client_tuner->dev.driver == NULL) | ||
565 | goto fail_tuner_device; | ||
566 | if (!try_module_get(client_tuner->dev.driver->owner)) | ||
567 | goto fail_tuner_module; | ||
568 | |||
569 | /* attach ci controller */ | ||
570 | memset(&sp2_config, 0, sizeof(sp2_config)); | ||
571 | sp2_config.dvb_adap = &adap->dvb_adap; | ||
572 | sp2_config.priv = d; | ||
573 | sp2_config.ci_control = dvbsky_ci_ctrl; | ||
574 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
575 | strlcpy(info.type, "sp2", I2C_NAME_SIZE); | ||
576 | info.addr = 0x40; | ||
577 | info.platform_data = &sp2_config; | ||
578 | |||
579 | request_module(info.type); | ||
580 | client_ci = i2c_new_device(&d->i2c_adap, &info); | ||
581 | |||
582 | if (client_ci == NULL || client_ci->dev.driver == NULL) | ||
583 | goto fail_ci_device; | ||
584 | |||
585 | if (!try_module_get(client_ci->dev.driver->owner)) | ||
586 | goto fail_ci_module; | ||
587 | |||
588 | state->i2c_client_demod = client_demod; | ||
589 | state->i2c_client_tuner = client_tuner; | ||
590 | state->i2c_client_ci = client_ci; | ||
591 | return ret; | ||
592 | fail_ci_module: | ||
593 | i2c_unregister_device(client_ci); | ||
594 | fail_ci_device: | ||
595 | module_put(client_tuner->dev.driver->owner); | ||
596 | fail_tuner_module: | ||
597 | i2c_unregister_device(client_tuner); | ||
598 | fail_tuner_device: | ||
599 | module_put(client_demod->dev.driver->owner); | ||
600 | fail_demod_module: | ||
601 | i2c_unregister_device(client_demod); | ||
602 | fail_demod_device: | ||
603 | ret = -ENODEV; | ||
604 | return ret; | ||
605 | } | ||
606 | |||
607 | static int dvbsky_t330_attach(struct dvb_usb_adapter *adap) | ||
608 | { | ||
609 | struct dvbsky_state *state = adap_to_priv(adap); | ||
610 | struct dvb_usb_device *d = adap_to_d(adap); | ||
611 | int ret = 0; | ||
612 | struct i2c_adapter *i2c_adapter; | ||
613 | struct i2c_client *client_demod, *client_tuner; | ||
614 | struct i2c_board_info info; | ||
615 | struct si2168_config si2168_config; | ||
616 | struct si2157_config si2157_config; | ||
617 | |||
618 | /* attach demod */ | ||
619 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
620 | si2168_config.i2c_adapter = &i2c_adapter; | ||
621 | si2168_config.fe = &adap->fe[0]; | ||
622 | si2168_config.ts_mode = SI2168_TS_PARALLEL | 0x40; | ||
623 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
624 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); | ||
625 | info.addr = 0x64; | ||
626 | info.platform_data = &si2168_config; | ||
627 | |||
628 | request_module(info.type); | ||
629 | client_demod = i2c_new_device(&d->i2c_adap, &info); | ||
630 | if (client_demod == NULL || | ||
631 | client_demod->dev.driver == NULL) | ||
632 | goto fail_demod_device; | ||
633 | if (!try_module_get(client_demod->dev.driver->owner)) | ||
634 | goto fail_demod_module; | ||
635 | |||
636 | /* attach tuner */ | ||
637 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
638 | si2157_config.fe = adap->fe[0]; | ||
639 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
640 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); | ||
641 | info.addr = 0x60; | ||
642 | info.platform_data = &si2157_config; | ||
643 | |||
644 | request_module(info.type); | ||
645 | client_tuner = i2c_new_device(i2c_adapter, &info); | ||
646 | if (client_tuner == NULL || | ||
647 | client_tuner->dev.driver == NULL) | ||
648 | goto fail_tuner_device; | ||
649 | if (!try_module_get(client_tuner->dev.driver->owner)) | ||
650 | goto fail_tuner_module; | ||
651 | |||
652 | state->i2c_client_demod = client_demod; | ||
653 | state->i2c_client_tuner = client_tuner; | ||
654 | return ret; | ||
655 | fail_tuner_module: | ||
656 | i2c_unregister_device(client_tuner); | ||
657 | fail_tuner_device: | ||
658 | module_put(client_demod->dev.driver->owner); | ||
659 | fail_demod_module: | ||
660 | i2c_unregister_device(client_demod); | ||
661 | fail_demod_device: | ||
662 | ret = -ENODEV; | ||
663 | return ret; | ||
664 | } | ||
665 | |||
365 | static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name) | 666 | static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name) |
366 | { | 667 | { |
367 | dvbsky_gpio_ctrl(d, 0x04, 1); | 668 | dvbsky_gpio_ctrl(d, 0x04, 1); |
@@ -404,6 +705,18 @@ static void dvbsky_exit(struct dvb_usb_device *d) | |||
404 | module_put(client->dev.driver->owner); | 705 | module_put(client->dev.driver->owner); |
405 | i2c_unregister_device(client); | 706 | i2c_unregister_device(client); |
406 | } | 707 | } |
708 | client = state->i2c_client_demod; | ||
709 | /* remove I2C demod */ | ||
710 | if (client) { | ||
711 | module_put(client->dev.driver->owner); | ||
712 | i2c_unregister_device(client); | ||
713 | } | ||
714 | client = state->i2c_client_ci; | ||
715 | /* remove I2C ci */ | ||
716 | if (client) { | ||
717 | module_put(client->dev.driver->owner); | ||
718 | i2c_unregister_device(client); | ||
719 | } | ||
407 | } | 720 | } |
408 | 721 | ||
409 | /* DVB USB Driver stuff */ | 722 | /* DVB USB Driver stuff */ |
@@ -434,9 +747,104 @@ static struct dvb_usb_device_properties dvbsky_s960_props = { | |||
434 | } | 747 | } |
435 | }; | 748 | }; |
436 | 749 | ||
750 | static struct dvb_usb_device_properties dvbsky_s960c_props = { | ||
751 | .driver_name = KBUILD_MODNAME, | ||
752 | .owner = THIS_MODULE, | ||
753 | .adapter_nr = adapter_nr, | ||
754 | .size_of_priv = sizeof(struct dvbsky_state), | ||
755 | |||
756 | .generic_bulk_ctrl_endpoint = 0x01, | ||
757 | .generic_bulk_ctrl_endpoint_response = 0x81, | ||
758 | .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY, | ||
759 | |||
760 | .i2c_algo = &dvbsky_i2c_algo, | ||
761 | .frontend_attach = dvbsky_s960c_attach, | ||
762 | .init = dvbsky_init, | ||
763 | .get_rc_config = dvbsky_get_rc_config, | ||
764 | .streaming_ctrl = dvbsky_streaming_ctrl, | ||
765 | .identify_state = dvbsky_identify_state, | ||
766 | .exit = dvbsky_exit, | ||
767 | .read_mac_address = dvbsky_read_mac_addr, | ||
768 | |||
769 | .num_adapters = 1, | ||
770 | .adapter = { | ||
771 | { | ||
772 | .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096), | ||
773 | } | ||
774 | } | ||
775 | }; | ||
776 | |||
777 | static struct dvb_usb_device_properties dvbsky_t680c_props = { | ||
778 | .driver_name = KBUILD_MODNAME, | ||
779 | .owner = THIS_MODULE, | ||
780 | .adapter_nr = adapter_nr, | ||
781 | .size_of_priv = sizeof(struct dvbsky_state), | ||
782 | |||
783 | .generic_bulk_ctrl_endpoint = 0x01, | ||
784 | .generic_bulk_ctrl_endpoint_response = 0x81, | ||
785 | .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY, | ||
786 | |||
787 | .i2c_algo = &dvbsky_i2c_algo, | ||
788 | .frontend_attach = dvbsky_t680c_attach, | ||
789 | .init = dvbsky_init, | ||
790 | .get_rc_config = dvbsky_get_rc_config, | ||
791 | .streaming_ctrl = dvbsky_streaming_ctrl, | ||
792 | .identify_state = dvbsky_identify_state, | ||
793 | .exit = dvbsky_exit, | ||
794 | .read_mac_address = dvbsky_read_mac_addr, | ||
795 | |||
796 | .num_adapters = 1, | ||
797 | .adapter = { | ||
798 | { | ||
799 | .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096), | ||
800 | } | ||
801 | } | ||
802 | }; | ||
803 | |||
804 | static struct dvb_usb_device_properties dvbsky_t330_props = { | ||
805 | .driver_name = KBUILD_MODNAME, | ||
806 | .owner = THIS_MODULE, | ||
807 | .adapter_nr = adapter_nr, | ||
808 | .size_of_priv = sizeof(struct dvbsky_state), | ||
809 | |||
810 | .generic_bulk_ctrl_endpoint = 0x01, | ||
811 | .generic_bulk_ctrl_endpoint_response = 0x81, | ||
812 | .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY, | ||
813 | |||
814 | .i2c_algo = &dvbsky_i2c_algo, | ||
815 | .frontend_attach = dvbsky_t330_attach, | ||
816 | .init = dvbsky_init, | ||
817 | .get_rc_config = dvbsky_get_rc_config, | ||
818 | .streaming_ctrl = dvbsky_streaming_ctrl, | ||
819 | .identify_state = dvbsky_identify_state, | ||
820 | .exit = dvbsky_exit, | ||
821 | .read_mac_address = dvbsky_read_mac_addr, | ||
822 | |||
823 | .num_adapters = 1, | ||
824 | .adapter = { | ||
825 | { | ||
826 | .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096), | ||
827 | } | ||
828 | } | ||
829 | }; | ||
830 | |||
437 | static const struct usb_device_id dvbsky_id_table[] = { | 831 | static const struct usb_device_id dvbsky_id_table[] = { |
438 | { DVB_USB_DEVICE(0x0572, 0x6831, | 832 | { DVB_USB_DEVICE(0x0572, 0x6831, |
439 | &dvbsky_s960_props, "DVBSky S960/S860", RC_MAP_DVBSKY) }, | 833 | &dvbsky_s960_props, "DVBSky S960/S860", RC_MAP_DVBSKY) }, |
834 | { DVB_USB_DEVICE(0x0572, 0x960c, | ||
835 | &dvbsky_s960c_props, "DVBSky S960CI", RC_MAP_DVBSKY) }, | ||
836 | { DVB_USB_DEVICE(0x0572, 0x680c, | ||
837 | &dvbsky_t680c_props, "DVBSky T680CI", RC_MAP_DVBSKY) }, | ||
838 | { DVB_USB_DEVICE(0x0572, 0x0320, | ||
839 | &dvbsky_t330_props, "DVBSky T330", RC_MAP_DVBSKY) }, | ||
840 | { DVB_USB_DEVICE(USB_VID_TECHNOTREND, | ||
841 | USB_PID_TECHNOTREND_TVSTICK_CT2_4400, | ||
842 | &dvbsky_t330_props, "TechnoTrend TVStick CT2-4400", | ||
843 | RC_MAP_TT_1500) }, | ||
844 | { DVB_USB_DEVICE(USB_VID_TECHNOTREND, | ||
845 | USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI, | ||
846 | &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI", | ||
847 | RC_MAP_TT_1500) }, | ||
440 | { } | 848 | { } |
441 | }; | 849 | }; |
442 | MODULE_DEVICE_TABLE(usb, dvbsky_id_table); | 850 | MODULE_DEVICE_TABLE(usb, dvbsky_id_table); |
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 9f2c5459b73a..994de53a574b 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c | |||
@@ -817,20 +817,22 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold) | |||
817 | case 0x1122: | 817 | case 0x1122: |
818 | switch (st->dvb_usb_lme2510_firmware) { | 818 | switch (st->dvb_usb_lme2510_firmware) { |
819 | default: | 819 | default: |
820 | st->dvb_usb_lme2510_firmware = TUNER_S0194; | ||
821 | case TUNER_S0194: | 820 | case TUNER_S0194: |
822 | fw_lme = fw_s0194; | 821 | fw_lme = fw_s0194; |
823 | ret = request_firmware(&fw, fw_lme, &udev->dev); | 822 | ret = request_firmware(&fw, fw_lme, &udev->dev); |
824 | if (ret == 0) { | 823 | if (ret == 0) { |
824 | st->dvb_usb_lme2510_firmware = TUNER_S0194; | ||
825 | cold = 0; | 825 | cold = 0; |
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | st->dvb_usb_lme2510_firmware = TUNER_LG; | 828 | /* fall through */ |
829 | case TUNER_LG: | 829 | case TUNER_LG: |
830 | fw_lme = fw_lg; | 830 | fw_lme = fw_lg; |
831 | ret = request_firmware(&fw, fw_lme, &udev->dev); | 831 | ret = request_firmware(&fw, fw_lme, &udev->dev); |
832 | if (ret == 0) | 832 | if (ret == 0) { |
833 | st->dvb_usb_lme2510_firmware = TUNER_LG; | ||
833 | break; | 834 | break; |
835 | } | ||
834 | st->dvb_usb_lme2510_firmware = TUNER_DEFAULT; | 836 | st->dvb_usb_lme2510_firmware = TUNER_DEFAULT; |
835 | break; | 837 | break; |
836 | } | 838 | } |
@@ -838,26 +840,30 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold) | |||
838 | case 0x1120: | 840 | case 0x1120: |
839 | switch (st->dvb_usb_lme2510_firmware) { | 841 | switch (st->dvb_usb_lme2510_firmware) { |
840 | default: | 842 | default: |
841 | st->dvb_usb_lme2510_firmware = TUNER_S7395; | ||
842 | case TUNER_S7395: | 843 | case TUNER_S7395: |
843 | fw_lme = fw_c_s7395; | 844 | fw_lme = fw_c_s7395; |
844 | ret = request_firmware(&fw, fw_lme, &udev->dev); | 845 | ret = request_firmware(&fw, fw_lme, &udev->dev); |
845 | if (ret == 0) { | 846 | if (ret == 0) { |
847 | st->dvb_usb_lme2510_firmware = TUNER_S7395; | ||
846 | cold = 0; | 848 | cold = 0; |
847 | break; | 849 | break; |
848 | } | 850 | } |
849 | st->dvb_usb_lme2510_firmware = TUNER_LG; | 851 | /* fall through */ |
850 | case TUNER_LG: | 852 | case TUNER_LG: |
851 | fw_lme = fw_c_lg; | 853 | fw_lme = fw_c_lg; |
852 | ret = request_firmware(&fw, fw_lme, &udev->dev); | 854 | ret = request_firmware(&fw, fw_lme, &udev->dev); |
853 | if (ret == 0) | 855 | if (ret == 0) { |
856 | st->dvb_usb_lme2510_firmware = TUNER_LG; | ||
854 | break; | 857 | break; |
855 | st->dvb_usb_lme2510_firmware = TUNER_S0194; | 858 | } |
859 | /* fall through */ | ||
856 | case TUNER_S0194: | 860 | case TUNER_S0194: |
857 | fw_lme = fw_c_s0194; | 861 | fw_lme = fw_c_s0194; |
858 | ret = request_firmware(&fw, fw_lme, &udev->dev); | 862 | ret = request_firmware(&fw, fw_lme, &udev->dev); |
859 | if (ret == 0) | 863 | if (ret == 0) { |
864 | st->dvb_usb_lme2510_firmware = TUNER_S0194; | ||
860 | break; | 865 | break; |
866 | } | ||
861 | st->dvb_usb_lme2510_firmware = TUNER_DEFAULT; | 867 | st->dvb_usb_lme2510_firmware = TUNER_DEFAULT; |
862 | cold = 0; | 868 | cold = 0; |
863 | break; | 869 | break; |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 27b1e0397e71..896a225ee011 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c | |||
@@ -24,6 +24,9 @@ | |||
24 | 24 | ||
25 | #include "rtl2830.h" | 25 | #include "rtl2830.h" |
26 | #include "rtl2832.h" | 26 | #include "rtl2832.h" |
27 | #include "rtl2832_sdr.h" | ||
28 | #include "mn88472.h" | ||
29 | #include "mn88473.h" | ||
27 | 30 | ||
28 | #include "qt1010.h" | 31 | #include "qt1010.h" |
29 | #include "mt2060.h" | 32 | #include "mt2060.h" |
@@ -35,25 +38,6 @@ | |||
35 | #include "tua9001.h" | 38 | #include "tua9001.h" |
36 | #include "r820t.h" | 39 | #include "r820t.h" |
37 | 40 | ||
38 | /* | ||
39 | * RTL2832_SDR module is in staging. That logic is added in order to avoid any | ||
40 | * hard dependency to drivers/staging/ directory as we want compile mainline | ||
41 | * driver even whole staging directory is missing. | ||
42 | */ | ||
43 | #include <media/v4l2-subdev.h> | ||
44 | |||
45 | #if IS_ENABLED(CONFIG_DVB_RTL2832_SDR) | ||
46 | struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe, | ||
47 | struct i2c_adapter *i2c, const struct rtl2832_config *cfg, | ||
48 | struct v4l2_subdev *sd); | ||
49 | #else | ||
50 | static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe, | ||
51 | struct i2c_adapter *i2c, const struct rtl2832_config *cfg, | ||
52 | struct v4l2_subdev *sd) | ||
53 | { | ||
54 | return NULL; | ||
55 | } | ||
56 | #endif | ||
57 | 41 | ||
58 | #ifdef CONFIG_MEDIA_ATTACH | 42 | #ifdef CONFIG_MEDIA_ATTACH |
59 | #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ | 43 | #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ |
@@ -420,6 +404,8 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
420 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; | 404 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; |
421 | struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 1, buf}; | 405 | struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 1, buf}; |
422 | struct rtl28xxu_req req_r828d = {0x0074, CMD_I2C_RD, 1, buf}; | 406 | struct rtl28xxu_req req_r828d = {0x0074, CMD_I2C_RD, 1, buf}; |
407 | struct rtl28xxu_req req_mn88472 = {0xff38, CMD_I2C_RD, 1, buf}; | ||
408 | struct rtl28xxu_req req_mn88473 = {0xff38, CMD_I2C_RD, 1, buf}; | ||
423 | 409 | ||
424 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 410 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
425 | 411 | ||
@@ -449,7 +435,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
449 | if (ret == 0 && buf[0] == 0xa1) { | 435 | if (ret == 0 && buf[0] == 0xa1) { |
450 | priv->tuner = TUNER_RTL2832_FC0012; | 436 | priv->tuner = TUNER_RTL2832_FC0012; |
451 | priv->tuner_name = "FC0012"; | 437 | priv->tuner_name = "FC0012"; |
452 | goto found; | 438 | goto tuner_found; |
453 | } | 439 | } |
454 | 440 | ||
455 | /* check FC0013 ID register; reg=00 val=a3 */ | 441 | /* check FC0013 ID register; reg=00 val=a3 */ |
@@ -457,7 +443,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
457 | if (ret == 0 && buf[0] == 0xa3) { | 443 | if (ret == 0 && buf[0] == 0xa3) { |
458 | priv->tuner = TUNER_RTL2832_FC0013; | 444 | priv->tuner = TUNER_RTL2832_FC0013; |
459 | priv->tuner_name = "FC0013"; | 445 | priv->tuner_name = "FC0013"; |
460 | goto found; | 446 | goto tuner_found; |
461 | } | 447 | } |
462 | 448 | ||
463 | /* check MT2266 ID register; reg=00 val=85 */ | 449 | /* check MT2266 ID register; reg=00 val=85 */ |
@@ -465,7 +451,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
465 | if (ret == 0 && buf[0] == 0x85) { | 451 | if (ret == 0 && buf[0] == 0x85) { |
466 | priv->tuner = TUNER_RTL2832_MT2266; | 452 | priv->tuner = TUNER_RTL2832_MT2266; |
467 | priv->tuner_name = "MT2266"; | 453 | priv->tuner_name = "MT2266"; |
468 | goto found; | 454 | goto tuner_found; |
469 | } | 455 | } |
470 | 456 | ||
471 | /* check FC2580 ID register; reg=01 val=56 */ | 457 | /* check FC2580 ID register; reg=01 val=56 */ |
@@ -473,7 +459,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
473 | if (ret == 0 && buf[0] == 0x56) { | 459 | if (ret == 0 && buf[0] == 0x56) { |
474 | priv->tuner = TUNER_RTL2832_FC2580; | 460 | priv->tuner = TUNER_RTL2832_FC2580; |
475 | priv->tuner_name = "FC2580"; | 461 | priv->tuner_name = "FC2580"; |
476 | goto found; | 462 | goto tuner_found; |
477 | } | 463 | } |
478 | 464 | ||
479 | /* check MT2063 ID register; reg=00 val=9e || 9c */ | 465 | /* check MT2063 ID register; reg=00 val=9e || 9c */ |
@@ -481,7 +467,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
481 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { | 467 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { |
482 | priv->tuner = TUNER_RTL2832_MT2063; | 468 | priv->tuner = TUNER_RTL2832_MT2063; |
483 | priv->tuner_name = "MT2063"; | 469 | priv->tuner_name = "MT2063"; |
484 | goto found; | 470 | goto tuner_found; |
485 | } | 471 | } |
486 | 472 | ||
487 | /* check MAX3543 ID register; reg=00 val=38 */ | 473 | /* check MAX3543 ID register; reg=00 val=38 */ |
@@ -489,7 +475,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
489 | if (ret == 0 && buf[0] == 0x38) { | 475 | if (ret == 0 && buf[0] == 0x38) { |
490 | priv->tuner = TUNER_RTL2832_MAX3543; | 476 | priv->tuner = TUNER_RTL2832_MAX3543; |
491 | priv->tuner_name = "MAX3543"; | 477 | priv->tuner_name = "MAX3543"; |
492 | goto found; | 478 | goto tuner_found; |
493 | } | 479 | } |
494 | 480 | ||
495 | /* check TUA9001 ID register; reg=7e val=2328 */ | 481 | /* check TUA9001 ID register; reg=7e val=2328 */ |
@@ -497,7 +483,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
497 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { | 483 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { |
498 | priv->tuner = TUNER_RTL2832_TUA9001; | 484 | priv->tuner = TUNER_RTL2832_TUA9001; |
499 | priv->tuner_name = "TUA9001"; | 485 | priv->tuner_name = "TUA9001"; |
500 | goto found; | 486 | goto tuner_found; |
501 | } | 487 | } |
502 | 488 | ||
503 | /* check MXL5007R ID register; reg=d9 val=14 */ | 489 | /* check MXL5007R ID register; reg=d9 val=14 */ |
@@ -505,7 +491,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
505 | if (ret == 0 && buf[0] == 0x14) { | 491 | if (ret == 0 && buf[0] == 0x14) { |
506 | priv->tuner = TUNER_RTL2832_MXL5007T; | 492 | priv->tuner = TUNER_RTL2832_MXL5007T; |
507 | priv->tuner_name = "MXL5007T"; | 493 | priv->tuner_name = "MXL5007T"; |
508 | goto found; | 494 | goto tuner_found; |
509 | } | 495 | } |
510 | 496 | ||
511 | /* check E4000 ID register; reg=02 val=40 */ | 497 | /* check E4000 ID register; reg=02 val=40 */ |
@@ -513,7 +499,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
513 | if (ret == 0 && buf[0] == 0x40) { | 499 | if (ret == 0 && buf[0] == 0x40) { |
514 | priv->tuner = TUNER_RTL2832_E4000; | 500 | priv->tuner = TUNER_RTL2832_E4000; |
515 | priv->tuner_name = "E4000"; | 501 | priv->tuner_name = "E4000"; |
516 | goto found; | 502 | goto tuner_found; |
517 | } | 503 | } |
518 | 504 | ||
519 | /* check TDA18272 ID register; reg=00 val=c760 */ | 505 | /* check TDA18272 ID register; reg=00 val=c760 */ |
@@ -521,7 +507,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
521 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { | 507 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { |
522 | priv->tuner = TUNER_RTL2832_TDA18272; | 508 | priv->tuner = TUNER_RTL2832_TDA18272; |
523 | priv->tuner_name = "TDA18272"; | 509 | priv->tuner_name = "TDA18272"; |
524 | goto found; | 510 | goto tuner_found; |
525 | } | 511 | } |
526 | 512 | ||
527 | /* check R820T ID register; reg=00 val=69 */ | 513 | /* check R820T ID register; reg=00 val=69 */ |
@@ -529,7 +515,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
529 | if (ret == 0 && buf[0] == 0x69) { | 515 | if (ret == 0 && buf[0] == 0x69) { |
530 | priv->tuner = TUNER_RTL2832_R820T; | 516 | priv->tuner = TUNER_RTL2832_R820T; |
531 | priv->tuner_name = "R820T"; | 517 | priv->tuner_name = "R820T"; |
532 | goto found; | 518 | goto tuner_found; |
533 | } | 519 | } |
534 | 520 | ||
535 | /* check R828D ID register; reg=00 val=69 */ | 521 | /* check R828D ID register; reg=00 val=69 */ |
@@ -537,13 +523,44 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) | |||
537 | if (ret == 0 && buf[0] == 0x69) { | 523 | if (ret == 0 && buf[0] == 0x69) { |
538 | priv->tuner = TUNER_RTL2832_R828D; | 524 | priv->tuner = TUNER_RTL2832_R828D; |
539 | priv->tuner_name = "R828D"; | 525 | priv->tuner_name = "R828D"; |
540 | goto found; | 526 | goto tuner_found; |
541 | } | 527 | } |
542 | 528 | ||
543 | 529 | tuner_found: | |
544 | found: | ||
545 | dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name); | 530 | dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name); |
546 | 531 | ||
532 | /* probe slave demod */ | ||
533 | if (priv->tuner == TUNER_RTL2832_R828D) { | ||
534 | /* power on MN88472 demod on GPIO0 */ | ||
535 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x01, 0x01); | ||
536 | if (ret) | ||
537 | goto err; | ||
538 | |||
539 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_DIR, 0x00, 0x01); | ||
540 | if (ret) | ||
541 | goto err; | ||
542 | |||
543 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_EN, 0x01, 0x01); | ||
544 | if (ret) | ||
545 | goto err; | ||
546 | |||
547 | /* check MN88472 answers */ | ||
548 | ret = rtl28xxu_ctrl_msg(d, &req_mn88472); | ||
549 | if (ret == 0 && buf[0] == 0x02) { | ||
550 | dev_dbg(&d->udev->dev, "%s: MN88472 found\n", __func__); | ||
551 | priv->slave_demod = SLAVE_DEMOD_MN88472; | ||
552 | goto demod_found; | ||
553 | } | ||
554 | |||
555 | ret = rtl28xxu_ctrl_msg(d, &req_mn88473); | ||
556 | if (ret == 0 && buf[0] == 0x03) { | ||
557 | dev_dbg(&d->udev->dev, "%s: MN88473 found\n", __func__); | ||
558 | priv->slave_demod = SLAVE_DEMOD_MN88473; | ||
559 | goto demod_found; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | demod_found: | ||
547 | /* close demod I2C gate */ | 564 | /* close demod I2C gate */ |
548 | ret = rtl28xxu_ctrl_msg(d, &req_gate_close); | 565 | ret = rtl28xxu_ctrl_msg(d, &req_gate_close); |
549 | if (ret < 0) | 566 | if (ret < 0) |
@@ -818,7 +835,66 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | |||
818 | /* set fe callback */ | 835 | /* set fe callback */ |
819 | adap->fe[0]->callback = rtl2832u_frontend_callback; | 836 | adap->fe[0]->callback = rtl2832u_frontend_callback; |
820 | 837 | ||
838 | if (priv->slave_demod) { | ||
839 | struct i2c_board_info info = {}; | ||
840 | struct i2c_client *client; | ||
841 | |||
842 | /* | ||
843 | * We continue on reduced mode, without DVB-T2/C, using master | ||
844 | * demod, when slave demod fails. | ||
845 | */ | ||
846 | ret = 0; | ||
847 | |||
848 | /* attach slave demodulator */ | ||
849 | if (priv->slave_demod == SLAVE_DEMOD_MN88472) { | ||
850 | struct mn88472_config mn88472_config = {}; | ||
851 | |||
852 | mn88472_config.fe = &adap->fe[1]; | ||
853 | mn88472_config.i2c_wr_max = 22, | ||
854 | strlcpy(info.type, "mn88472", I2C_NAME_SIZE); | ||
855 | info.addr = 0x18; | ||
856 | info.platform_data = &mn88472_config; | ||
857 | request_module(info.type); | ||
858 | client = i2c_new_device(priv->demod_i2c_adapter, &info); | ||
859 | if (client == NULL || client->dev.driver == NULL) { | ||
860 | priv->slave_demod = SLAVE_DEMOD_NONE; | ||
861 | goto err_slave_demod_failed; | ||
862 | } | ||
863 | |||
864 | if (!try_module_get(client->dev.driver->owner)) { | ||
865 | i2c_unregister_device(client); | ||
866 | priv->slave_demod = SLAVE_DEMOD_NONE; | ||
867 | goto err_slave_demod_failed; | ||
868 | } | ||
869 | |||
870 | priv->i2c_client_slave_demod = client; | ||
871 | } else { | ||
872 | struct mn88473_config mn88473_config = {}; | ||
873 | |||
874 | mn88473_config.fe = &adap->fe[1]; | ||
875 | mn88473_config.i2c_wr_max = 22, | ||
876 | strlcpy(info.type, "mn88473", I2C_NAME_SIZE); | ||
877 | info.addr = 0x18; | ||
878 | info.platform_data = &mn88473_config; | ||
879 | request_module(info.type); | ||
880 | client = i2c_new_device(priv->demod_i2c_adapter, &info); | ||
881 | if (client == NULL || client->dev.driver == NULL) { | ||
882 | priv->slave_demod = SLAVE_DEMOD_NONE; | ||
883 | goto err_slave_demod_failed; | ||
884 | } | ||
885 | |||
886 | if (!try_module_get(client->dev.driver->owner)) { | ||
887 | i2c_unregister_device(client); | ||
888 | priv->slave_demod = SLAVE_DEMOD_NONE; | ||
889 | goto err_slave_demod_failed; | ||
890 | } | ||
891 | |||
892 | priv->i2c_client_slave_demod = client; | ||
893 | } | ||
894 | } | ||
895 | |||
821 | return 0; | 896 | return 0; |
897 | err_slave_demod_failed: | ||
822 | err: | 898 | err: |
823 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | 899 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
824 | return ret; | 900 | return ret; |
@@ -984,7 +1060,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
984 | break; | 1060 | break; |
985 | } | 1061 | } |
986 | 1062 | ||
987 | priv->client = client; | 1063 | priv->i2c_client_tuner = client; |
988 | sd = i2c_get_clientdata(client); | 1064 | sd = i2c_get_clientdata(client); |
989 | i2c_set_adapdata(i2c_adap_internal, d); | 1065 | i2c_set_adapdata(i2c_adap_internal, d); |
990 | 1066 | ||
@@ -1024,32 +1100,30 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1024 | &rtl28xxu_rtl2832_r820t_config, NULL); | 1100 | &rtl28xxu_rtl2832_r820t_config, NULL); |
1025 | break; | 1101 | break; |
1026 | case TUNER_RTL2832_R828D: | 1102 | case TUNER_RTL2832_R828D: |
1027 | /* power off mn88472 demod on GPIO0 */ | 1103 | fe = dvb_attach(r820t_attach, adap->fe[0], |
1028 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x00, 0x01); | 1104 | priv->demod_i2c_adapter, |
1029 | if (ret) | ||
1030 | goto err; | ||
1031 | |||
1032 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_DIR, 0x00, 0x01); | ||
1033 | if (ret) | ||
1034 | goto err; | ||
1035 | |||
1036 | ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_EN, 0x01, 0x01); | ||
1037 | if (ret) | ||
1038 | goto err; | ||
1039 | |||
1040 | fe = dvb_attach(r820t_attach, adap->fe[0], &d->i2c_adap, | ||
1041 | &rtl2832u_r828d_config); | 1105 | &rtl2832u_r828d_config); |
1042 | |||
1043 | /* Use tuner to get the signal strength */ | ||
1044 | adap->fe[0]->ops.read_signal_strength = | 1106 | adap->fe[0]->ops.read_signal_strength = |
1045 | adap->fe[0]->ops.tuner_ops.get_rf_strength; | 1107 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
1108 | |||
1109 | if (adap->fe[1]) { | ||
1110 | fe = dvb_attach(r820t_attach, adap->fe[1], | ||
1111 | priv->demod_i2c_adapter, | ||
1112 | &rtl2832u_r828d_config); | ||
1113 | adap->fe[1]->ops.read_signal_strength = | ||
1114 | adap->fe[1]->ops.tuner_ops.get_rf_strength; | ||
1115 | } | ||
1116 | |||
1117 | /* attach SDR */ | ||
1118 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, | ||
1119 | &rtl28xxu_rtl2832_r820t_config, NULL); | ||
1046 | break; | 1120 | break; |
1047 | default: | 1121 | default: |
1048 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, | 1122 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, |
1049 | priv->tuner); | 1123 | priv->tuner); |
1050 | } | 1124 | } |
1051 | 1125 | ||
1052 | if (fe == NULL && priv->client == NULL) { | 1126 | if (fe == NULL && priv->i2c_client_tuner == NULL) { |
1053 | ret = -ENODEV; | 1127 | ret = -ENODEV; |
1054 | goto err; | 1128 | goto err; |
1055 | } | 1129 | } |
@@ -1097,11 +1171,19 @@ err: | |||
1097 | static void rtl28xxu_exit(struct dvb_usb_device *d) | 1171 | static void rtl28xxu_exit(struct dvb_usb_device *d) |
1098 | { | 1172 | { |
1099 | struct rtl28xxu_priv *priv = d->priv; | 1173 | struct rtl28xxu_priv *priv = d->priv; |
1100 | struct i2c_client *client = priv->client; | 1174 | struct i2c_client *client; |
1101 | 1175 | ||
1102 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 1176 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
1103 | 1177 | ||
1104 | /* remove I2C tuner */ | 1178 | /* remove I2C tuner */ |
1179 | client = priv->i2c_client_tuner; | ||
1180 | if (client) { | ||
1181 | module_put(client->dev.driver->owner); | ||
1182 | i2c_unregister_device(client); | ||
1183 | } | ||
1184 | |||
1185 | /* remove I2C slave demod */ | ||
1186 | client = priv->i2c_client_slave_demod; | ||
1105 | if (client) { | 1187 | if (client) { |
1106 | module_put(client->dev.driver->owner); | 1188 | module_put(client->dev.driver->owner); |
1107 | i2c_unregister_device(client); | 1189 | i2c_unregister_device(client); |
@@ -1201,13 +1283,6 @@ static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
1201 | if (ret) | 1283 | if (ret) |
1202 | goto err; | 1284 | goto err; |
1203 | 1285 | ||
1204 | mdelay(5); | ||
1205 | |||
1206 | /* enable ADC */ | ||
1207 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x48, 0x48); | ||
1208 | if (ret) | ||
1209 | goto err; | ||
1210 | |||
1211 | /* streaming EP: clear stall & reset */ | 1286 | /* streaming EP: clear stall & reset */ |
1212 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x00\x00", 2); | 1287 | ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x00\x00", 2); |
1213 | if (ret) | 1288 | if (ret) |
@@ -1222,11 +1297,6 @@ static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
1222 | if (ret) | 1297 | if (ret) |
1223 | goto err; | 1298 | goto err; |
1224 | 1299 | ||
1225 | /* disable ADC */ | ||
1226 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x48); | ||
1227 | if (ret) | ||
1228 | goto err; | ||
1229 | |||
1230 | /* disable PLL */ | 1300 | /* disable PLL */ |
1231 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x80); | 1301 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x80); |
1232 | if (ret) | 1302 | if (ret) |
@@ -1244,6 +1314,38 @@ err: | |||
1244 | return ret; | 1314 | return ret; |
1245 | } | 1315 | } |
1246 | 1316 | ||
1317 | static int rtl2832u_frontend_ctrl(struct dvb_frontend *fe, int onoff) | ||
1318 | { | ||
1319 | struct dvb_usb_device *d = fe_to_d(fe); | ||
1320 | struct dvb_usb_adapter *adap = fe_to_adap(fe); | ||
1321 | int ret; | ||
1322 | u8 val; | ||
1323 | |||
1324 | dev_dbg(&d->udev->dev, "%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); | ||
1325 | |||
1326 | /* control internal demod ADC */ | ||
1327 | if (fe->id == 0 && onoff) | ||
1328 | val = 0x48; /* enable ADC */ | ||
1329 | else | ||
1330 | val = 0x00; /* disable ADC */ | ||
1331 | |||
1332 | ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, val, 0x48); | ||
1333 | if (ret) | ||
1334 | goto err; | ||
1335 | |||
1336 | /* bypass slave demod TS through master demod */ | ||
1337 | if (fe->id == 1 && onoff) { | ||
1338 | ret = rtl2832_enable_external_ts_if(adap->fe[0]); | ||
1339 | if (ret) | ||
1340 | goto err; | ||
1341 | } | ||
1342 | |||
1343 | return 0; | ||
1344 | err: | ||
1345 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | ||
1346 | return ret; | ||
1347 | } | ||
1348 | |||
1247 | #if IS_ENABLED(CONFIG_RC_CORE) | 1349 | #if IS_ENABLED(CONFIG_RC_CORE) |
1248 | static int rtl2831u_rc_query(struct dvb_usb_device *d) | 1350 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
1249 | { | 1351 | { |
@@ -1467,6 +1569,7 @@ static const struct dvb_usb_device_properties rtl2832u_props = { | |||
1467 | .size_of_priv = sizeof(struct rtl28xxu_priv), | 1569 | .size_of_priv = sizeof(struct rtl28xxu_priv), |
1468 | 1570 | ||
1469 | .power_ctrl = rtl2832u_power_ctrl, | 1571 | .power_ctrl = rtl2832u_power_ctrl, |
1572 | .frontend_ctrl = rtl2832u_frontend_ctrl, | ||
1470 | .i2c_algo = &rtl28xxu_i2c_algo, | 1573 | .i2c_algo = &rtl28xxu_i2c_algo, |
1471 | .read_config = rtl2832u_read_config, | 1574 | .read_config = rtl2832u_read_config, |
1472 | .frontend_attach = rtl2832u_frontend_attach, | 1575 | .frontend_attach = rtl2832u_frontend_attach, |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index a26cab10f382..3e3ea9d64a38 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h | |||
@@ -57,7 +57,12 @@ struct rtl28xxu_priv { | |||
57 | u8 page; /* integrated demod active register page */ | 57 | u8 page; /* integrated demod active register page */ |
58 | struct i2c_adapter *demod_i2c_adapter; | 58 | struct i2c_adapter *demod_i2c_adapter; |
59 | bool rc_active; | 59 | bool rc_active; |
60 | struct i2c_client *client; | 60 | struct i2c_client *i2c_client_tuner; |
61 | struct i2c_client *i2c_client_slave_demod; | ||
62 | #define SLAVE_DEMOD_NONE 0 | ||
63 | #define SLAVE_DEMOD_MN88472 1 | ||
64 | #define SLAVE_DEMOD_MN88473 2 | ||
65 | unsigned int slave_demod:2; | ||
61 | }; | 66 | }; |
62 | 67 | ||
63 | enum rtl28xxu_chip_id { | 68 | enum rtl28xxu_chip_id { |
diff --git a/drivers/media/usb/dvb-usb/Kconfig b/drivers/media/usb/dvb-usb/Kconfig index 41d3eb922a00..3364200db093 100644 --- a/drivers/media/usb/dvb-usb/Kconfig +++ b/drivers/media/usb/dvb-usb/Kconfig | |||
@@ -130,7 +130,6 @@ config DVB_USB_CXUSB | |||
130 | 130 | ||
131 | Medion MD95700 hybrid USB2.0 device. | 131 | Medion MD95700 hybrid USB2.0 device. |
132 | DViCO FusionHDTV (Bluebird) USB2.0 devices | 132 | DViCO FusionHDTV (Bluebird) USB2.0 devices |
133 | TechnoTrend TVStick CT2-4400 and CT2-4650 CI devices | ||
134 | 133 | ||
135 | config DVB_USB_M920X | 134 | config DVB_USB_M920X |
136 | tristate "Uli m920x DVB-T USB2.0 support" | 135 | tristate "Uli m920x DVB-T USB2.0 support" |
diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c index 3f4361e48a32..efa782ed6e2d 100644 --- a/drivers/media/usb/dvb-usb/af9005.c +++ b/drivers/media/usb/dvb-usb/af9005.c | |||
@@ -1081,9 +1081,12 @@ static int __init af9005_usb_module_init(void) | |||
1081 | err("usb_register failed. (%d)", result); | 1081 | err("usb_register failed. (%d)", result); |
1082 | return result; | 1082 | return result; |
1083 | } | 1083 | } |
1084 | #if IS_MODULE(CONFIG_DVB_USB_AF9005) || defined(CONFIG_DVB_USB_AF9005_REMOTE) | ||
1085 | /* FIXME: convert to todays kernel IR infrastructure */ | ||
1084 | rc_decode = symbol_request(af9005_rc_decode); | 1086 | rc_decode = symbol_request(af9005_rc_decode); |
1085 | rc_keys = symbol_request(rc_map_af9005_table); | 1087 | rc_keys = symbol_request(rc_map_af9005_table); |
1086 | rc_keys_size = symbol_request(rc_map_af9005_table_size); | 1088 | rc_keys_size = symbol_request(rc_map_af9005_table_size); |
1089 | #endif | ||
1087 | if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) { | 1090 | if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) { |
1088 | err("af9005_rc_decode function not found, disabling remote"); | 1091 | err("af9005_rc_decode function not found, disabling remote"); |
1089 | af9005_properties.rc.legacy.rc_query = NULL; | 1092 | af9005_properties.rc.legacy.rc_query = NULL; |
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c index 356abb369c20..0f345b1f9014 100644 --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include "atbm8830.h" | 44 | #include "atbm8830.h" |
45 | #include "si2168.h" | 45 | #include "si2168.h" |
46 | #include "si2157.h" | 46 | #include "si2157.h" |
47 | #include "sp2.h" | ||
48 | 47 | ||
49 | /* Max transfer size done by I2C transfer functions */ | 48 | /* Max transfer size done by I2C transfer functions */ |
50 | #define MAX_XFER_SIZE 80 | 49 | #define MAX_XFER_SIZE 80 |
@@ -147,22 +146,6 @@ static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d, | |||
147 | } | 146 | } |
148 | } | 147 | } |
149 | 148 | ||
150 | static int cxusb_tt_ct2_4400_gpio_tuner(struct dvb_usb_device *d, int onoff) | ||
151 | { | ||
152 | u8 o[2], i; | ||
153 | int rc; | ||
154 | |||
155 | o[0] = 0x83; | ||
156 | o[1] = onoff; | ||
157 | rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1); | ||
158 | |||
159 | if (rc) { | ||
160 | deb_info("gpio_write failed.\n"); | ||
161 | return -EIO; | ||
162 | } | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | /* I2C */ | 149 | /* I2C */ |
167 | static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | 150 | static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
168 | int num) | 151 | int num) |
@@ -524,30 +507,6 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event, | |||
524 | return 0; | 507 | return 0; |
525 | } | 508 | } |
526 | 509 | ||
527 | static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d) | ||
528 | { | ||
529 | u8 i[2]; | ||
530 | int ret; | ||
531 | u32 cmd, keycode; | ||
532 | u8 rc5_cmd, rc5_addr, rc5_toggle; | ||
533 | |||
534 | ret = cxusb_ctrl_msg(d, 0x10, NULL, 0, i, 2); | ||
535 | if (ret) | ||
536 | return ret; | ||
537 | |||
538 | cmd = (i[0] << 8) | i[1]; | ||
539 | |||
540 | if (cmd != 0xffff) { | ||
541 | rc5_cmd = cmd & 0x3F; /* bits 1-6 for command */ | ||
542 | rc5_addr = (cmd & 0x07C0) >> 6; /* bits 7-11 for address */ | ||
543 | rc5_toggle = (cmd & 0x0800) >> 11; /* bit 12 for toggle */ | ||
544 | keycode = (rc5_addr << 8) | rc5_cmd; | ||
545 | rc_keydown(d->rc_dev, RC_BIT_RC5, keycode, rc5_toggle); | ||
546 | } | ||
547 | |||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | static struct rc_map_table rc_map_dvico_mce_table[] = { | 510 | static struct rc_map_table rc_map_dvico_mce_table[] = { |
552 | { 0xfe02, KEY_TV }, | 511 | { 0xfe02, KEY_TV }, |
553 | { 0xfe0e, KEY_MP3 }, | 512 | { 0xfe0e, KEY_MP3 }, |
@@ -673,70 +632,6 @@ static struct rc_map_table rc_map_d680_dmb_table[] = { | |||
673 | { 0x0025, KEY_POWER }, | 632 | { 0x0025, KEY_POWER }, |
674 | }; | 633 | }; |
675 | 634 | ||
676 | static int cxusb_tt_ct2_4400_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) | ||
677 | { | ||
678 | u8 wbuf[2]; | ||
679 | u8 rbuf[6]; | ||
680 | int ret; | ||
681 | struct i2c_msg msg[] = { | ||
682 | { | ||
683 | .addr = 0x51, | ||
684 | .flags = 0, | ||
685 | .buf = wbuf, | ||
686 | .len = 2, | ||
687 | }, { | ||
688 | .addr = 0x51, | ||
689 | .flags = I2C_M_RD, | ||
690 | .buf = rbuf, | ||
691 | .len = 6, | ||
692 | } | ||
693 | }; | ||
694 | |||
695 | wbuf[0] = 0x1e; | ||
696 | wbuf[1] = 0x00; | ||
697 | ret = cxusb_i2c_xfer(&d->i2c_adap, msg, 2); | ||
698 | |||
699 | if (ret == 2) { | ||
700 | memcpy(mac, rbuf, 6); | ||
701 | return 0; | ||
702 | } else { | ||
703 | if (ret < 0) | ||
704 | return ret; | ||
705 | return -EIO; | ||
706 | } | ||
707 | } | ||
708 | |||
709 | static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr, | ||
710 | u8 data, int *mem) | ||
711 | { | ||
712 | struct dvb_usb_device *d = priv; | ||
713 | u8 wbuf[3]; | ||
714 | u8 rbuf[2]; | ||
715 | int ret; | ||
716 | |||
717 | wbuf[0] = (addr >> 8) & 0xff; | ||
718 | wbuf[1] = addr & 0xff; | ||
719 | |||
720 | if (read) { | ||
721 | ret = cxusb_ctrl_msg(d, CMD_SP2_CI_READ, wbuf, 2, rbuf, 2); | ||
722 | } else { | ||
723 | wbuf[2] = data; | ||
724 | ret = cxusb_ctrl_msg(d, CMD_SP2_CI_WRITE, wbuf, 3, rbuf, 1); | ||
725 | } | ||
726 | |||
727 | if (ret) | ||
728 | goto err; | ||
729 | |||
730 | if (read) | ||
731 | *mem = rbuf[1]; | ||
732 | |||
733 | return 0; | ||
734 | err: | ||
735 | deb_info("%s: ci usb write returned %d\n", __func__, ret); | ||
736 | return ret; | ||
737 | |||
738 | } | ||
739 | |||
740 | static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) | 635 | static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) |
741 | { | 636 | { |
742 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; | 637 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; |
@@ -1408,36 +1303,34 @@ static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap) | |||
1408 | return 0; | 1303 | return 0; |
1409 | } | 1304 | } |
1410 | 1305 | ||
1411 | static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap) | 1306 | static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap) |
1412 | { | 1307 | { |
1413 | struct dvb_usb_device *d = adap->dev; | 1308 | struct dvb_usb_device *d = adap->dev; |
1414 | struct cxusb_state *st = d->priv; | 1309 | struct cxusb_state *st = d->priv; |
1415 | struct i2c_adapter *adapter; | 1310 | struct i2c_adapter *adapter; |
1416 | struct i2c_client *client_demod; | 1311 | struct i2c_client *client_demod; |
1417 | struct i2c_client *client_tuner; | 1312 | struct i2c_client *client_tuner; |
1418 | struct i2c_client *client_ci; | ||
1419 | struct i2c_board_info info; | 1313 | struct i2c_board_info info; |
1420 | struct si2168_config si2168_config; | 1314 | struct si2168_config si2168_config; |
1421 | struct si2157_config si2157_config; | 1315 | struct si2157_config si2157_config; |
1422 | struct sp2_config sp2_config; | ||
1423 | u8 o[2], i; | ||
1424 | 1316 | ||
1425 | /* reset the tuner */ | 1317 | /* Select required USB configuration */ |
1426 | if (cxusb_tt_ct2_4400_gpio_tuner(d, 0) < 0) { | 1318 | if (usb_set_interface(d->udev, 0, 0) < 0) |
1427 | err("clear tuner gpio failed"); | 1319 | err("set interface failed"); |
1428 | return -EIO; | 1320 | |
1429 | } | 1321 | /* Unblock all USB pipes */ |
1430 | msleep(100); | 1322 | usb_clear_halt(d->udev, |
1431 | if (cxusb_tt_ct2_4400_gpio_tuner(d, 1) < 0) { | 1323 | usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); |
1432 | err("set tuner gpio failed"); | 1324 | usb_clear_halt(d->udev, |
1433 | return -EIO; | 1325 | usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); |
1434 | } | 1326 | usb_clear_halt(d->udev, |
1435 | msleep(100); | 1327 | usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); |
1436 | 1328 | ||
1437 | /* attach frontend */ | 1329 | /* attach frontend */ |
1438 | si2168_config.i2c_adapter = &adapter; | 1330 | si2168_config.i2c_adapter = &adapter; |
1439 | si2168_config.fe = &adap->fe_adap[0].fe; | 1331 | si2168_config.fe = &adap->fe_adap[0].fe; |
1440 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | 1332 | si2168_config.ts_mode = SI2168_TS_PARALLEL; |
1333 | si2168_config.ts_clock_inv = 1; | ||
1441 | memset(&info, 0, sizeof(struct i2c_board_info)); | 1334 | memset(&info, 0, sizeof(struct i2c_board_info)); |
1442 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); | 1335 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); |
1443 | info.addr = 0x64; | 1336 | info.addr = 0x64; |
@@ -1477,48 +1370,6 @@ static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap) | |||
1477 | 1370 | ||
1478 | st->i2c_client_tuner = client_tuner; | 1371 | st->i2c_client_tuner = client_tuner; |
1479 | 1372 | ||
1480 | /* initialize CI */ | ||
1481 | if (d->udev->descriptor.idProduct == | ||
1482 | USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) { | ||
1483 | |||
1484 | memcpy(o, "\xc0\x01", 2); | ||
1485 | cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1); | ||
1486 | msleep(100); | ||
1487 | |||
1488 | memcpy(o, "\xc0\x00", 2); | ||
1489 | cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1); | ||
1490 | msleep(100); | ||
1491 | |||
1492 | memset(&sp2_config, 0, sizeof(sp2_config)); | ||
1493 | sp2_config.dvb_adap = &adap->dvb_adap; | ||
1494 | sp2_config.priv = d; | ||
1495 | sp2_config.ci_control = cxusb_tt_ct2_4650_ci_ctrl; | ||
1496 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1497 | strlcpy(info.type, "sp2", I2C_NAME_SIZE); | ||
1498 | info.addr = 0x40; | ||
1499 | info.platform_data = &sp2_config; | ||
1500 | request_module(info.type); | ||
1501 | client_ci = i2c_new_device(&d->i2c_adap, &info); | ||
1502 | if (client_ci == NULL || client_ci->dev.driver == NULL) { | ||
1503 | module_put(client_tuner->dev.driver->owner); | ||
1504 | i2c_unregister_device(client_tuner); | ||
1505 | module_put(client_demod->dev.driver->owner); | ||
1506 | i2c_unregister_device(client_demod); | ||
1507 | return -ENODEV; | ||
1508 | } | ||
1509 | if (!try_module_get(client_ci->dev.driver->owner)) { | ||
1510 | i2c_unregister_device(client_ci); | ||
1511 | module_put(client_tuner->dev.driver->owner); | ||
1512 | i2c_unregister_device(client_tuner); | ||
1513 | module_put(client_demod->dev.driver->owner); | ||
1514 | i2c_unregister_device(client_demod); | ||
1515 | return -ENODEV; | ||
1516 | } | ||
1517 | |||
1518 | st->i2c_client_ci = client_ci; | ||
1519 | |||
1520 | } | ||
1521 | |||
1522 | return 0; | 1373 | return 0; |
1523 | } | 1374 | } |
1524 | 1375 | ||
@@ -1603,7 +1454,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_prope | |||
1603 | static struct dvb_usb_device_properties cxusb_aver_a868r_properties; | 1454 | static struct dvb_usb_device_properties cxusb_aver_a868r_properties; |
1604 | static struct dvb_usb_device_properties cxusb_d680_dmb_properties; | 1455 | static struct dvb_usb_device_properties cxusb_d680_dmb_properties; |
1605 | static struct dvb_usb_device_properties cxusb_mygica_d689_properties; | 1456 | static struct dvb_usb_device_properties cxusb_mygica_d689_properties; |
1606 | static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties; | 1457 | static struct dvb_usb_device_properties cxusb_mygica_t230_properties; |
1607 | 1458 | ||
1608 | static int cxusb_probe(struct usb_interface *intf, | 1459 | static int cxusb_probe(struct usb_interface *intf, |
1609 | const struct usb_device_id *id) | 1460 | const struct usb_device_id *id) |
@@ -1634,7 +1485,7 @@ static int cxusb_probe(struct usb_interface *intf, | |||
1634 | THIS_MODULE, NULL, adapter_nr) || | 1485 | THIS_MODULE, NULL, adapter_nr) || |
1635 | 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties, | 1486 | 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties, |
1636 | THIS_MODULE, NULL, adapter_nr) || | 1487 | THIS_MODULE, NULL, adapter_nr) || |
1637 | 0 == dvb_usb_device_init(intf, &cxusb_tt_ct2_4400_properties, | 1488 | 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties, |
1638 | THIS_MODULE, NULL, adapter_nr) || | 1489 | THIS_MODULE, NULL, adapter_nr) || |
1639 | 0) | 1490 | 0) |
1640 | return 0; | 1491 | return 0; |
@@ -1648,13 +1499,6 @@ static void cxusb_disconnect(struct usb_interface *intf) | |||
1648 | struct cxusb_state *st = d->priv; | 1499 | struct cxusb_state *st = d->priv; |
1649 | struct i2c_client *client; | 1500 | struct i2c_client *client; |
1650 | 1501 | ||
1651 | /* remove I2C client for CI */ | ||
1652 | client = st->i2c_client_ci; | ||
1653 | if (client) { | ||
1654 | module_put(client->dev.driver->owner); | ||
1655 | i2c_unregister_device(client); | ||
1656 | } | ||
1657 | |||
1658 | /* remove I2C client for tuner */ | 1502 | /* remove I2C client for tuner */ |
1659 | client = st->i2c_client_tuner; | 1503 | client = st->i2c_client_tuner; |
1660 | if (client) { | 1504 | if (client) { |
@@ -1693,8 +1537,7 @@ static struct usb_device_id cxusb_table [] = { | |||
1693 | { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) }, | 1537 | { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) }, |
1694 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) }, | 1538 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) }, |
1695 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) }, | 1539 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) }, |
1696 | { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_TVSTICK_CT2_4400) }, | 1540 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230) }, |
1697 | { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) }, | ||
1698 | {} /* Terminating entry */ | 1541 | {} /* Terminating entry */ |
1699 | }; | 1542 | }; |
1700 | MODULE_DEVICE_TABLE (usb, cxusb_table); | 1543 | MODULE_DEVICE_TABLE (usb, cxusb_table); |
@@ -2341,7 +2184,7 @@ static struct dvb_usb_device_properties cxusb_mygica_d689_properties = { | |||
2341 | } | 2184 | } |
2342 | }; | 2185 | }; |
2343 | 2186 | ||
2344 | static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties = { | 2187 | static struct dvb_usb_device_properties cxusb_mygica_t230_properties = { |
2345 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 2188 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
2346 | 2189 | ||
2347 | .usb_ctrl = CYPRESS_FX2, | 2190 | .usb_ctrl = CYPRESS_FX2, |
@@ -2349,25 +2192,21 @@ static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties = { | |||
2349 | .size_of_priv = sizeof(struct cxusb_state), | 2192 | .size_of_priv = sizeof(struct cxusb_state), |
2350 | 2193 | ||
2351 | .num_adapters = 1, | 2194 | .num_adapters = 1, |
2352 | .read_mac_address = cxusb_tt_ct2_4400_read_mac_address, | ||
2353 | |||
2354 | .adapter = { | 2195 | .adapter = { |
2355 | { | 2196 | { |
2356 | .num_frontends = 1, | 2197 | .num_frontends = 1, |
2357 | .fe = {{ | 2198 | .fe = {{ |
2358 | .streaming_ctrl = cxusb_streaming_ctrl, | 2199 | .streaming_ctrl = cxusb_streaming_ctrl, |
2359 | /* both frontend and tuner attached in the | 2200 | .frontend_attach = cxusb_mygica_t230_frontend_attach, |
2360 | same function */ | ||
2361 | .frontend_attach = cxusb_tt_ct2_4400_attach, | ||
2362 | 2201 | ||
2363 | /* parameter for the MPEG2-data transfer */ | 2202 | /* parameter for the MPEG2-data transfer */ |
2364 | .stream = { | 2203 | .stream = { |
2365 | .type = USB_BULK, | 2204 | .type = USB_BULK, |
2366 | .count = 8, | 2205 | .count = 5, |
2367 | .endpoint = 0x82, | 2206 | .endpoint = 0x02, |
2368 | .u = { | 2207 | .u = { |
2369 | .bulk = { | 2208 | .bulk = { |
2370 | .buffersize = 4096, | 2209 | .buffersize = 8192, |
2371 | } | 2210 | } |
2372 | } | 2211 | } |
2373 | }, | 2212 | }, |
@@ -2375,28 +2214,25 @@ static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties = { | |||
2375 | }, | 2214 | }, |
2376 | }, | 2215 | }, |
2377 | 2216 | ||
2378 | .i2c_algo = &cxusb_i2c_algo, | 2217 | .power_ctrl = cxusb_d680_dmb_power_ctrl, |
2218 | |||
2219 | .i2c_algo = &cxusb_i2c_algo, | ||
2220 | |||
2379 | .generic_bulk_ctrl_endpoint = 0x01, | 2221 | .generic_bulk_ctrl_endpoint = 0x01, |
2380 | .generic_bulk_ctrl_endpoint_response = 0x81, | ||
2381 | 2222 | ||
2382 | .rc.core = { | 2223 | .rc.legacy = { |
2383 | .rc_codes = RC_MAP_TT_1500, | 2224 | .rc_interval = 100, |
2384 | .allowed_protos = RC_BIT_RC5, | 2225 | .rc_map_table = rc_map_d680_dmb_table, |
2385 | .rc_query = cxusb_tt_ct2_4400_rc_query, | 2226 | .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), |
2386 | .rc_interval = 150, | 2227 | .rc_query = cxusb_d680_dmb_rc_query, |
2387 | }, | 2228 | }, |
2388 | 2229 | ||
2389 | .num_device_descs = 2, | 2230 | .num_device_descs = 1, |
2390 | .devices = { | 2231 | .devices = { |
2391 | { | 2232 | { |
2392 | "TechnoTrend TVStick CT2-4400", | 2233 | "Mygica T230 DVB-T/T2/C", |
2393 | { NULL }, | ||
2394 | { &cxusb_table[20], NULL }, | ||
2395 | }, | ||
2396 | { | ||
2397 | "TechnoTrend TT-connect CT2-4650 CI", | ||
2398 | { NULL }, | 2234 | { NULL }, |
2399 | { &cxusb_table[21], NULL }, | 2235 | { &cxusb_table[22], NULL }, |
2400 | }, | 2236 | }, |
2401 | } | 2237 | } |
2402 | }; | 2238 | }; |
diff --git a/drivers/media/usb/dvb-usb/cxusb.h b/drivers/media/usb/dvb-usb/cxusb.h index 29f3e2ea2476..527ff7905e15 100644 --- a/drivers/media/usb/dvb-usb/cxusb.h +++ b/drivers/media/usb/dvb-usb/cxusb.h | |||
@@ -28,14 +28,10 @@ | |||
28 | #define CMD_ANALOG 0x50 | 28 | #define CMD_ANALOG 0x50 |
29 | #define CMD_DIGITAL 0x51 | 29 | #define CMD_DIGITAL 0x51 |
30 | 30 | ||
31 | #define CMD_SP2_CI_WRITE 0x70 | ||
32 | #define CMD_SP2_CI_READ 0x71 | ||
33 | |||
34 | struct cxusb_state { | 31 | struct cxusb_state { |
35 | u8 gpio_write_state[3]; | 32 | u8 gpio_write_state[3]; |
36 | struct i2c_client *i2c_client_demod; | 33 | struct i2c_client *i2c_client_demod; |
37 | struct i2c_client *i2c_client_tuner; | 34 | struct i2c_client *i2c_client_tuner; |
38 | struct i2c_client *i2c_client_ci; | ||
39 | }; | 35 | }; |
40 | 36 | ||
41 | #endif | 37 | #endif |
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c index 6b0b8b6b9e2a..5801ae7f672a 100644 --- a/drivers/media/usb/dvb-usb/technisat-usb2.c +++ b/drivers/media/usb/dvb-usb/technisat-usb2.c | |||
@@ -449,6 +449,8 @@ static int technisat_usb2_read_mac_address(struct dvb_usb_device *d, | |||
449 | return 0; | 449 | return 0; |
450 | } | 450 | } |
451 | 451 | ||
452 | static struct stv090x_config technisat_usb2_stv090x_config; | ||
453 | |||
452 | /* frontend attach */ | 454 | /* frontend attach */ |
453 | static int technisat_usb2_set_voltage(struct dvb_frontend *fe, | 455 | static int technisat_usb2_set_voltage(struct dvb_frontend *fe, |
454 | fe_sec_voltage_t voltage) | 456 | fe_sec_voltage_t voltage) |
@@ -472,7 +474,8 @@ static int technisat_usb2_set_voltage(struct dvb_frontend *fe, | |||
472 | } | 474 | } |
473 | 475 | ||
474 | for (i = 0; i < 3; i++) | 476 | for (i = 0; i < 3; i++) |
475 | if (stv090x_set_gpio(fe, i+2, 0, gpio[i], 0) != 0) | 477 | if (technisat_usb2_stv090x_config.set_gpio(fe, i+2, 0, |
478 | gpio[i], 0) != 0) | ||
476 | return -EREMOTEIO; | 479 | return -EREMOTEIO; |
477 | return 0; | 480 | return 0; |
478 | } | 481 | } |
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c index 957c7ae30efe..44ae1e0661e6 100644 --- a/drivers/media/usb/em28xx/em28xx-audio.c +++ b/drivers/media/usb/em28xx/em28xx-audio.c | |||
@@ -56,7 +56,7 @@ MODULE_PARM_DESC(debug, "activates debug info"); | |||
56 | #define dprintk(fmt, arg...) do { \ | 56 | #define dprintk(fmt, arg...) do { \ |
57 | if (debug) \ | 57 | if (debug) \ |
58 | printk(KERN_INFO "em28xx-audio %s: " fmt, \ | 58 | printk(KERN_INFO "em28xx-audio %s: " fmt, \ |
59 | __func__, ##arg); \ | 59 | __func__, ##arg); \ |
60 | } while (0) | 60 | } while (0) |
61 | 61 | ||
62 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 62 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
@@ -232,7 +232,6 @@ static struct snd_pcm_hardware snd_em28xx_hw_capture = { | |||
232 | .channels_max = 2, | 232 | .channels_max = 2, |
233 | .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */ | 233 | .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */ |
234 | 234 | ||
235 | |||
236 | /* | 235 | /* |
237 | * The period is 12.288 bytes. Allow a 10% of variation along its | 236 | * The period is 12.288 bytes. Allow a 10% of variation along its |
238 | * value, in order to avoid overruns/underruns due to some clock | 237 | * value, in order to avoid overruns/underruns due to some clock |
@@ -361,7 +360,7 @@ static int snd_em28xx_hw_capture_params(struct snd_pcm_substream *substream, | |||
361 | dprintk("Setting capture parameters\n"); | 360 | dprintk("Setting capture parameters\n"); |
362 | 361 | ||
363 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | 362 | ret = snd_pcm_alloc_vmalloc_buffer(substream, |
364 | params_buffer_bytes(hw_params)); | 363 | params_buffer_bytes(hw_params)); |
365 | if (ret < 0) | 364 | if (ret < 0) |
366 | return ret; | 365 | return ret; |
367 | #if 0 | 366 | #if 0 |
@@ -478,7 +477,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | |||
478 | * AC97 volume control support | 477 | * AC97 volume control support |
479 | */ | 478 | */ |
480 | static int em28xx_vol_info(struct snd_kcontrol *kcontrol, | 479 | static int em28xx_vol_info(struct snd_kcontrol *kcontrol, |
481 | struct snd_ctl_elem_info *info) | 480 | struct snd_ctl_elem_info *info) |
482 | { | 481 | { |
483 | struct em28xx *dev = snd_kcontrol_chip(kcontrol); | 482 | struct em28xx *dev = snd_kcontrol_chip(kcontrol); |
484 | 483 | ||
@@ -494,7 +493,7 @@ static int em28xx_vol_info(struct snd_kcontrol *kcontrol, | |||
494 | } | 493 | } |
495 | 494 | ||
496 | static int em28xx_vol_put(struct snd_kcontrol *kcontrol, | 495 | static int em28xx_vol_put(struct snd_kcontrol *kcontrol, |
497 | struct snd_ctl_elem_value *value) | 496 | struct snd_ctl_elem_value *value) |
498 | { | 497 | { |
499 | struct em28xx *dev = snd_kcontrol_chip(kcontrol); | 498 | struct em28xx *dev = snd_kcontrol_chip(kcontrol); |
500 | struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream; | 499 | struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream; |
@@ -534,7 +533,7 @@ err: | |||
534 | } | 533 | } |
535 | 534 | ||
536 | static int em28xx_vol_get(struct snd_kcontrol *kcontrol, | 535 | static int em28xx_vol_get(struct snd_kcontrol *kcontrol, |
537 | struct snd_ctl_elem_value *value) | 536 | struct snd_ctl_elem_value *value) |
538 | { | 537 | { |
539 | struct em28xx *dev = snd_kcontrol_chip(kcontrol); | 538 | struct em28xx *dev = snd_kcontrol_chip(kcontrol); |
540 | struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream; | 539 | struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream; |
@@ -655,7 +654,7 @@ static int em28xx_cvol_new(struct snd_card *card, struct em28xx *dev, | |||
655 | struct snd_kcontrol *kctl; | 654 | struct snd_kcontrol *kctl; |
656 | struct snd_kcontrol_new tmp; | 655 | struct snd_kcontrol_new tmp; |
657 | 656 | ||
658 | memset (&tmp, 0, sizeof(tmp)); | 657 | memset(&tmp, 0, sizeof(tmp)); |
659 | tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 658 | tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
660 | tmp.private_value = id, | 659 | tmp.private_value = id, |
661 | tmp.name = ctl_name, | 660 | tmp.name = ctl_name, |
@@ -672,7 +671,7 @@ static int em28xx_cvol_new(struct snd_card *card, struct em28xx *dev, | |||
672 | dprintk("Added control %s for ac97 volume control 0x%04x\n", | 671 | dprintk("Added control %s for ac97 volume control 0x%04x\n", |
673 | ctl_name, id); | 672 | ctl_name, id); |
674 | 673 | ||
675 | memset (&tmp, 0, sizeof(tmp)); | 674 | memset(&tmp, 0, sizeof(tmp)); |
676 | tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 675 | tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
677 | tmp.private_value = id, | 676 | tmp.private_value = id, |
678 | tmp.name = ctl_name, | 677 | tmp.name = ctl_name, |
@@ -731,7 +730,7 @@ static void em28xx_audio_free_urb(struct em28xx *dev) | |||
731 | 730 | ||
732 | /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ | 731 | /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ |
733 | static int em28xx_audio_ep_packet_size(struct usb_device *udev, | 732 | static int em28xx_audio_ep_packet_size(struct usb_device *udev, |
734 | struct usb_endpoint_descriptor *e) | 733 | struct usb_endpoint_descriptor *e) |
735 | { | 734 | { |
736 | int size = le16_to_cpu(e->wMaxPacketSize); | 735 | int size = le16_to_cpu(e->wMaxPacketSize); |
737 | 736 | ||
@@ -781,7 +780,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev) | |||
781 | interval = 1 << (ep->bInterval - 1); | 780 | interval = 1 << (ep->bInterval - 1); |
782 | 781 | ||
783 | em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", | 782 | em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", |
784 | EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed), | 783 | EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed), |
785 | dev->ifnum, alt, | 784 | dev->ifnum, alt, |
786 | interval, | 785 | interval, |
787 | ep_size); | 786 | ep_size); |
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c index 6d2ea9afd57b..7be661f73930 100644 --- a/drivers/media/usb/em28xx/em28xx-camera.c +++ b/drivers/media/usb/em28xx/em28xx-camera.c | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | #include "em28xx.h" | 28 | #include "em28xx.h" |
29 | 29 | ||
30 | |||
31 | /* Possible i2c addresses of Micron sensors */ | 30 | /* Possible i2c addresses of Micron sensors */ |
32 | static unsigned short micron_sensor_addrs[] = { | 31 | static unsigned short micron_sensor_addrs[] = { |
33 | 0xb8 >> 1, /* MT9V111, MT9V403 */ | 32 | 0xb8 >> 1, /* MT9V111, MT9V403 */ |
@@ -43,7 +42,6 @@ static unsigned short omnivision_sensor_addrs[] = { | |||
43 | I2C_CLIENT_END | 42 | I2C_CLIENT_END |
44 | }; | 43 | }; |
45 | 44 | ||
46 | |||
47 | static struct soc_camera_link camlink = { | 45 | static struct soc_camera_link camlink = { |
48 | .bus_id = 0, | 46 | .bus_id = 0, |
49 | .flags = 0, | 47 | .flags = 0, |
@@ -51,7 +49,6 @@ static struct soc_camera_link camlink = { | |||
51 | .unbalanced_power = true, | 49 | .unbalanced_power = true, |
52 | }; | 50 | }; |
53 | 51 | ||
54 | |||
55 | /* FIXME: Should be replaced by a proper mt9m111 driver */ | 52 | /* FIXME: Should be replaced by a proper mt9m111 driver */ |
56 | static int em28xx_initialize_mt9m111(struct em28xx *dev) | 53 | static int em28xx_initialize_mt9m111(struct em28xx *dev) |
57 | { | 54 | { |
@@ -70,7 +67,6 @@ static int em28xx_initialize_mt9m111(struct em28xx *dev) | |||
70 | return 0; | 67 | return 0; |
71 | } | 68 | } |
72 | 69 | ||
73 | |||
74 | /* FIXME: Should be replaced by a proper mt9m001 driver */ | 70 | /* FIXME: Should be replaced by a proper mt9m001 driver */ |
75 | static int em28xx_initialize_mt9m001(struct em28xx *dev) | 71 | static int em28xx_initialize_mt9m001(struct em28xx *dev) |
76 | { | 72 | { |
@@ -98,7 +94,6 @@ static int em28xx_initialize_mt9m001(struct em28xx *dev) | |||
98 | return 0; | 94 | return 0; |
99 | } | 95 | } |
100 | 96 | ||
101 | |||
102 | /* | 97 | /* |
103 | * Probes Micron sensors with 8 bit address and 16 bit register width | 98 | * Probes Micron sensors with 8 bit address and 16 bit register width |
104 | */ | 99 | */ |
@@ -430,7 +425,7 @@ int em28xx_init_camera(struct em28xx *dev) | |||
430 | break; | 425 | break; |
431 | } | 426 | } |
432 | 427 | ||
433 | fmt.code = V4L2_MBUS_FMT_YUYV8_2X8; | 428 | fmt.code = MEDIA_BUS_FMT_YUYV8_2X8; |
434 | fmt.width = 640; | 429 | fmt.width = 640; |
435 | fmt.height = 480; | 430 | fmt.height = 480; |
436 | v4l2_subdev_call(subdev, video, s_mbus_fmt, &fmt); | 431 | v4l2_subdev_call(subdev, video, s_mbus_fmt, &fmt); |
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 71fa51e7984e..d9704e66b8c9 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c | |||
@@ -64,7 +64,6 @@ module_param(usb_xfer_mode, int, 0444); | |||
64 | MODULE_PARM_DESC(usb_xfer_mode, | 64 | MODULE_PARM_DESC(usb_xfer_mode, |
65 | "USB transfer mode for frame data (-1 = auto, 0 = prefer isoc, 1 = prefer bulk)"); | 65 | "USB transfer mode for frame data (-1 = auto, 0 = prefer isoc, 1 = prefer bulk)"); |
66 | 66 | ||
67 | |||
68 | /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */ | 67 | /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */ |
69 | static DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS); | 68 | static DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS); |
70 | 69 | ||
@@ -190,8 +189,8 @@ static struct em28xx_reg_seq kworld_a340_digital[] = { | |||
190 | }; | 189 | }; |
191 | 190 | ||
192 | static struct em28xx_reg_seq kworld_ub435q_v3_digital[] = { | 191 | static struct em28xx_reg_seq kworld_ub435q_v3_digital[] = { |
193 | {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 100}, | 192 | {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 100}, |
194 | {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 100}, | 193 | {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 100}, |
195 | {EM2874_R80_GPIO_P0_CTRL, 0xbe, 0xff, 100}, | 194 | {EM2874_R80_GPIO_P0_CTRL, 0xbe, 0xff, 100}, |
196 | {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 100}, | 195 | {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 100}, |
197 | { -1, -1, -1, -1}, | 196 | { -1, -1, -1, -1}, |
@@ -301,7 +300,6 @@ static struct em28xx_reg_seq dikom_dk300_digital[] = { | |||
301 | { -1, -1, -1, -1}, | 300 | { -1, -1, -1, -1}, |
302 | }; | 301 | }; |
303 | 302 | ||
304 | |||
305 | /* Reset for the most [digital] boards */ | 303 | /* Reset for the most [digital] boards */ |
306 | static struct em28xx_reg_seq leadership_digital[] = { | 304 | static struct em28xx_reg_seq leadership_digital[] = { |
307 | {EM2874_R80_GPIO_P0_CTRL, 0x70, 0xff, 10}, | 305 | {EM2874_R80_GPIO_P0_CTRL, 0x70, 0xff, 10}, |
@@ -479,6 +477,20 @@ static struct em28xx_reg_seq pctv_292e[] = { | |||
479 | {-1, -1, -1, -1}, | 477 | {-1, -1, -1, -1}, |
480 | }; | 478 | }; |
481 | 479 | ||
480 | static struct em28xx_reg_seq terratec_t2_stick_hd[] = { | ||
481 | {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0}, | ||
482 | {0x0d, 0xff, 0xff, 600}, | ||
483 | {EM2874_R80_GPIO_P0_CTRL, 0xfc, 0xff, 10}, | ||
484 | {EM2874_R80_GPIO_P0_CTRL, 0xbc, 0xff, 100}, | ||
485 | {EM2874_R80_GPIO_P0_CTRL, 0xfc, 0xff, 100}, | ||
486 | {EM2874_R80_GPIO_P0_CTRL, 0x00, 0xff, 300}, | ||
487 | {EM2874_R80_GPIO_P0_CTRL, 0xf8, 0xff, 100}, | ||
488 | {EM2874_R80_GPIO_P0_CTRL, 0xfc, 0xff, 300}, | ||
489 | {0x0d, 0x42, 0xff, 1000}, | ||
490 | {EM2874_R5F_TS_ENABLE, 0x85, 0xff, 0}, | ||
491 | {-1, -1, -1, -1}, | ||
492 | }; | ||
493 | |||
482 | /* | 494 | /* |
483 | * Button definitions | 495 | * Button definitions |
484 | */ | 496 | */ |
@@ -548,7 +560,6 @@ static struct em28xx_led pctv_80e_leds[] = { | |||
548 | {-1, 0, 0, 0}, | 560 | {-1, 0, 0, 0}, |
549 | }; | 561 | }; |
550 | 562 | ||
551 | |||
552 | /* | 563 | /* |
553 | * Board definitions | 564 | * Board definitions |
554 | */ | 565 | */ |
@@ -1514,7 +1525,7 @@ struct em28xx_board em28xx_boards[] = { | |||
1514 | .type = EM28XX_VMUX_TELEVISION, | 1525 | .type = EM28XX_VMUX_TELEVISION, |
1515 | .vmux = SAA7115_COMPOSITE2, | 1526 | .vmux = SAA7115_COMPOSITE2, |
1516 | .amux = EM28XX_AMUX_VIDEO, | 1527 | .amux = EM28XX_AMUX_VIDEO, |
1517 | .aout = EM28XX_AOUT_MONO | /* I2S */ | 1528 | .aout = EM28XX_AOUT_MONO | /* I2S */ |
1518 | EM28XX_AOUT_MASTER, /* Line out pin */ | 1529 | EM28XX_AOUT_MASTER, /* Line out pin */ |
1519 | }, { | 1530 | }, { |
1520 | .type = EM28XX_VMUX_COMPOSITE1, | 1531 | .type = EM28XX_VMUX_COMPOSITE1, |
@@ -1536,7 +1547,7 @@ struct em28xx_board em28xx_boards[] = { | |||
1536 | .type = EM28XX_VMUX_TELEVISION, | 1547 | .type = EM28XX_VMUX_TELEVISION, |
1537 | .vmux = SAA7115_COMPOSITE2, | 1548 | .vmux = SAA7115_COMPOSITE2, |
1538 | .amux = EM28XX_AMUX_VIDEO, | 1549 | .amux = EM28XX_AMUX_VIDEO, |
1539 | .aout = EM28XX_AOUT_MONO | /* I2S */ | 1550 | .aout = EM28XX_AOUT_MONO | /* I2S */ |
1540 | EM28XX_AOUT_MASTER, /* Line out pin */ | 1551 | EM28XX_AOUT_MASTER, /* Line out pin */ |
1541 | }, { | 1552 | }, { |
1542 | .type = EM28XX_VMUX_COMPOSITE1, | 1553 | .type = EM28XX_VMUX_COMPOSITE1, |
@@ -2243,6 +2254,31 @@ struct em28xx_board em28xx_boards[] = { | |||
2243 | .has_dvb = 1, | 2254 | .has_dvb = 1, |
2244 | .ir_codes = RC_MAP_PINNACLE_PCTV_HD, | 2255 | .ir_codes = RC_MAP_PINNACLE_PCTV_HD, |
2245 | }, | 2256 | }, |
2257 | [EM2861_BOARD_LEADTEK_VC100] = { | ||
2258 | .name = "Leadtek VC100", | ||
2259 | .tuner_type = TUNER_ABSENT, /* Capture only device */ | ||
2260 | .decoder = EM28XX_TVP5150, | ||
2261 | .input = { { | ||
2262 | .type = EM28XX_VMUX_COMPOSITE1, | ||
2263 | .vmux = TVP5150_COMPOSITE1, | ||
2264 | .amux = EM28XX_AMUX_LINE_IN, | ||
2265 | }, { | ||
2266 | .type = EM28XX_VMUX_SVIDEO, | ||
2267 | .vmux = TVP5150_SVIDEO, | ||
2268 | .amux = EM28XX_AMUX_LINE_IN, | ||
2269 | } }, | ||
2270 | }, | ||
2271 | /* eb1a:8179 Terratec Cinergy T2 Stick HD. | ||
2272 | * Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2146 */ | ||
2273 | [EM28178_BOARD_TERRATEC_T2_STICK_HD] = { | ||
2274 | .name = "Terratec Cinergy T2 Stick HD", | ||
2275 | .def_i2c_bus = 1, | ||
2276 | .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ, | ||
2277 | .tuner_type = TUNER_ABSENT, | ||
2278 | .tuner_gpio = terratec_t2_stick_hd, | ||
2279 | .has_dvb = 1, | ||
2280 | .ir_codes = RC_MAP_TERRATEC_SLIM_2, | ||
2281 | }, | ||
2246 | }; | 2282 | }; |
2247 | EXPORT_SYMBOL_GPL(em28xx_boards); | 2283 | EXPORT_SYMBOL_GPL(em28xx_boards); |
2248 | 2284 | ||
@@ -2424,6 +2460,10 @@ struct usb_device_id em28xx_id_table[] = { | |||
2424 | .driver_info = EM28178_BOARD_PCTV_461E }, | 2460 | .driver_info = EM28178_BOARD_PCTV_461E }, |
2425 | { USB_DEVICE(0x2013, 0x025f), | 2461 | { USB_DEVICE(0x2013, 0x025f), |
2426 | .driver_info = EM28178_BOARD_PCTV_292E }, | 2462 | .driver_info = EM28178_BOARD_PCTV_292E }, |
2463 | { USB_DEVICE(0x0413, 0x6f07), | ||
2464 | .driver_info = EM2861_BOARD_LEADTEK_VC100 }, | ||
2465 | { USB_DEVICE(0xeb1a, 0x8179), | ||
2466 | .driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD }, | ||
2427 | { }, | 2467 | { }, |
2428 | }; | 2468 | }; |
2429 | MODULE_DEVICE_TABLE(usb, em28xx_id_table); | 2469 | MODULE_DEVICE_TABLE(usb, em28xx_id_table); |
@@ -2453,6 +2493,7 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { | |||
2453 | {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF}, | 2493 | {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF}, |
2454 | {0x6b800080, EM2874_BOARD_LEADERSHIP_ISDBT, TUNER_ABSENT}, | 2494 | {0x6b800080, EM2874_BOARD_LEADERSHIP_ISDBT, TUNER_ABSENT}, |
2455 | }; | 2495 | }; |
2496 | |||
2456 | /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */ | 2497 | /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */ |
2457 | 2498 | ||
2458 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) | 2499 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) |
@@ -2695,7 +2736,7 @@ static int em28xx_hint_board(struct em28xx *dev) | |||
2695 | " insmod option:\n"); | 2736 | " insmod option:\n"); |
2696 | for (i = 0; i < em28xx_bcount; i++) { | 2737 | for (i = 0; i < em28xx_bcount; i++) { |
2697 | em28xx_errdev(" card=%d -> %s\n", | 2738 | em28xx_errdev(" card=%d -> %s\n", |
2698 | i, em28xx_boards[i].name); | 2739 | i, em28xx_boards[i].name); |
2699 | } | 2740 | } |
2700 | return -1; | 2741 | return -1; |
2701 | } | 2742 | } |
@@ -3051,6 +3092,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3051 | if (le16_to_cpu(dev->udev->descriptor.idVendor) | 3092 | if (le16_to_cpu(dev->udev->descriptor.idVendor) |
3052 | == 0xeb1a) { | 3093 | == 0xeb1a) { |
3053 | __le16 idProd = dev->udev->descriptor.idProduct; | 3094 | __le16 idProd = dev->udev->descriptor.idProduct; |
3095 | |||
3054 | if (le16_to_cpu(idProd) == 0x2710) | 3096 | if (le16_to_cpu(idProd) == 0x2710) |
3055 | chip_name = "em2710"; | 3097 | chip_name = "em2710"; |
3056 | else if (le16_to_cpu(idProd) == 0x2820) | 3098 | else if (le16_to_cpu(idProd) == 0x2820) |
@@ -3139,7 +3181,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3139 | retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX); | 3181 | retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX); |
3140 | if (retval < 0) { | 3182 | if (retval < 0) { |
3141 | em28xx_errdev("%s: em28xx_i2c_register bus 0 - error [%d]!\n", | 3183 | em28xx_errdev("%s: em28xx_i2c_register bus 0 - error [%d]!\n", |
3142 | __func__, retval); | 3184 | __func__, retval); |
3143 | return retval; | 3185 | return retval; |
3144 | } | 3186 | } |
3145 | 3187 | ||
@@ -3147,13 +3189,13 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3147 | if (dev->def_i2c_bus) { | 3189 | if (dev->def_i2c_bus) { |
3148 | if (dev->is_em25xx) | 3190 | if (dev->is_em25xx) |
3149 | retval = em28xx_i2c_register(dev, 1, | 3191 | retval = em28xx_i2c_register(dev, 1, |
3150 | EM28XX_I2C_ALGO_EM25XX_BUS_B); | 3192 | EM28XX_I2C_ALGO_EM25XX_BUS_B); |
3151 | else | 3193 | else |
3152 | retval = em28xx_i2c_register(dev, 1, | 3194 | retval = em28xx_i2c_register(dev, 1, |
3153 | EM28XX_I2C_ALGO_EM28XX); | 3195 | EM28XX_I2C_ALGO_EM28XX); |
3154 | if (retval < 0) { | 3196 | if (retval < 0) { |
3155 | em28xx_errdev("%s: em28xx_i2c_register bus 1 - error [%d]!\n", | 3197 | em28xx_errdev("%s: em28xx_i2c_register bus 1 - error [%d]!\n", |
3156 | __func__, retval); | 3198 | __func__, retval); |
3157 | 3199 | ||
3158 | em28xx_i2c_unregister(dev, 0); | 3200 | em28xx_i2c_unregister(dev, 0); |
3159 | 3201 | ||
@@ -3193,7 +3235,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3193 | if (nr >= EM28XX_MAXBOARDS) { | 3235 | if (nr >= EM28XX_MAXBOARDS) { |
3194 | /* No free device slots */ | 3236 | /* No free device slots */ |
3195 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", | 3237 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", |
3196 | EM28XX_MAXBOARDS); | 3238 | EM28XX_MAXBOARDS); |
3197 | retval = -ENOMEM; | 3239 | retval = -ENOMEM; |
3198 | goto err_no_slot; | 3240 | goto err_no_slot; |
3199 | } | 3241 | } |
@@ -3377,6 +3419,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3377 | /* Checks if audio is provided by a USB Audio Class interface */ | 3419 | /* Checks if audio is provided by a USB Audio Class interface */ |
3378 | for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { | 3420 | for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { |
3379 | struct usb_interface *uif = udev->config->interface[i]; | 3421 | struct usb_interface *uif = udev->config->interface[i]; |
3422 | |||
3380 | if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { | 3423 | if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { |
3381 | if (has_vendor_audio) | 3424 | if (has_vendor_audio) |
3382 | em28xx_err("em28xx: device seems to have vendor AND usb audio class interfaces !\n" | 3425 | em28xx_err("em28xx: device seems to have vendor AND usb audio class interfaces !\n" |
@@ -3487,7 +3530,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
3487 | } | 3530 | } |
3488 | 3531 | ||
3489 | static int em28xx_usb_suspend(struct usb_interface *interface, | 3532 | static int em28xx_usb_suspend(struct usb_interface *interface, |
3490 | pm_message_t message) | 3533 | pm_message_t message) |
3491 | { | 3534 | { |
3492 | struct em28xx *dev; | 3535 | struct em28xx *dev; |
3493 | 3536 | ||
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index 901cf2b952d7..86461a708abe 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c | |||
@@ -75,7 +75,7 @@ MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]"); | |||
75 | * reads data from the usb device specifying bRequest | 75 | * reads data from the usb device specifying bRequest |
76 | */ | 76 | */ |
77 | int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | 77 | int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, |
78 | char *buf, int len) | 78 | char *buf, int len) |
79 | { | 79 | { |
80 | int ret; | 80 | int ret; |
81 | int pipe = usb_rcvctrlpipe(dev->udev, 0); | 81 | int pipe = usb_rcvctrlpipe(dev->udev, 0); |
@@ -151,7 +151,7 @@ EXPORT_SYMBOL_GPL(em28xx_read_reg); | |||
151 | * sends data to the usb device, specifying bRequest | 151 | * sends data to the usb device, specifying bRequest |
152 | */ | 152 | */ |
153 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | 153 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, |
154 | int len) | 154 | int len) |
155 | { | 155 | { |
156 | int ret; | 156 | int ret; |
157 | int pipe = usb_sndctrlpipe(dev->udev, 0); | 157 | int pipe = usb_sndctrlpipe(dev->udev, 0); |
@@ -213,7 +213,7 @@ EXPORT_SYMBOL_GPL(em28xx_write_reg); | |||
213 | * the actual value | 213 | * the actual value |
214 | */ | 214 | */ |
215 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | 215 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, |
216 | u8 bitmask) | 216 | u8 bitmask) |
217 | { | 217 | { |
218 | int oldval; | 218 | int oldval; |
219 | u8 newval; | 219 | u8 newval; |
@@ -222,7 +222,7 @@ int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | |||
222 | if (oldval < 0) | 222 | if (oldval < 0) |
223 | return oldval; | 223 | return oldval; |
224 | 224 | ||
225 | newval = (((u8) oldval) & ~bitmask) | (val & bitmask); | 225 | newval = (((u8)oldval) & ~bitmask) | (val & bitmask); |
226 | 226 | ||
227 | return em28xx_write_regs(dev, reg, &newval, 1); | 227 | return em28xx_write_regs(dev, reg, &newval, 1); |
228 | } | 228 | } |
@@ -314,7 +314,7 @@ int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val) | |||
314 | if (ret < 0) | 314 | if (ret < 0) |
315 | return ret; | 315 | return ret; |
316 | 316 | ||
317 | ret = em28xx_write_regs(dev, EM28XX_R40_AC97LSB, (u8 *) &value, 2); | 317 | ret = em28xx_write_regs(dev, EM28XX_R40_AC97LSB, (u8 *)&value, 2); |
318 | if (ret < 0) | 318 | if (ret < 0) |
319 | return ret; | 319 | return ret; |
320 | 320 | ||
@@ -361,7 +361,7 @@ static int set_ac97_input(struct em28xx *dev) | |||
361 | 361 | ||
362 | if (ret < 0) | 362 | if (ret < 0) |
363 | em28xx_warn("couldn't setup AC97 register %d\n", | 363 | em28xx_warn("couldn't setup AC97 register %d\n", |
364 | inputs[i].reg); | 364 | inputs[i].reg); |
365 | } | 365 | } |
366 | return 0; | 366 | return 0; |
367 | } | 367 | } |
@@ -445,7 +445,7 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
445 | ret = em28xx_write_ac97(dev, outputs[i].reg, 0x8000); | 445 | ret = em28xx_write_ac97(dev, outputs[i].reg, 0x8000); |
446 | if (ret < 0) | 446 | if (ret < 0) |
447 | em28xx_warn("couldn't setup AC97 register %d\n", | 447 | em28xx_warn("couldn't setup AC97 register %d\n", |
448 | outputs[i].reg); | 448 | outputs[i].reg); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | 451 | ||
@@ -483,7 +483,7 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
483 | vol); | 483 | vol); |
484 | if (ret < 0) | 484 | if (ret < 0) |
485 | em28xx_warn("couldn't setup AC97 register %d\n", | 485 | em28xx_warn("couldn't setup AC97 register %d\n", |
486 | outputs[i].reg); | 486 | outputs[i].reg); |
487 | } | 487 | } |
488 | 488 | ||
489 | if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) { | 489 | if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) { |
@@ -531,7 +531,7 @@ int em28xx_audio_setup(struct em28xx *dev) | |||
531 | } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) != EM28XX_CHIPCFG_AC97) { | 531 | } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) != EM28XX_CHIPCFG_AC97) { |
532 | dev->int_audio_type = EM28XX_INT_AUDIO_I2S; | 532 | dev->int_audio_type = EM28XX_INT_AUDIO_I2S; |
533 | if (dev->chip_id < CHIP_ID_EM2860 && | 533 | if (dev->chip_id < CHIP_ID_EM2860 && |
534 | (cfg & EM28XX_CHIPCFG_AUDIOMASK) == | 534 | (cfg & EM28XX_CHIPCFG_AUDIOMASK) == |
535 | EM2820_CHIPCFG_I2S_1_SAMPRATE) | 535 | EM2820_CHIPCFG_I2S_1_SAMPRATE) |
536 | i2s_samplerates = 1; | 536 | i2s_samplerates = 1; |
537 | else if (dev->chip_id >= CHIP_ID_EM2860 && | 537 | else if (dev->chip_id >= CHIP_ID_EM2860 && |
@@ -541,7 +541,7 @@ int em28xx_audio_setup(struct em28xx *dev) | |||
541 | else | 541 | else |
542 | i2s_samplerates = 3; | 542 | i2s_samplerates = 3; |
543 | em28xx_info("I2S Audio (%d sample rate(s))\n", | 543 | em28xx_info("I2S Audio (%d sample rate(s))\n", |
544 | i2s_samplerates); | 544 | i2s_samplerates); |
545 | /* Skip the code that does AC97 vendor detection */ | 545 | /* Skip the code that does AC97 vendor detection */ |
546 | dev->audio_mode.ac97 = EM28XX_NO_AC97; | 546 | dev->audio_mode.ac97 = EM28XX_NO_AC97; |
547 | goto init_audio; | 547 | goto init_audio; |
@@ -614,8 +614,9 @@ const struct em28xx_led *em28xx_find_led(struct em28xx *dev, | |||
614 | { | 614 | { |
615 | if (dev->board.leds) { | 615 | if (dev->board.leds) { |
616 | u8 k = 0; | 616 | u8 k = 0; |
617 | |||
617 | while (dev->board.leds[k].role >= 0 && | 618 | while (dev->board.leds[k].role >= 0 && |
618 | dev->board.leds[k].role < EM28XX_NUM_LED_ROLES) { | 619 | dev->board.leds[k].role < EM28XX_NUM_LED_ROLES) { |
619 | if (dev->board.leds[k].role == role) | 620 | if (dev->board.leds[k].role == role) |
620 | return &dev->board.leds[k]; | 621 | return &dev->board.leds[k]; |
621 | k++; | 622 | k++; |
@@ -658,10 +659,12 @@ int em28xx_capture_start(struct em28xx *dev, int start) | |||
658 | 659 | ||
659 | if (dev->mode == EM28XX_ANALOG_MODE) | 660 | if (dev->mode == EM28XX_ANALOG_MODE) |
660 | rc = em28xx_write_reg(dev, | 661 | rc = em28xx_write_reg(dev, |
661 | EM28XX_R12_VINENABLE, 0x67); | 662 | EM28XX_R12_VINENABLE, |
663 | 0x67); | ||
662 | else | 664 | else |
663 | rc = em28xx_write_reg(dev, | 665 | rc = em28xx_write_reg(dev, |
664 | EM28XX_R12_VINENABLE, 0x37); | 666 | EM28XX_R12_VINENABLE, |
667 | 0x37); | ||
665 | if (rc < 0) | 668 | if (rc < 0) |
666 | return rc; | 669 | return rc; |
667 | 670 | ||
@@ -815,9 +818,9 @@ void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode) | |||
815 | 818 | ||
816 | if (usb_bufs->transfer_buffer[i]) { | 819 | if (usb_bufs->transfer_buffer[i]) { |
817 | usb_free_coherent(dev->udev, | 820 | usb_free_coherent(dev->udev, |
818 | urb->transfer_buffer_length, | 821 | urb->transfer_buffer_length, |
819 | usb_bufs->transfer_buffer[i], | 822 | usb_bufs->transfer_buffer[i], |
820 | urb->transfer_dma); | 823 | urb->transfer_dma); |
821 | } | 824 | } |
822 | usb_free_urb(urb); | 825 | usb_free_urb(urb); |
823 | usb_bufs->urb[i] = NULL; | 826 | usb_bufs->urb[i] = NULL; |
@@ -889,7 +892,7 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, | |||
889 | if ((xfer_bulk && !dev->analog_ep_bulk) || | 892 | if ((xfer_bulk && !dev->analog_ep_bulk) || |
890 | (!xfer_bulk && !dev->analog_ep_isoc)) { | 893 | (!xfer_bulk && !dev->analog_ep_isoc)) { |
891 | em28xx_errdev("no endpoint for analog mode and transfer type %d\n", | 894 | em28xx_errdev("no endpoint for analog mode and transfer type %d\n", |
892 | xfer_bulk > 0); | 895 | xfer_bulk > 0); |
893 | return -EINVAL; | 896 | return -EINVAL; |
894 | } | 897 | } |
895 | usb_bufs = &dev->usb_ctl.analog_bufs; | 898 | usb_bufs = &dev->usb_ctl.analog_bufs; |
@@ -988,9 +991,9 @@ EXPORT_SYMBOL_GPL(em28xx_alloc_urbs); | |||
988 | * Allocate URBs and start IRQ | 991 | * Allocate URBs and start IRQ |
989 | */ | 992 | */ |
990 | int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, | 993 | int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, |
991 | int xfer_bulk, int num_bufs, int max_pkt_size, | 994 | int xfer_bulk, int num_bufs, int max_pkt_size, |
992 | int packet_multiplier, | 995 | int packet_multiplier, |
993 | int (*urb_data_copy) (struct em28xx *dev, struct urb *urb)) | 996 | int (*urb_data_copy)(struct em28xx *dev, struct urb *urb)) |
994 | { | 997 | { |
995 | struct em28xx_dmaqueue *dma_q = &dev->vidq; | 998 | struct em28xx_dmaqueue *dma_q = &dev->vidq; |
996 | struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; | 999 | struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; |
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 9682c52d67d1..9877b699c6bc 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c | |||
@@ -63,7 +63,6 @@ MODULE_LICENSE("GPL"); | |||
63 | MODULE_DESCRIPTION(DRIVER_DESC " - digital TV interface"); | 63 | MODULE_DESCRIPTION(DRIVER_DESC " - digital TV interface"); |
64 | MODULE_VERSION(EM28XX_VERSION); | 64 | MODULE_VERSION(EM28XX_VERSION); |
65 | 65 | ||
66 | |||
67 | static unsigned int debug; | 66 | static unsigned int debug; |
68 | module_param(debug, int, 0644); | 67 | module_param(debug, int, 0644); |
69 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | 68 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); |
@@ -71,7 +70,7 @@ MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | |||
71 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 70 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
72 | 71 | ||
73 | #define dprintk(level, fmt, arg...) do { \ | 72 | #define dprintk(level, fmt, arg...) do { \ |
74 | if (debug >= level) \ | 73 | if (debug >= level) \ |
75 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ | 74 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ |
76 | } while (0) | 75 | } while (0) |
77 | 76 | ||
@@ -99,9 +98,8 @@ struct em28xx_dvb { | |||
99 | struct i2c_client *i2c_client_tuner; | 98 | struct i2c_client *i2c_client_tuner; |
100 | }; | 99 | }; |
101 | 100 | ||
102 | |||
103 | static inline void print_err_status(struct em28xx *dev, | 101 | static inline void print_err_status(struct em28xx *dev, |
104 | int packet, int status) | 102 | int packet, int status) |
105 | { | 103 | { |
106 | char *errmsg = "Unknown"; | 104 | char *errmsg = "Unknown"; |
107 | 105 | ||
@@ -169,7 +167,7 @@ static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb) | |||
169 | if (!urb->actual_length) | 167 | if (!urb->actual_length) |
170 | continue; | 168 | continue; |
171 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer, | 169 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer, |
172 | urb->actual_length); | 170 | urb->actual_length); |
173 | } else { | 171 | } else { |
174 | if (urb->iso_frame_desc[i].status < 0) { | 172 | if (urb->iso_frame_desc[i].status < 0) { |
175 | print_err_status(dev, i, | 173 | print_err_status(dev, i, |
@@ -280,7 +278,6 @@ static int em28xx_stop_feed(struct dvb_demux_feed *feed) | |||
280 | } | 278 | } |
281 | 279 | ||
282 | 280 | ||
283 | |||
284 | /* ------------------------------------------------------------------ */ | 281 | /* ------------------------------------------------------------------ */ |
285 | static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) | 282 | static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) |
286 | { | 283 | { |
@@ -740,7 +737,7 @@ static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) | |||
740 | return ret; | 737 | return ret; |
741 | #else | 738 | #else |
742 | dev_warn(&dev->udev->dev, "%s: LNA control is disabled (lna=%u)\n", | 739 | dev_warn(&dev->udev->dev, "%s: LNA control is disabled (lna=%u)\n", |
743 | KBUILD_MODNAME, c->lna); | 740 | KBUILD_MODNAME, c->lna); |
744 | return 0; | 741 | return 0; |
745 | #endif | 742 | #endif |
746 | } | 743 | } |
@@ -830,6 +827,7 @@ static struct zl10353_config em28xx_zl10353_no_i2c_gate_dev = { | |||
830 | .no_tuner = 1, | 827 | .no_tuner = 1, |
831 | .parallel_ts = 1, | 828 | .parallel_ts = 1, |
832 | }; | 829 | }; |
830 | |||
833 | static struct qt1010_config em28xx_qt1010_config = { | 831 | static struct qt1010_config em28xx_qt1010_config = { |
834 | .i2c_address = 0x62 | 832 | .i2c_address = 0x62 |
835 | }; | 833 | }; |
@@ -861,7 +859,6 @@ static const struct m88ds3103_config pctv_461e_m88ds3103_config = { | |||
861 | .agc = 0x99, | 859 | .agc = 0x99, |
862 | }; | 860 | }; |
863 | 861 | ||
864 | |||
865 | static struct tda18271_std_map drx_j_std_map = { | 862 | static struct tda18271_std_map drx_j_std_map = { |
866 | .atsc_6 = { .if_freq = 5000, .agc_mode = 3, .std = 0, .if_lvl = 1, | 863 | .atsc_6 = { .if_freq = 5000, .agc_mode = 3, .std = 0, .if_lvl = 1, |
867 | .rfagc_top = 0x37, }, | 864 | .rfagc_top = 0x37, }, |
@@ -948,7 +945,7 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, | |||
948 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); | 945 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); |
949 | if (result < 0) { | 946 | if (result < 0) { |
950 | printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n", | 947 | printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n", |
951 | dev->name, result); | 948 | dev->name, result); |
952 | goto fail_frontend1; | 949 | goto fail_frontend1; |
953 | } | 950 | } |
954 | } | 951 | } |
@@ -1047,7 +1044,7 @@ static void em28xx_unregister_dvb(struct em28xx_dvb *dvb) | |||
1047 | 1044 | ||
1048 | static int em28xx_dvb_init(struct em28xx *dev) | 1045 | static int em28xx_dvb_init(struct em28xx *dev) |
1049 | { | 1046 | { |
1050 | int result = 0, mfe_shared = 0; | 1047 | int result = 0; |
1051 | struct em28xx_dvb *dvb; | 1048 | struct em28xx_dvb *dvb; |
1052 | 1049 | ||
1053 | if (dev->is_audio_only) { | 1050 | if (dev->is_audio_only) { |
@@ -1182,7 +1179,8 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1182 | &dev->i2c_adap[dev->def_i2c_bus]); | 1179 | &dev->i2c_adap[dev->def_i2c_bus]); |
1183 | if (dvb->fe[0] != NULL) { | 1180 | if (dvb->fe[0] != NULL) { |
1184 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], | 1181 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
1185 | &dev->i2c_adap[dev->def_i2c_bus], 0x61, TUNER_THOMSON_DTT761X)) { | 1182 | &dev->i2c_adap[dev->def_i2c_bus], |
1183 | 0x61, TUNER_THOMSON_DTT761X)) { | ||
1186 | result = -EINVAL; | 1184 | result = -EINVAL; |
1187 | goto out_free; | 1185 | goto out_free; |
1188 | } | 1186 | } |
@@ -1204,7 +1202,8 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1204 | &dev->i2c_adap[dev->def_i2c_bus], 0x48); | 1202 | &dev->i2c_adap[dev->def_i2c_bus], 0x48); |
1205 | if (dvb->fe[0]) { | 1203 | if (dvb->fe[0]) { |
1206 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], | 1204 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
1207 | &dev->i2c_adap[dev->def_i2c_bus], 0x60, TUNER_PHILIPS_CU1216L)) { | 1205 | &dev->i2c_adap[dev->def_i2c_bus], |
1206 | 0x60, TUNER_PHILIPS_CU1216L)) { | ||
1208 | result = -EINVAL; | 1207 | result = -EINVAL; |
1209 | goto out_free; | 1208 | goto out_free; |
1210 | } | 1209 | } |
@@ -1219,7 +1218,7 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1219 | goto out_free; | 1218 | goto out_free; |
1220 | } | 1219 | } |
1221 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, | 1220 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
1222 | &dev->i2c_adap[dev->def_i2c_bus], | 1221 | &dev->i2c_adap[dev->def_i2c_bus], |
1223 | &kworld_a340_config)) { | 1222 | &kworld_a340_config)) { |
1224 | dvb_frontend_detach(dvb->fe[0]); | 1223 | dvb_frontend_detach(dvb->fe[0]); |
1225 | result = -EINVAL; | 1224 | result = -EINVAL; |
@@ -1250,10 +1249,10 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1250 | #ifdef CONFIG_GPIOLIB | 1249 | #ifdef CONFIG_GPIOLIB |
1251 | /* enable LNA for DVB-T, DVB-T2 and DVB-C */ | 1250 | /* enable LNA for DVB-T, DVB-T2 and DVB-C */ |
1252 | result = gpio_request_one(dvb->lna_gpio, | 1251 | result = gpio_request_one(dvb->lna_gpio, |
1253 | GPIOF_OUT_INIT_LOW, NULL); | 1252 | GPIOF_OUT_INIT_LOW, NULL); |
1254 | if (result) | 1253 | if (result) |
1255 | em28xx_errdev("gpio request failed %d\n", | 1254 | em28xx_errdev("gpio request failed %d\n", |
1256 | result); | 1255 | result); |
1257 | else | 1256 | else |
1258 | gpio_free(dvb->lna_gpio); | 1257 | gpio_free(dvb->lna_gpio); |
1259 | 1258 | ||
@@ -1266,6 +1265,7 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1266 | case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: | 1265 | case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: |
1267 | { | 1266 | { |
1268 | struct xc5000_config cfg; | 1267 | struct xc5000_config cfg; |
1268 | |||
1269 | hauppauge_hvr930c_init(dev); | 1269 | hauppauge_hvr930c_init(dev); |
1270 | 1270 | ||
1271 | dvb->fe[0] = dvb_attach(drxk_attach, | 1271 | dvb->fe[0] = dvb_attach(drxk_attach, |
@@ -1339,7 +1339,7 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1339 | /* attach SEC */ | 1339 | /* attach SEC */ |
1340 | if (dvb->fe[0]) | 1340 | if (dvb->fe[0]) |
1341 | dvb_attach(a8293_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus], | 1341 | dvb_attach(a8293_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus], |
1342 | &em28xx_a8293_config); | 1342 | &em28xx_a8293_config); |
1343 | break; | 1343 | break; |
1344 | case EM2874_BOARD_DELOCK_61959: | 1344 | case EM2874_BOARD_DELOCK_61959: |
1345 | case EM2874_BOARD_MAXMEDIA_UB425_TC: | 1345 | case EM2874_BOARD_MAXMEDIA_UB425_TC: |
@@ -1553,6 +1553,7 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1553 | struct si2157_config si2157_config; | 1553 | struct si2157_config si2157_config; |
1554 | 1554 | ||
1555 | /* attach demod */ | 1555 | /* attach demod */ |
1556 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
1556 | si2168_config.i2c_adapter = &adapter; | 1557 | si2168_config.i2c_adapter = &adapter; |
1557 | si2168_config.fe = &dvb->fe[0]; | 1558 | si2168_config.fe = &dvb->fe[0]; |
1558 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | 1559 | si2168_config.ts_mode = SI2168_TS_PARALLEL; |
@@ -1603,6 +1604,65 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1603 | dvb->fe[0]->ops.set_lna = em28xx_pctv_292e_set_lna; | 1604 | dvb->fe[0]->ops.set_lna = em28xx_pctv_292e_set_lna; |
1604 | } | 1605 | } |
1605 | break; | 1606 | break; |
1607 | case EM28178_BOARD_TERRATEC_T2_STICK_HD: | ||
1608 | { | ||
1609 | struct i2c_adapter *adapter; | ||
1610 | struct i2c_client *client; | ||
1611 | struct i2c_board_info info; | ||
1612 | struct si2168_config si2168_config; | ||
1613 | struct si2157_config si2157_config; | ||
1614 | |||
1615 | /* attach demod */ | ||
1616 | memset(&si2168_config, 0, sizeof(si2168_config)); | ||
1617 | si2168_config.i2c_adapter = &adapter; | ||
1618 | si2168_config.fe = &dvb->fe[0]; | ||
1619 | si2168_config.ts_mode = SI2168_TS_PARALLEL; | ||
1620 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1621 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); | ||
1622 | info.addr = 0x64; | ||
1623 | info.platform_data = &si2168_config; | ||
1624 | request_module(info.type); | ||
1625 | client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info); | ||
1626 | if (client == NULL || client->dev.driver == NULL) { | ||
1627 | result = -ENODEV; | ||
1628 | goto out_free; | ||
1629 | } | ||
1630 | |||
1631 | if (!try_module_get(client->dev.driver->owner)) { | ||
1632 | i2c_unregister_device(client); | ||
1633 | result = -ENODEV; | ||
1634 | goto out_free; | ||
1635 | } | ||
1636 | |||
1637 | dvb->i2c_client_demod = client; | ||
1638 | |||
1639 | /* attach tuner */ | ||
1640 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
1641 | si2157_config.fe = dvb->fe[0]; | ||
1642 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1643 | strlcpy(info.type, "si2146", I2C_NAME_SIZE); | ||
1644 | info.addr = 0x60; | ||
1645 | info.platform_data = &si2157_config; | ||
1646 | request_module("si2157"); | ||
1647 | client = i2c_new_device(adapter, &info); | ||
1648 | if (client == NULL || client->dev.driver == NULL) { | ||
1649 | module_put(dvb->i2c_client_demod->dev.driver->owner); | ||
1650 | i2c_unregister_device(dvb->i2c_client_demod); | ||
1651 | result = -ENODEV; | ||
1652 | goto out_free; | ||
1653 | } | ||
1654 | |||
1655 | if (!try_module_get(client->dev.driver->owner)) { | ||
1656 | i2c_unregister_device(client); | ||
1657 | module_put(dvb->i2c_client_demod->dev.driver->owner); | ||
1658 | i2c_unregister_device(dvb->i2c_client_demod); | ||
1659 | result = -ENODEV; | ||
1660 | goto out_free; | ||
1661 | } | ||
1662 | |||
1663 | dvb->i2c_client_tuner = client; | ||
1664 | } | ||
1665 | break; | ||
1606 | default: | 1666 | default: |
1607 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" | 1667 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" |
1608 | " isn't supported yet\n"); | 1668 | " isn't supported yet\n"); |
@@ -1624,9 +1684,6 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1624 | if (result < 0) | 1684 | if (result < 0) |
1625 | goto out_free; | 1685 | goto out_free; |
1626 | 1686 | ||
1627 | /* MFE lock */ | ||
1628 | dvb->adapter.mfe_shared = mfe_shared; | ||
1629 | |||
1630 | em28xx_info("DVB extension successfully initialized\n"); | 1687 | em28xx_info("DVB extension successfully initialized\n"); |
1631 | 1688 | ||
1632 | kref_get(&dev->ref); | 1689 | kref_get(&dev->ref); |
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index 1048c1a23fb6..a19b5c8b56ff 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c | |||
@@ -593,6 +593,7 @@ static inline unsigned long em28xx_hash_mem(char *buf, int length, int bits) | |||
593 | unsigned long l = 0; | 593 | unsigned long l = 0; |
594 | int len = 0; | 594 | int len = 0; |
595 | unsigned char c; | 595 | unsigned char c; |
596 | |||
596 | do { | 597 | do { |
597 | if (len == length) { | 598 | if (len == length) { |
598 | c = (char)len; | 599 | c = (char)len; |
@@ -877,6 +878,7 @@ static struct i2c_client em28xx_client_template = { | |||
877 | * incomplete list of known devices | 878 | * incomplete list of known devices |
878 | */ | 879 | */ |
879 | static char *i2c_devs[128] = { | 880 | static char *i2c_devs[128] = { |
881 | [0x1c >> 1] = "lgdt330x", | ||
880 | [0x3e >> 1] = "remote IR sensor", | 882 | [0x3e >> 1] = "remote IR sensor", |
881 | [0x4a >> 1] = "saa7113h", | 883 | [0x4a >> 1] = "saa7113h", |
882 | [0x52 >> 1] = "drxk", | 884 | [0x52 >> 1] = "drxk", |
@@ -949,7 +951,7 @@ int em28xx_i2c_register(struct em28xx *dev, unsigned bus, | |||
949 | retval = i2c_add_adapter(&dev->i2c_adap[bus]); | 951 | retval = i2c_add_adapter(&dev->i2c_adap[bus]); |
950 | if (retval < 0) { | 952 | if (retval < 0) { |
951 | em28xx_errdev("%s: i2c_add_adapter failed! retval [%d]\n", | 953 | em28xx_errdev("%s: i2c_add_adapter failed! retval [%d]\n", |
952 | __func__, retval); | 954 | __func__, retval); |
953 | return retval; | 955 | return retval; |
954 | } | 956 | } |
955 | 957 | ||
@@ -961,7 +963,7 @@ int em28xx_i2c_register(struct em28xx *dev, unsigned bus, | |||
961 | retval = em28xx_i2c_eeprom(dev, bus, &dev->eedata, &dev->eedata_len); | 963 | retval = em28xx_i2c_eeprom(dev, bus, &dev->eedata, &dev->eedata_len); |
962 | if ((retval < 0) && (retval != -ENODEV)) { | 964 | if ((retval < 0) && (retval != -ENODEV)) { |
963 | em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", | 965 | em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", |
964 | __func__, retval); | 966 | __func__, retval); |
965 | 967 | ||
966 | return retval; | 968 | return retval; |
967 | } | 969 | } |
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c index 23f8f6afa2e0..d8dc03aadfbd 100644 --- a/drivers/media/usb/em28xx/em28xx-input.c +++ b/drivers/media/usb/em28xx/em28xx-input.c | |||
@@ -459,7 +459,7 @@ static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) | |||
459 | return em2874_ir_change_protocol(rc_dev, rc_type); | 459 | return em2874_ir_change_protocol(rc_dev, rc_type); |
460 | default: | 460 | default: |
461 | printk("Unrecognized em28xx chip id 0x%02x: IR not supported\n", | 461 | printk("Unrecognized em28xx chip id 0x%02x: IR not supported\n", |
462 | dev->chip_id); | 462 | dev->chip_id); |
463 | return -EINVAL; | 463 | return -EINVAL; |
464 | } | 464 | } |
465 | } | 465 | } |
@@ -505,7 +505,7 @@ static void em28xx_query_buttons(struct work_struct *work) | |||
505 | /* Check states of the buttons and act */ | 505 | /* Check states of the buttons and act */ |
506 | j = 0; | 506 | j = 0; |
507 | while (dev->board.buttons[j].role >= 0 && | 507 | while (dev->board.buttons[j].role >= 0 && |
508 | dev->board.buttons[j].role < EM28XX_NUM_BUTTON_ROLES) { | 508 | dev->board.buttons[j].role < EM28XX_NUM_BUTTON_ROLES) { |
509 | struct em28xx_button *button = &dev->board.buttons[j]; | 509 | struct em28xx_button *button = &dev->board.buttons[j]; |
510 | /* Check if button uses the current address */ | 510 | /* Check if button uses the current address */ |
511 | if (button->reg_r != dev->button_polling_addresses[i]) { | 511 | if (button->reg_r != dev->button_polling_addresses[i]) { |
@@ -607,7 +607,7 @@ static void em28xx_init_buttons(struct em28xx *dev) | |||
607 | 607 | ||
608 | dev->button_polling_interval = EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL; | 608 | dev->button_polling_interval = EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL; |
609 | while (dev->board.buttons[i].role >= 0 && | 609 | while (dev->board.buttons[i].role >= 0 && |
610 | dev->board.buttons[i].role < EM28XX_NUM_BUTTON_ROLES) { | 610 | dev->board.buttons[i].role < EM28XX_NUM_BUTTON_ROLES) { |
611 | struct em28xx_button *button = &dev->board.buttons[i]; | 611 | struct em28xx_button *button = &dev->board.buttons[i]; |
612 | /* Check if polling address is already on the list */ | 612 | /* Check if polling address is already on the list */ |
613 | addr_new = true; | 613 | addr_new = true; |
@@ -653,11 +653,11 @@ next_button: | |||
653 | /* Start polling */ | 653 | /* Start polling */ |
654 | if (dev->num_button_polling_addresses) { | 654 | if (dev->num_button_polling_addresses) { |
655 | memset(dev->button_polling_last_values, 0, | 655 | memset(dev->button_polling_last_values, 0, |
656 | EM28XX_NUM_BUTTON_ADDRESSES_MAX); | 656 | EM28XX_NUM_BUTTON_ADDRESSES_MAX); |
657 | INIT_DELAYED_WORK(&dev->buttons_query_work, | 657 | INIT_DELAYED_WORK(&dev->buttons_query_work, |
658 | em28xx_query_buttons); | 658 | em28xx_query_buttons); |
659 | schedule_delayed_work(&dev->buttons_query_work, | 659 | schedule_delayed_work(&dev->buttons_query_work, |
660 | msecs_to_jiffies(dev->button_polling_interval)); | 660 | msecs_to_jiffies(dev->button_polling_interval)); |
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
@@ -841,8 +841,7 @@ static int em28xx_ir_fini(struct em28xx *dev) | |||
841 | if (!ir) | 841 | if (!ir) |
842 | goto ref_put; | 842 | goto ref_put; |
843 | 843 | ||
844 | if (ir->rc) | 844 | rc_unregister_device(ir->rc); |
845 | rc_unregister_device(ir->rc); | ||
846 | 845 | ||
847 | kfree(ir->i2c_client); | 846 | kfree(ir->i2c_client); |
848 | 847 | ||
@@ -887,7 +886,7 @@ static int em28xx_ir_resume(struct em28xx *dev) | |||
887 | schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); | 886 | schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); |
888 | if (dev->num_button_polling_addresses) | 887 | if (dev->num_button_polling_addresses) |
889 | schedule_delayed_work(&dev->buttons_query_work, | 888 | schedule_delayed_work(&dev->buttons_query_work, |
890 | msecs_to_jiffies(dev->button_polling_interval)); | 889 | msecs_to_jiffies(dev->button_polling_interval)); |
891 | return 0; | 890 | return 0; |
892 | } | 891 | } |
893 | 892 | ||
diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h index 311fb349dafa..13cbb7f3ea10 100644 --- a/drivers/media/usb/em28xx/em28xx-reg.h +++ b/drivers/media/usb/em28xx/em28xx-reg.h | |||
@@ -49,7 +49,6 @@ | |||
49 | #define EM28XX_CHIPCFG2_TS_PACKETSIZE_564 0x02 | 49 | #define EM28XX_CHIPCFG2_TS_PACKETSIZE_564 0x02 |
50 | #define EM28XX_CHIPCFG2_TS_PACKETSIZE_752 0x03 | 50 | #define EM28XX_CHIPCFG2_TS_PACKETSIZE_752 0x03 |
51 | 51 | ||
52 | |||
53 | /* GPIO/GPO registers */ | 52 | /* GPIO/GPO registers */ |
54 | #define EM2880_R04_GPO 0x04 /* em2880-em2883 only */ | 53 | #define EM2880_R04_GPO 0x04 /* em2880-em2883 only */ |
55 | #define EM2820_R08_GPIO_CTRL 0x08 /* em2820-em2873/83 only */ | 54 | #define EM2820_R08_GPIO_CTRL 0x08 /* em2820-em2873/83 only */ |
@@ -68,7 +67,6 @@ | |||
68 | #define EM28XX_I2C_FREQ_400_KHZ 0x01 | 67 | #define EM28XX_I2C_FREQ_400_KHZ 0x01 |
69 | #define EM28XX_I2C_FREQ_100_KHZ 0x00 | 68 | #define EM28XX_I2C_FREQ_100_KHZ 0x00 |
70 | 69 | ||
71 | |||
72 | #define EM28XX_R0A_CHIPID 0x0a | 70 | #define EM28XX_R0A_CHIPID 0x0a |
73 | #define EM28XX_R0C_USBSUSP 0x0c | 71 | #define EM28XX_R0C_USBSUSP 0x0c |
74 | #define EM28XX_R0C_USBSUSP_SNAPSHOT 0x20 /* 1=button pressed, needs reset */ | 72 | #define EM28XX_R0C_USBSUSP_SNAPSHOT 0x20 /* 1=button pressed, needs reset */ |
@@ -157,7 +155,6 @@ | |||
157 | #define EM28XX_OUTFMT_YUV422_Y1UY0V 0x15 | 155 | #define EM28XX_OUTFMT_YUV422_Y1UY0V 0x15 |
158 | #define EM28XX_OUTFMT_YUV411 0x18 | 156 | #define EM28XX_OUTFMT_YUV411 0x18 |
159 | 157 | ||
160 | |||
161 | #define EM28XX_R28_XMIN 0x28 | 158 | #define EM28XX_R28_XMIN 0x28 |
162 | #define EM28XX_R29_XMAX 0x29 | 159 | #define EM28XX_R29_XMAX 0x29 |
163 | #define EM28XX_R2A_YMIN 0x2a | 160 | #define EM28XX_R2A_YMIN 0x2a |
diff --git a/drivers/media/usb/em28xx/em28xx-v4l.h b/drivers/media/usb/em28xx/em28xx-v4l.h index 432862c20bbf..8dfcb56bf4b3 100644 --- a/drivers/media/usb/em28xx/em28xx-v4l.h +++ b/drivers/media/usb/em28xx/em28xx-v4l.h | |||
@@ -14,7 +14,6 @@ | |||
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | |||
18 | int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count); | 17 | int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count); |
19 | void em28xx_stop_vbi_streaming(struct vb2_queue *vq); | 18 | void em28xx_stop_vbi_streaming(struct vb2_queue *vq); |
20 | extern struct vb2_ops em28xx_vbi_qops; | 19 | extern struct vb2_ops em28xx_vbi_qops; |
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c b/drivers/media/usb/em28xx/em28xx-vbi.c index 34ee1e03a732..744e7ed743e1 100644 --- a/drivers/media/usb/em28xx/em28xx-vbi.c +++ b/drivers/media/usb/em28xx/em28xx-vbi.c | |||
@@ -92,7 +92,6 @@ vbi_buffer_queue(struct vb2_buffer *vb) | |||
92 | spin_unlock_irqrestore(&dev->slock, flags); | 92 | spin_unlock_irqrestore(&dev->slock, flags); |
93 | } | 93 | } |
94 | 94 | ||
95 | |||
96 | struct vb2_ops em28xx_vbi_qops = { | 95 | struct vb2_ops em28xx_vbi_qops = { |
97 | .queue_setup = vbi_queue_setup, | 96 | .queue_setup = vbi_queue_setup, |
98 | .buf_prepare = vbi_buffer_prepare, | 97 | .buf_prepare = vbi_buffer_prepare, |
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 03d5ece0319c..cf7f58b76292 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -81,7 +81,6 @@ MODULE_DESCRIPTION(DRIVER_DESC " - v4l2 interface"); | |||
81 | MODULE_LICENSE("GPL"); | 81 | MODULE_LICENSE("GPL"); |
82 | MODULE_VERSION(EM28XX_VERSION); | 82 | MODULE_VERSION(EM28XX_VERSION); |
83 | 83 | ||
84 | |||
85 | #define EM25XX_FRMDATAHDR_BYTE1 0x02 | 84 | #define EM25XX_FRMDATAHDR_BYTE1 0x02 |
86 | #define EM25XX_FRMDATAHDR_BYTE2_STILL_IMAGE 0x20 | 85 | #define EM25XX_FRMDATAHDR_BYTE2_STILL_IMAGE 0x20 |
87 | #define EM25XX_FRMDATAHDR_BYTE2_FRAME_END 0x02 | 86 | #define EM25XX_FRMDATAHDR_BYTE2_FRAME_END 0x02 |
@@ -90,7 +89,6 @@ MODULE_VERSION(EM28XX_VERSION); | |||
90 | EM25XX_FRMDATAHDR_BYTE2_FRAME_END | \ | 89 | EM25XX_FRMDATAHDR_BYTE2_FRAME_END | \ |
91 | EM25XX_FRMDATAHDR_BYTE2_FRAME_ID) | 90 | EM25XX_FRMDATAHDR_BYTE2_FRAME_ID) |
92 | 91 | ||
93 | |||
94 | static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; | 92 | static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
95 | static unsigned int vbi_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; | 93 | static unsigned int vbi_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
96 | static unsigned int radio_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; | 94 | static unsigned int radio_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
@@ -194,9 +192,10 @@ static int em28xx_vbi_supported(struct em28xx *dev) | |||
194 | static void em28xx_wake_i2c(struct em28xx *dev) | 192 | static void em28xx_wake_i2c(struct em28xx *dev) |
195 | { | 193 | { |
196 | struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev; | 194 | struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev; |
195 | |||
197 | v4l2_device_call_all(v4l2_dev, 0, core, reset, 0); | 196 | v4l2_device_call_all(v4l2_dev, 0, core, reset, 0); |
198 | v4l2_device_call_all(v4l2_dev, 0, video, s_routing, | 197 | v4l2_device_call_all(v4l2_dev, 0, video, s_routing, |
199 | INPUT(dev->ctl_input)->vmux, 0, 0); | 198 | INPUT(dev->ctl_input)->vmux, 0, 0); |
200 | v4l2_device_call_all(v4l2_dev, 0, video, s_stream, 0); | 199 | v4l2_device_call_all(v4l2_dev, 0, video, s_stream, 0); |
201 | } | 200 | } |
202 | 201 | ||
@@ -275,7 +274,7 @@ static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, | |||
275 | } | 274 | } |
276 | 275 | ||
277 | static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, | 276 | static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, |
278 | u16 width, u16 height) | 277 | u16 width, u16 height) |
279 | { | 278 | { |
280 | u8 cwidth = width >> 2; | 279 | u8 cwidth = width >> 2; |
281 | u8 cheight = height >> 2; | 280 | u8 cheight = height >> 2; |
@@ -283,7 +282,7 @@ static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, | |||
283 | /* NOTE: size limit: 2047x1023 = 2MPix */ | 282 | /* NOTE: size limit: 2047x1023 = 2MPix */ |
284 | 283 | ||
285 | em28xx_videodbg("capture area set to (%d,%d): %dx%d\n", | 284 | em28xx_videodbg("capture area set to (%d,%d): %dx%d\n", |
286 | hstart, vstart, | 285 | hstart, vstart, |
287 | ((overflow & 2) << 9 | cwidth << 2), | 286 | ((overflow & 2) << 9 | cwidth << 2), |
288 | ((overflow & 1) << 10 | cheight << 2)); | 287 | ((overflow & 1) << 10 | cheight << 2)); |
289 | 288 | ||
@@ -406,13 +405,13 @@ set_alt: | |||
406 | dev->packet_multiplier = EM28XX_BULK_PACKET_MULTIPLIER; | 405 | dev->packet_multiplier = EM28XX_BULK_PACKET_MULTIPLIER; |
407 | } else { /* isoc */ | 406 | } else { /* isoc */ |
408 | em28xx_videodbg("minimum isoc packet size: %u (alt=%d)\n", | 407 | em28xx_videodbg("minimum isoc packet size: %u (alt=%d)\n", |
409 | min_pkt_size, dev->alt); | 408 | min_pkt_size, dev->alt); |
410 | dev->max_pkt_size = | 409 | dev->max_pkt_size = |
411 | dev->alt_max_pkt_size_isoc[dev->alt]; | 410 | dev->alt_max_pkt_size_isoc[dev->alt]; |
412 | dev->packet_multiplier = EM28XX_NUM_ISOC_PACKETS; | 411 | dev->packet_multiplier = EM28XX_NUM_ISOC_PACKETS; |
413 | } | 412 | } |
414 | em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n", | 413 | em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n", |
415 | dev->alt, dev->max_pkt_size); | 414 | dev->alt, dev->max_pkt_size); |
416 | errCode = usb_set_interface(dev->udev, dev->ifnum, dev->alt); | 415 | errCode = usb_set_interface(dev->udev, dev->ifnum, dev->alt); |
417 | if (errCode < 0) { | 416 | if (errCode < 0) { |
418 | em28xx_errdev("cannot change alternate number to %d (error=%i)\n", | 417 | em28xx_errdev("cannot change alternate number to %d (error=%i)\n", |
@@ -482,7 +481,7 @@ static void em28xx_copy_video(struct em28xx *dev, | |||
482 | 481 | ||
483 | if ((char *)startwrite + lencopy > (char *)buf->vb_buf + buf->length) { | 482 | if ((char *)startwrite + lencopy > (char *)buf->vb_buf + buf->length) { |
484 | em28xx_isocdbg("Overflow of %zu bytes past buffer end (1)\n", | 483 | em28xx_isocdbg("Overflow of %zu bytes past buffer end (1)\n", |
485 | ((char *)startwrite + lencopy) - | 484 | ((char *)startwrite + lencopy) - |
486 | ((char *)buf->vb_buf + buf->length)); | 485 | ((char *)buf->vb_buf + buf->length)); |
487 | remain = (char *)buf->vb_buf + buf->length - | 486 | remain = (char *)buf->vb_buf + buf->length - |
488 | (char *)startwrite; | 487 | (char *)startwrite; |
@@ -548,7 +547,7 @@ static void em28xx_copy_vbi(struct em28xx *dev, | |||
548 | } | 547 | } |
549 | 548 | ||
550 | static inline void print_err_status(struct em28xx *dev, | 549 | static inline void print_err_status(struct em28xx *dev, |
551 | int packet, int status) | 550 | int packet, int status) |
552 | { | 551 | { |
553 | char *errmsg = "Unknown"; | 552 | char *errmsg = "Unknown"; |
554 | 553 | ||
@@ -831,7 +830,6 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb) | |||
831 | return 1; | 830 | return 1; |
832 | } | 831 | } |
833 | 832 | ||
834 | |||
835 | static int get_ressource(enum v4l2_buf_type f_type) | 833 | static int get_ressource(enum v4l2_buf_type f_type) |
836 | { | 834 | { |
837 | switch (f_type) { | 835 | switch (f_type) { |
@@ -1003,6 +1001,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq) | |||
1003 | } | 1001 | } |
1004 | while (!list_empty(&vidq->active)) { | 1002 | while (!list_empty(&vidq->active)) { |
1005 | struct em28xx_buffer *buf; | 1003 | struct em28xx_buffer *buf; |
1004 | |||
1006 | buf = list_entry(vidq->active.next, struct em28xx_buffer, list); | 1005 | buf = list_entry(vidq->active.next, struct em28xx_buffer, list); |
1007 | list_del(&buf->list); | 1006 | list_del(&buf->list); |
1008 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | 1007 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); |
@@ -1033,6 +1032,7 @@ void em28xx_stop_vbi_streaming(struct vb2_queue *vq) | |||
1033 | } | 1032 | } |
1034 | while (!list_empty(&vbiq->active)) { | 1033 | while (!list_empty(&vbiq->active)) { |
1035 | struct em28xx_buffer *buf; | 1034 | struct em28xx_buffer *buf; |
1035 | |||
1036 | buf = list_entry(vbiq->active.next, struct em28xx_buffer, list); | 1036 | buf = list_entry(vbiq->active.next, struct em28xx_buffer, list); |
1037 | list_del(&buf->list); | 1037 | list_del(&buf->list); |
1038 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | 1038 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); |
@@ -1109,6 +1109,7 @@ static int em28xx_vb2_setup(struct em28xx *dev) | |||
1109 | static void video_mux(struct em28xx *dev, int index) | 1109 | static void video_mux(struct em28xx *dev, int index) |
1110 | { | 1110 | { |
1111 | struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev; | 1111 | struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev; |
1112 | |||
1112 | dev->ctl_input = index; | 1113 | dev->ctl_input = index; |
1113 | dev->ctl_ainput = INPUT(index)->amux; | 1114 | dev->ctl_ainput = INPUT(index)->amux; |
1114 | dev->ctl_aoutput = INPUT(index)->aout; | 1115 | dev->ctl_aoutput = INPUT(index)->aout; |
@@ -1117,21 +1118,22 @@ static void video_mux(struct em28xx *dev, int index) | |||
1117 | dev->ctl_aoutput = EM28XX_AOUT_MASTER; | 1118 | dev->ctl_aoutput = EM28XX_AOUT_MASTER; |
1118 | 1119 | ||
1119 | v4l2_device_call_all(v4l2_dev, 0, video, s_routing, | 1120 | v4l2_device_call_all(v4l2_dev, 0, video, s_routing, |
1120 | INPUT(index)->vmux, 0, 0); | 1121 | INPUT(index)->vmux, 0, 0); |
1121 | 1122 | ||
1122 | if (dev->board.has_msp34xx) { | 1123 | if (dev->board.has_msp34xx) { |
1123 | if (dev->i2s_speed) { | 1124 | if (dev->i2s_speed) { |
1124 | v4l2_device_call_all(v4l2_dev, 0, audio, | 1125 | v4l2_device_call_all(v4l2_dev, 0, audio, |
1125 | s_i2s_clock_freq, dev->i2s_speed); | 1126 | s_i2s_clock_freq, dev->i2s_speed); |
1126 | } | 1127 | } |
1127 | /* Note: this is msp3400 specific */ | 1128 | /* Note: this is msp3400 specific */ |
1128 | v4l2_device_call_all(v4l2_dev, 0, audio, s_routing, | 1129 | v4l2_device_call_all(v4l2_dev, 0, audio, s_routing, |
1129 | dev->ctl_ainput, MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0); | 1130 | dev->ctl_ainput, |
1131 | MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0); | ||
1130 | } | 1132 | } |
1131 | 1133 | ||
1132 | if (dev->board.adecoder != EM28XX_NOADECODER) { | 1134 | if (dev->board.adecoder != EM28XX_NOADECODER) { |
1133 | v4l2_device_call_all(v4l2_dev, 0, audio, s_routing, | 1135 | v4l2_device_call_all(v4l2_dev, 0, audio, s_routing, |
1134 | dev->ctl_ainput, dev->ctl_aoutput, 0); | 1136 | dev->ctl_ainput, dev->ctl_aoutput, 0); |
1135 | } | 1137 | } |
1136 | 1138 | ||
1137 | em28xx_audio_analog_set(dev); | 1139 | em28xx_audio_analog_set(dev); |
@@ -1203,7 +1205,7 @@ static const struct v4l2_ctrl_ops em28xx_ctrl_ops = { | |||
1203 | }; | 1205 | }; |
1204 | 1206 | ||
1205 | static void size_to_scale(struct em28xx *dev, | 1207 | static void size_to_scale(struct em28xx *dev, |
1206 | unsigned int width, unsigned int height, | 1208 | unsigned int width, unsigned int height, |
1207 | unsigned int *hscale, unsigned int *vscale) | 1209 | unsigned int *hscale, unsigned int *vscale) |
1208 | { | 1210 | { |
1209 | unsigned int maxw = norm_maxw(dev); | 1211 | unsigned int maxw = norm_maxw(dev); |
@@ -1234,7 +1236,7 @@ static void scale_to_size(struct em28xx *dev, | |||
1234 | ------------------------------------------------------------------*/ | 1236 | ------------------------------------------------------------------*/ |
1235 | 1237 | ||
1236 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | 1238 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
1237 | struct v4l2_format *f) | 1239 | struct v4l2_format *f) |
1238 | { | 1240 | { |
1239 | struct em28xx *dev = video_drvdata(file); | 1241 | struct em28xx *dev = video_drvdata(file); |
1240 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 1242 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
@@ -1267,7 +1269,7 @@ static struct em28xx_fmt *format_by_fourcc(unsigned int fourcc) | |||
1267 | } | 1269 | } |
1268 | 1270 | ||
1269 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | 1271 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
1270 | struct v4l2_format *f) | 1272 | struct v4l2_format *f) |
1271 | { | 1273 | { |
1272 | struct em28xx *dev = video_drvdata(file); | 1274 | struct em28xx *dev = video_drvdata(file); |
1273 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 1275 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
@@ -1338,7 +1340,7 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc, | |||
1338 | 1340 | ||
1339 | /* set new image size */ | 1341 | /* set new image size */ |
1340 | size_to_scale(dev, v4l2->width, v4l2->height, | 1342 | size_to_scale(dev, v4l2->width, v4l2->height, |
1341 | &v4l2->hscale, &v4l2->vscale); | 1343 | &v4l2->hscale, &v4l2->vscale); |
1342 | 1344 | ||
1343 | em28xx_resolution_set(dev); | 1345 | em28xx_resolution_set(dev); |
1344 | 1346 | ||
@@ -1346,7 +1348,7 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc, | |||
1346 | } | 1348 | } |
1347 | 1349 | ||
1348 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | 1350 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, |
1349 | struct v4l2_format *f) | 1351 | struct v4l2_format *f) |
1350 | { | 1352 | { |
1351 | struct em28xx *dev = video_drvdata(file); | 1353 | struct em28xx *dev = video_drvdata(file); |
1352 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 1354 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
@@ -1401,7 +1403,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) | |||
1401 | v4l2->width = f.fmt.pix.width; | 1403 | v4l2->width = f.fmt.pix.width; |
1402 | v4l2->height = f.fmt.pix.height; | 1404 | v4l2->height = f.fmt.pix.height; |
1403 | size_to_scale(dev, v4l2->width, v4l2->height, | 1405 | size_to_scale(dev, v4l2->width, v4l2->height, |
1404 | &v4l2->hscale, &v4l2->vscale); | 1406 | &v4l2->hscale, &v4l2->vscale); |
1405 | 1407 | ||
1406 | em28xx_resolution_set(dev); | 1408 | em28xx_resolution_set(dev); |
1407 | v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_std, v4l2->norm); | 1409 | v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_std, v4l2->norm); |
@@ -1422,7 +1424,7 @@ static int vidioc_g_parm(struct file *file, void *priv, | |||
1422 | video, g_parm, p); | 1424 | video, g_parm, p); |
1423 | else | 1425 | else |
1424 | v4l2_video_std_frame_period(v4l2->norm, | 1426 | v4l2_video_std_frame_period(v4l2->norm, |
1425 | &p->parm.capture.timeperframe); | 1427 | &p->parm.capture.timeperframe); |
1426 | 1428 | ||
1427 | return rc; | 1429 | return rc; |
1428 | } | 1430 | } |
@@ -1450,7 +1452,7 @@ static const char *iname[] = { | |||
1450 | }; | 1452 | }; |
1451 | 1453 | ||
1452 | static int vidioc_enum_input(struct file *file, void *priv, | 1454 | static int vidioc_enum_input(struct file *file, void *priv, |
1453 | struct v4l2_input *i) | 1455 | struct v4l2_input *i) |
1454 | { | 1456 | { |
1455 | struct em28xx *dev = video_drvdata(file); | 1457 | struct em28xx *dev = video_drvdata(file); |
1456 | unsigned int n; | 1458 | unsigned int n; |
@@ -1467,7 +1469,7 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
1467 | strcpy(i->name, iname[INPUT(n)->type]); | 1469 | strcpy(i->name, iname[INPUT(n)->type]); |
1468 | 1470 | ||
1469 | if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) || | 1471 | if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) || |
1470 | (EM28XX_VMUX_CABLE == INPUT(n)->type)) | 1472 | (EM28XX_VMUX_CABLE == INPUT(n)->type)) |
1471 | i->type = V4L2_INPUT_TYPE_TUNER; | 1473 | i->type = V4L2_INPUT_TYPE_TUNER; |
1472 | 1474 | ||
1473 | i->std = dev->v4l2->vdev->tvnorms; | 1475 | i->std = dev->v4l2->vdev->tvnorms; |
@@ -1558,7 +1560,7 @@ static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio | |||
1558 | } | 1560 | } |
1559 | 1561 | ||
1560 | static int vidioc_g_tuner(struct file *file, void *priv, | 1562 | static int vidioc_g_tuner(struct file *file, void *priv, |
1561 | struct v4l2_tuner *t) | 1563 | struct v4l2_tuner *t) |
1562 | { | 1564 | { |
1563 | struct em28xx *dev = video_drvdata(file); | 1565 | struct em28xx *dev = video_drvdata(file); |
1564 | 1566 | ||
@@ -1572,7 +1574,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
1572 | } | 1574 | } |
1573 | 1575 | ||
1574 | static int vidioc_s_tuner(struct file *file, void *priv, | 1576 | static int vidioc_s_tuner(struct file *file, void *priv, |
1575 | const struct v4l2_tuner *t) | 1577 | const struct v4l2_tuner *t) |
1576 | { | 1578 | { |
1577 | struct em28xx *dev = video_drvdata(file); | 1579 | struct em28xx *dev = video_drvdata(file); |
1578 | 1580 | ||
@@ -1584,7 +1586,7 @@ static int vidioc_s_tuner(struct file *file, void *priv, | |||
1584 | } | 1586 | } |
1585 | 1587 | ||
1586 | static int vidioc_g_frequency(struct file *file, void *priv, | 1588 | static int vidioc_g_frequency(struct file *file, void *priv, |
1587 | struct v4l2_frequency *f) | 1589 | struct v4l2_frequency *f) |
1588 | { | 1590 | { |
1589 | struct em28xx *dev = video_drvdata(file); | 1591 | struct em28xx *dev = video_drvdata(file); |
1590 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 1592 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
@@ -1597,7 +1599,7 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
1597 | } | 1599 | } |
1598 | 1600 | ||
1599 | static int vidioc_s_frequency(struct file *file, void *priv, | 1601 | static int vidioc_s_frequency(struct file *file, void *priv, |
1600 | const struct v4l2_frequency *f) | 1602 | const struct v4l2_frequency *f) |
1601 | { | 1603 | { |
1602 | struct v4l2_frequency new_freq = *f; | 1604 | struct v4l2_frequency new_freq = *f; |
1603 | struct em28xx *dev = video_drvdata(file); | 1605 | struct em28xx *dev = video_drvdata(file); |
@@ -1615,7 +1617,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1615 | 1617 | ||
1616 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1618 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1617 | static int vidioc_g_chip_info(struct file *file, void *priv, | 1619 | static int vidioc_g_chip_info(struct file *file, void *priv, |
1618 | struct v4l2_dbg_chip_info *chip) | 1620 | struct v4l2_dbg_chip_info *chip) |
1619 | { | 1621 | { |
1620 | struct em28xx *dev = video_drvdata(file); | 1622 | struct em28xx *dev = video_drvdata(file); |
1621 | 1623 | ||
@@ -1670,6 +1672,7 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1670 | reg->val = ret; | 1672 | reg->val = ret; |
1671 | } else { | 1673 | } else { |
1672 | __le16 val = 0; | 1674 | __le16 val = 0; |
1675 | |||
1673 | ret = dev->em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, | 1676 | ret = dev->em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, |
1674 | reg->reg, (char *)&val, 2); | 1677 | reg->reg, (char *)&val, 2); |
1675 | if (ret < 0) | 1678 | if (ret < 0) |
@@ -1700,9 +1703,8 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
1700 | } | 1703 | } |
1701 | #endif | 1704 | #endif |
1702 | 1705 | ||
1703 | |||
1704 | static int vidioc_querycap(struct file *file, void *priv, | 1706 | static int vidioc_querycap(struct file *file, void *priv, |
1705 | struct v4l2_capability *cap) | 1707 | struct v4l2_capability *cap) |
1706 | { | 1708 | { |
1707 | struct video_device *vdev = video_devdata(file); | 1709 | struct video_device *vdev = video_devdata(file); |
1708 | struct em28xx *dev = video_drvdata(file); | 1710 | struct em28xx *dev = video_drvdata(file); |
@@ -1736,7 +1738,7 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
1736 | } | 1738 | } |
1737 | 1739 | ||
1738 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, | 1740 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, |
1739 | struct v4l2_fmtdesc *f) | 1741 | struct v4l2_fmtdesc *f) |
1740 | { | 1742 | { |
1741 | if (unlikely(f->index >= ARRAY_SIZE(format))) | 1743 | if (unlikely(f->index >= ARRAY_SIZE(format))) |
1742 | return -EINVAL; | 1744 | return -EINVAL; |
@@ -2177,9 +2179,10 @@ static unsigned short msp3400_addrs[] = { | |||
2177 | 2179 | ||
2178 | /******************************** usb interface ******************************/ | 2180 | /******************************** usb interface ******************************/ |
2179 | 2181 | ||
2180 | static struct video_device *em28xx_vdev_init(struct em28xx *dev, | 2182 | static struct video_device |
2181 | const struct video_device *template, | 2183 | *em28xx_vdev_init(struct em28xx *dev, |
2182 | const char *type_name) | 2184 | const struct video_device *template, |
2185 | const char *type_name) | ||
2183 | { | 2186 | { |
2184 | struct video_device *vfd; | 2187 | struct video_device *vfd; |
2185 | 2188 | ||
@@ -2344,21 +2347,24 @@ static int em28xx_v4l2_init(struct em28xx *dev) | |||
2344 | 2347 | ||
2345 | if (dev->board.radio.type) | 2348 | if (dev->board.radio.type) |
2346 | v4l2_i2c_new_subdev(&v4l2->v4l2_dev, | 2349 | v4l2_i2c_new_subdev(&v4l2->v4l2_dev, |
2347 | &dev->i2c_adap[dev->def_i2c_bus], | 2350 | &dev->i2c_adap[dev->def_i2c_bus], |
2348 | "tuner", dev->board.radio_addr, NULL); | 2351 | "tuner", dev->board.radio_addr, |
2352 | NULL); | ||
2349 | 2353 | ||
2350 | if (has_demod) | 2354 | if (has_demod) |
2351 | v4l2_i2c_new_subdev(&v4l2->v4l2_dev, | 2355 | v4l2_i2c_new_subdev(&v4l2->v4l2_dev, |
2352 | &dev->i2c_adap[dev->def_i2c_bus], "tuner", | 2356 | &dev->i2c_adap[dev->def_i2c_bus], |
2353 | 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | 2357 | "tuner", 0, |
2358 | v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
2354 | if (tuner_addr == 0) { | 2359 | if (tuner_addr == 0) { |
2355 | enum v4l2_i2c_tuner_type type = | 2360 | enum v4l2_i2c_tuner_type type = |
2356 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | 2361 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; |
2357 | struct v4l2_subdev *sd; | 2362 | struct v4l2_subdev *sd; |
2358 | 2363 | ||
2359 | sd = v4l2_i2c_new_subdev(&v4l2->v4l2_dev, | 2364 | sd = v4l2_i2c_new_subdev(&v4l2->v4l2_dev, |
2360 | &dev->i2c_adap[dev->def_i2c_bus], "tuner", | 2365 | &dev->i2c_adap[dev->def_i2c_bus], |
2361 | 0, v4l2_i2c_tuner_addrs(type)); | 2366 | "tuner", 0, |
2367 | v4l2_i2c_tuner_addrs(type)); | ||
2362 | 2368 | ||
2363 | if (sd) | 2369 | if (sd) |
2364 | tuner_addr = v4l2_i2c_subdev_addr(sd); | 2370 | tuner_addr = v4l2_i2c_subdev_addr(sd); |
@@ -2378,20 +2384,20 @@ static int em28xx_v4l2_init(struct em28xx *dev) | |||
2378 | ret = em28xx_audio_setup(dev); | 2384 | ret = em28xx_audio_setup(dev); |
2379 | if (ret < 0) { | 2385 | if (ret < 0) { |
2380 | em28xx_errdev("%s: Error while setting audio - error [%d]!\n", | 2386 | em28xx_errdev("%s: Error while setting audio - error [%d]!\n", |
2381 | __func__, ret); | 2387 | __func__, ret); |
2382 | goto unregister_dev; | 2388 | goto unregister_dev; |
2383 | } | 2389 | } |
2384 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | 2390 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { |
2385 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, | 2391 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, |
2386 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); | 2392 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); |
2387 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, | 2393 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, |
2388 | V4L2_CID_AUDIO_VOLUME, 0, 0x1f, 1, 0x1f); | 2394 | V4L2_CID_AUDIO_VOLUME, 0, 0x1f, 1, 0x1f); |
2389 | } else { | 2395 | } else { |
2390 | /* install the em28xx notify callback */ | 2396 | /* install the em28xx notify callback */ |
2391 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_MUTE), | 2397 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_MUTE), |
2392 | em28xx_ctrl_notify, dev); | 2398 | em28xx_ctrl_notify, dev); |
2393 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_VOLUME), | 2399 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_VOLUME), |
2394 | em28xx_ctrl_notify, dev); | 2400 | em28xx_ctrl_notify, dev); |
2395 | } | 2401 | } |
2396 | 2402 | ||
2397 | /* wake i2c devices */ | 2403 | /* wake i2c devices */ |
@@ -2518,7 +2524,7 @@ static int em28xx_v4l2_init(struct em28xx *dev) | |||
2518 | 2524 | ||
2519 | /* register v4l2 video video_device */ | 2525 | /* register v4l2 video video_device */ |
2520 | ret = video_register_device(v4l2->vdev, VFL_TYPE_GRABBER, | 2526 | ret = video_register_device(v4l2->vdev, VFL_TYPE_GRABBER, |
2521 | video_nr[dev->devno]); | 2527 | video_nr[dev->devno]); |
2522 | if (ret) { | 2528 | if (ret) { |
2523 | em28xx_errdev("unable to register video device (error=%i).\n", | 2529 | em28xx_errdev("unable to register video device (error=%i).\n", |
2524 | ret); | 2530 | ret); |
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index a21a7463b557..9c7075344109 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h | |||
@@ -141,6 +141,8 @@ | |||
141 | #define EM28178_BOARD_PCTV_461E 92 | 141 | #define EM28178_BOARD_PCTV_461E 92 |
142 | #define EM2874_BOARD_KWORLD_UB435Q_V3 93 | 142 | #define EM2874_BOARD_KWORLD_UB435Q_V3 93 |
143 | #define EM28178_BOARD_PCTV_292E 94 | 143 | #define EM28178_BOARD_PCTV_292E 94 |
144 | #define EM2861_BOARD_LEADTEK_VC100 95 | ||
145 | #define EM28178_BOARD_TERRATEC_T2_STICK_HD 96 | ||
144 | 146 | ||
145 | /* Limits minimum and default number of buffers */ | 147 | /* Limits minimum and default number of buffers */ |
146 | #define EM28XX_MIN_BUF 4 | 148 | #define EM28XX_MIN_BUF 4 |
@@ -215,7 +217,6 @@ enum em28xx_mode { | |||
215 | EM28XX_DIGITAL_MODE, | 217 | EM28XX_DIGITAL_MODE, |
216 | }; | 218 | }; |
217 | 219 | ||
218 | |||
219 | struct em28xx; | 220 | struct em28xx; |
220 | 221 | ||
221 | struct em28xx_usb_bufs { | 222 | struct em28xx_usb_bufs { |
@@ -243,11 +244,11 @@ struct em28xx_usb_ctl { | |||
243 | struct em28xx_usb_bufs digital_bufs; | 244 | struct em28xx_usb_bufs digital_bufs; |
244 | 245 | ||
245 | /* Stores already requested buffers */ | 246 | /* Stores already requested buffers */ |
246 | struct em28xx_buffer *vid_buf; | 247 | struct em28xx_buffer *vid_buf; |
247 | struct em28xx_buffer *vbi_buf; | 248 | struct em28xx_buffer *vbi_buf; |
248 | 249 | ||
249 | /* copy data from URB */ | 250 | /* copy data from URB */ |
250 | int (*urb_data_copy) (struct em28xx *dev, struct urb *urb); | 251 | int (*urb_data_copy)(struct em28xx *dev, struct urb *urb); |
251 | 252 | ||
252 | }; | 253 | }; |
253 | 254 | ||
@@ -695,14 +696,14 @@ struct em28xx { | |||
695 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ | 696 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ |
696 | 697 | ||
697 | /* helper funcs that call usb_control_msg */ | 698 | /* helper funcs that call usb_control_msg */ |
698 | int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, | 699 | int (*em28xx_write_regs)(struct em28xx *dev, u16 reg, |
699 | char *buf, int len); | 700 | char *buf, int len); |
700 | int (*em28xx_read_reg) (struct em28xx *dev, u16 reg); | 701 | int (*em28xx_read_reg)(struct em28xx *dev, u16 reg); |
701 | int (*em28xx_read_reg_req_len) (struct em28xx *dev, u8 req, u16 reg, | 702 | int (*em28xx_read_reg_req_len)(struct em28xx *dev, u8 req, u16 reg, |
702 | char *buf, int len); | 703 | char *buf, int len); |
703 | int (*em28xx_write_regs_req) (struct em28xx *dev, u8 req, u16 reg, | 704 | int (*em28xx_write_regs_req)(struct em28xx *dev, u8 req, u16 reg, |
704 | char *buf, int len); | 705 | char *buf, int len); |
705 | int (*em28xx_read_reg_req) (struct em28xx *dev, u8 req, u16 reg); | 706 | int (*em28xx_read_reg_req)(struct em28xx *dev, u8 req, u16 reg); |
706 | 707 | ||
707 | enum em28xx_mode mode; | 708 | enum em28xx_mode mode; |
708 | 709 | ||
@@ -745,7 +746,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
745 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); | 746 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); |
746 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); | 747 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); |
747 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | 748 | int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, |
748 | u8 bitmask); | 749 | u8 bitmask); |
749 | int em28xx_toggle_reg_bits(struct em28xx *dev, u16 reg, u8 bitmask); | 750 | int em28xx_toggle_reg_bits(struct em28xx *dev, u16 reg, u8 bitmask); |
750 | 751 | ||
751 | int em28xx_read_ac97(struct em28xx *dev, u8 reg); | 752 | int em28xx_read_ac97(struct em28xx *dev, u8 reg); |
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c b/drivers/media/usb/go7007/go7007-v4l2.c index ec799b4d88be..d6bf982efa42 100644 --- a/drivers/media/usb/go7007/go7007-v4l2.c +++ b/drivers/media/usb/go7007/go7007-v4l2.c | |||
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) | |||
252 | if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) { | 252 | if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) { |
253 | struct v4l2_mbus_framefmt mbus_fmt; | 253 | struct v4l2_mbus_framefmt mbus_fmt; |
254 | 254 | ||
255 | mbus_fmt.code = V4L2_MBUS_FMT_FIXED; | 255 | mbus_fmt.code = MEDIA_BUS_FMT_FIXED; |
256 | mbus_fmt.width = fmt ? fmt->fmt.pix.width : width; | 256 | mbus_fmt.width = fmt ? fmt->fmt.pix.width : width; |
257 | mbus_fmt.height = height; | 257 | mbus_fmt.height = height; |
258 | go->encoder_h_halve = 0; | 258 | go->encoder_h_halve = 0; |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c index 7c19ff72e6b3..c8761c71c9d2 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-context.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c | |||
@@ -80,7 +80,7 @@ static void pvr2_context_set_notify(struct pvr2_context *mp, int fl) | |||
80 | static void pvr2_context_destroy(struct pvr2_context *mp) | 80 | static void pvr2_context_destroy(struct pvr2_context *mp) |
81 | { | 81 | { |
82 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp); | 82 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp); |
83 | if (mp->hdw) pvr2_hdw_destroy(mp->hdw); | 83 | pvr2_hdw_destroy(mp->hdw); |
84 | pvr2_context_set_notify(mp, 0); | 84 | pvr2_context_set_notify(mp, 0); |
85 | mutex_lock(&pvr2_context_mutex); | 85 | mutex_lock(&pvr2_context_mutex); |
86 | if (mp->exist_next) { | 86 | if (mp->exist_next) { |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index 9623b6218214..2fd9b5e0e2a9 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c | |||
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) | |||
2966 | memset(&fmt, 0, sizeof(fmt)); | 2966 | memset(&fmt, 0, sizeof(fmt)); |
2967 | fmt.width = hdw->res_hor_val; | 2967 | fmt.width = hdw->res_hor_val; |
2968 | fmt.height = hdw->res_ver_val; | 2968 | fmt.height = hdw->res_ver_val; |
2969 | fmt.code = V4L2_MBUS_FMT_FIXED; | 2969 | fmt.code = MEDIA_BUS_FMT_FIXED; |
2970 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_size(%dx%d)", | 2970 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_size(%dx%d)", |
2971 | fmt.width, fmt.height); | 2971 | fmt.width, fmt.height); |
2972 | v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_mbus_fmt, &fmt); | 2972 | v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_mbus_fmt, &fmt); |
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 1c0dbf428a3a..de55e96fed15 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c | |||
@@ -558,27 +558,30 @@ static void s2255_fwchunk_complete(struct urb *urb) | |||
558 | 558 | ||
559 | } | 559 | } |
560 | 560 | ||
561 | static int s2255_got_frame(struct s2255_vc *vc, int jpgsize) | 561 | static void s2255_got_frame(struct s2255_vc *vc, int jpgsize) |
562 | { | 562 | { |
563 | struct s2255_buffer *buf; | 563 | struct s2255_buffer *buf; |
564 | struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); | 564 | struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); |
565 | unsigned long flags = 0; | 565 | unsigned long flags = 0; |
566 | int rc = 0; | 566 | |
567 | spin_lock_irqsave(&vc->qlock, flags); | 567 | spin_lock_irqsave(&vc->qlock, flags); |
568 | if (list_empty(&vc->buf_list)) { | 568 | if (list_empty(&vc->buf_list)) { |
569 | dprintk(dev, 1, "No active queue to serve\n"); | 569 | dprintk(dev, 1, "No active queue to serve\n"); |
570 | rc = -1; | 570 | spin_unlock_irqrestore(&vc->qlock, flags); |
571 | goto unlock; | 571 | return; |
572 | } | 572 | } |
573 | buf = list_entry(vc->buf_list.next, | 573 | buf = list_entry(vc->buf_list.next, |
574 | struct s2255_buffer, list); | 574 | struct s2255_buffer, list); |
575 | list_del(&buf->list); | 575 | list_del(&buf->list); |
576 | v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); | 576 | v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); |
577 | buf->vb.v4l2_buf.field = vc->field; | ||
578 | buf->vb.v4l2_buf.sequence = vc->frame_count; | ||
579 | spin_unlock_irqrestore(&vc->qlock, flags); | ||
580 | |||
577 | s2255_fillbuff(vc, buf, jpgsize); | 581 | s2255_fillbuff(vc, buf, jpgsize); |
582 | /* tell v4l buffer was filled */ | ||
583 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); | ||
578 | dprintk(dev, 2, "%s: [buf] [%p]\n", __func__, buf); | 584 | dprintk(dev, 2, "%s: [buf] [%p]\n", __func__, buf); |
579 | unlock: | ||
580 | spin_unlock_irqrestore(&vc->qlock, flags); | ||
581 | return rc; | ||
582 | } | 585 | } |
583 | 586 | ||
584 | static const struct s2255_fmt *format_by_fourcc(int fourcc) | 587 | static const struct s2255_fmt *format_by_fourcc(int fourcc) |
@@ -649,11 +652,6 @@ static void s2255_fillbuff(struct s2255_vc *vc, | |||
649 | } | 652 | } |
650 | dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n", | 653 | dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n", |
651 | (unsigned long)vbuf, pos); | 654 | (unsigned long)vbuf, pos); |
652 | /* tell v4l buffer was filled */ | ||
653 | buf->vb.v4l2_buf.field = vc->field; | ||
654 | buf->vb.v4l2_buf.sequence = vc->frame_count; | ||
655 | v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); | ||
656 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); | ||
657 | } | 655 | } |
658 | 656 | ||
659 | 657 | ||
@@ -1976,8 +1974,7 @@ static int s2255_release_sys_buffers(struct s2255_vc *vc) | |||
1976 | { | 1974 | { |
1977 | unsigned long i; | 1975 | unsigned long i; |
1978 | for (i = 0; i < SYS_FRAMES; i++) { | 1976 | for (i = 0; i < SYS_FRAMES; i++) { |
1979 | if (vc->buffer.frame[i].lpvbits) | 1977 | vfree(vc->buffer.frame[i].lpvbits); |
1980 | vfree(vc->buffer.frame[i].lpvbits); | ||
1981 | vc->buffer.frame[i].lpvbits = NULL; | 1978 | vc->buffer.frame[i].lpvbits = NULL; |
1982 | } | 1979 | } |
1983 | return 0; | 1980 | return 0; |
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c index 233054311a62..a47629108c1b 100644 --- a/drivers/media/usb/stk1160/stk1160-v4l.c +++ b/drivers/media/usb/stk1160/stk1160-v4l.c | |||
@@ -475,7 +475,7 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
475 | struct stk1160 *dev = video_drvdata(file); | 475 | struct stk1160 *dev = video_drvdata(file); |
476 | 476 | ||
477 | /* Match host */ | 477 | /* Match host */ |
478 | return stk1160_write_reg(dev, reg->reg, cpu_to_le16(reg->val)); | 478 | return stk1160_write_reg(dev, reg->reg, reg->val); |
479 | } | 479 | } |
480 | #endif | 480 | #endif |
481 | 481 | ||
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index 9bfa041e3316..693d5f409138 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c | |||
@@ -509,11 +509,12 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
509 | usbvision_device_data[usbvision->dev_model].model_string, | 509 | usbvision_device_data[usbvision->dev_model].model_string, |
510 | sizeof(vc->card)); | 510 | sizeof(vc->card)); |
511 | usb_make_path(usbvision->dev, vc->bus_info, sizeof(vc->bus_info)); | 511 | usb_make_path(usbvision->dev, vc->bus_info, sizeof(vc->bus_info)); |
512 | vc->capabilities = V4L2_CAP_VIDEO_CAPTURE | | 512 | vc->device_caps = V4L2_CAP_VIDEO_CAPTURE | |
513 | V4L2_CAP_AUDIO | | 513 | V4L2_CAP_AUDIO | |
514 | V4L2_CAP_READWRITE | | 514 | V4L2_CAP_READWRITE | |
515 | V4L2_CAP_STREAMING | | 515 | V4L2_CAP_STREAMING | |
516 | (usbvision->have_tuner ? V4L2_CAP_TUNER : 0); | 516 | (usbvision->have_tuner ? V4L2_CAP_TUNER : 0); |
517 | vc->capabilities = vc->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
517 | return 0; | 518 | return 0; |
518 | } | 519 | } |
519 | 520 | ||
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 7c8322d4fc63..6a4b0b8cd270 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c | |||
@@ -331,6 +331,7 @@ static int uvc_parse_format(struct uvc_device *dev, | |||
331 | struct uvc_format_desc *fmtdesc; | 331 | struct uvc_format_desc *fmtdesc; |
332 | struct uvc_frame *frame; | 332 | struct uvc_frame *frame; |
333 | const unsigned char *start = buffer; | 333 | const unsigned char *start = buffer; |
334 | unsigned int width_multiplier = 1; | ||
334 | unsigned int interval; | 335 | unsigned int interval; |
335 | unsigned int i, n; | 336 | unsigned int i, n; |
336 | __u8 ftype; | 337 | __u8 ftype; |
@@ -366,6 +367,20 @@ static int uvc_parse_format(struct uvc_device *dev, | |||
366 | } | 367 | } |
367 | 368 | ||
368 | format->bpp = buffer[21]; | 369 | format->bpp = buffer[21]; |
370 | |||
371 | /* Some devices report a format that doesn't match what they | ||
372 | * really send. | ||
373 | */ | ||
374 | if (dev->quirks & UVC_QUIRK_FORCE_Y8) { | ||
375 | if (format->fcc == V4L2_PIX_FMT_YUYV) { | ||
376 | strlcpy(format->name, "Greyscale 8-bit (Y8 )", | ||
377 | sizeof(format->name)); | ||
378 | format->fcc = V4L2_PIX_FMT_GREY; | ||
379 | format->bpp = 8; | ||
380 | width_multiplier = 2; | ||
381 | } | ||
382 | } | ||
383 | |||
369 | if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) { | 384 | if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) { |
370 | ftype = UVC_VS_FRAME_UNCOMPRESSED; | 385 | ftype = UVC_VS_FRAME_UNCOMPRESSED; |
371 | } else { | 386 | } else { |
@@ -474,7 +489,8 @@ static int uvc_parse_format(struct uvc_device *dev, | |||
474 | 489 | ||
475 | frame->bFrameIndex = buffer[3]; | 490 | frame->bFrameIndex = buffer[3]; |
476 | frame->bmCapabilities = buffer[4]; | 491 | frame->bmCapabilities = buffer[4]; |
477 | frame->wWidth = get_unaligned_le16(&buffer[5]); | 492 | frame->wWidth = get_unaligned_le16(&buffer[5]) |
493 | * width_multiplier; | ||
478 | frame->wHeight = get_unaligned_le16(&buffer[7]); | 494 | frame->wHeight = get_unaligned_le16(&buffer[7]); |
479 | frame->dwMinBitRate = get_unaligned_le32(&buffer[9]); | 495 | frame->dwMinBitRate = get_unaligned_le32(&buffer[9]); |
480 | frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]); | 496 | frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]); |
@@ -1623,12 +1639,12 @@ static void uvc_delete(struct uvc_device *dev) | |||
1623 | { | 1639 | { |
1624 | struct list_head *p, *n; | 1640 | struct list_head *p, *n; |
1625 | 1641 | ||
1626 | usb_put_intf(dev->intf); | ||
1627 | usb_put_dev(dev->udev); | ||
1628 | |||
1629 | uvc_status_cleanup(dev); | 1642 | uvc_status_cleanup(dev); |
1630 | uvc_ctrl_cleanup_device(dev); | 1643 | uvc_ctrl_cleanup_device(dev); |
1631 | 1644 | ||
1645 | usb_put_intf(dev->intf); | ||
1646 | usb_put_dev(dev->udev); | ||
1647 | |||
1632 | if (dev->vdev.dev) | 1648 | if (dev->vdev.dev) |
1633 | v4l2_device_unregister(&dev->vdev); | 1649 | v4l2_device_unregister(&dev->vdev); |
1634 | #ifdef CONFIG_MEDIA_CONTROLLER | 1650 | #ifdef CONFIG_MEDIA_CONTROLLER |
@@ -1718,6 +1734,11 @@ static int uvc_register_video(struct uvc_device *dev, | |||
1718 | struct video_device *vdev; | 1734 | struct video_device *vdev; |
1719 | int ret; | 1735 | int ret; |
1720 | 1736 | ||
1737 | /* Initialize the video buffers queue. */ | ||
1738 | ret = uvc_queue_init(&stream->queue, stream->type, !uvc_no_drop_param); | ||
1739 | if (ret) | ||
1740 | return ret; | ||
1741 | |||
1721 | /* Initialize the streaming interface with default streaming | 1742 | /* Initialize the streaming interface with default streaming |
1722 | * parameters. | 1743 | * parameters. |
1723 | */ | 1744 | */ |
@@ -1744,6 +1765,7 @@ static int uvc_register_video(struct uvc_device *dev, | |||
1744 | */ | 1765 | */ |
1745 | vdev->v4l2_dev = &dev->vdev; | 1766 | vdev->v4l2_dev = &dev->vdev; |
1746 | vdev->fops = &uvc_fops; | 1767 | vdev->fops = &uvc_fops; |
1768 | vdev->ioctl_ops = &uvc_ioctl_ops; | ||
1747 | vdev->release = uvc_release; | 1769 | vdev->release = uvc_release; |
1748 | vdev->prio = &stream->chain->prio; | 1770 | vdev->prio = &stream->chain->prio; |
1749 | if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) | 1771 | if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) |
@@ -1991,14 +2013,13 @@ static int __uvc_resume(struct usb_interface *intf, int reset) | |||
1991 | { | 2013 | { |
1992 | struct uvc_device *dev = usb_get_intfdata(intf); | 2014 | struct uvc_device *dev = usb_get_intfdata(intf); |
1993 | struct uvc_streaming *stream; | 2015 | struct uvc_streaming *stream; |
2016 | int ret = 0; | ||
1994 | 2017 | ||
1995 | uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", | 2018 | uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", |
1996 | intf->cur_altsetting->desc.bInterfaceNumber); | 2019 | intf->cur_altsetting->desc.bInterfaceNumber); |
1997 | 2020 | ||
1998 | if (intf->cur_altsetting->desc.bInterfaceSubClass == | 2021 | if (intf->cur_altsetting->desc.bInterfaceSubClass == |
1999 | UVC_SC_VIDEOCONTROL) { | 2022 | UVC_SC_VIDEOCONTROL) { |
2000 | int ret = 0; | ||
2001 | |||
2002 | if (reset) { | 2023 | if (reset) { |
2003 | ret = uvc_ctrl_restore_values(dev); | 2024 | ret = uvc_ctrl_restore_values(dev); |
2004 | if (ret < 0) | 2025 | if (ret < 0) |
@@ -2014,8 +2035,13 @@ static int __uvc_resume(struct usb_interface *intf, int reset) | |||
2014 | } | 2035 | } |
2015 | 2036 | ||
2016 | list_for_each_entry(stream, &dev->streams, list) { | 2037 | list_for_each_entry(stream, &dev->streams, list) { |
2017 | if (stream->intf == intf) | 2038 | if (stream->intf == intf) { |
2018 | return uvc_video_resume(stream, reset); | 2039 | ret = uvc_video_resume(stream, reset); |
2040 | if (ret < 0) | ||
2041 | uvc_queue_streamoff(&stream->queue, | ||
2042 | stream->queue.queue.type); | ||
2043 | return ret; | ||
2044 | } | ||
2019 | } | 2045 | } |
2020 | 2046 | ||
2021 | uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface " | 2047 | uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface " |
@@ -2504,6 +2530,15 @@ static struct usb_device_id uvc_ids[] = { | |||
2504 | .bInterfaceProtocol = 0, | 2530 | .bInterfaceProtocol = 0, |
2505 | .driver_info = UVC_QUIRK_PROBE_MINMAX | 2531 | .driver_info = UVC_QUIRK_PROBE_MINMAX |
2506 | | UVC_QUIRK_IGNORE_SELECTOR_UNIT }, | 2532 | | UVC_QUIRK_IGNORE_SELECTOR_UNIT }, |
2533 | /* Oculus VR Positional Tracker DK2 */ | ||
2534 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
2535 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
2536 | .idVendor = 0x2833, | ||
2537 | .idProduct = 0x0201, | ||
2538 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
2539 | .bInterfaceSubClass = 1, | ||
2540 | .bInterfaceProtocol = 0, | ||
2541 | .driver_info = UVC_QUIRK_FORCE_Y8 }, | ||
2507 | /* Generic USB Video Class */ | 2542 | /* Generic USB Video Class */ |
2508 | { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) }, | 2543 | { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) }, |
2509 | {} | 2544 | {} |
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index 6e92d2080255..cc960723b926 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c | |||
@@ -36,6 +36,34 @@ | |||
36 | * the driver. | 36 | * the driver. |
37 | */ | 37 | */ |
38 | 38 | ||
39 | static inline struct uvc_streaming * | ||
40 | uvc_queue_to_stream(struct uvc_video_queue *queue) | ||
41 | { | ||
42 | return container_of(queue, struct uvc_streaming, queue); | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | * Return all queued buffers to videobuf2 in the requested state. | ||
47 | * | ||
48 | * This function must be called with the queue spinlock held. | ||
49 | */ | ||
50 | static void uvc_queue_return_buffers(struct uvc_video_queue *queue, | ||
51 | enum uvc_buffer_state state) | ||
52 | { | ||
53 | enum vb2_buffer_state vb2_state = state == UVC_BUF_STATE_ERROR | ||
54 | ? VB2_BUF_STATE_ERROR | ||
55 | : VB2_BUF_STATE_QUEUED; | ||
56 | |||
57 | while (!list_empty(&queue->irqqueue)) { | ||
58 | struct uvc_buffer *buf = list_first_entry(&queue->irqqueue, | ||
59 | struct uvc_buffer, | ||
60 | queue); | ||
61 | list_del(&buf->queue); | ||
62 | buf->state = state; | ||
63 | vb2_buffer_done(&buf->buf, vb2_state); | ||
64 | } | ||
65 | } | ||
66 | |||
39 | /* ----------------------------------------------------------------------------- | 67 | /* ----------------------------------------------------------------------------- |
40 | * videobuf2 queue operations | 68 | * videobuf2 queue operations |
41 | */ | 69 | */ |
@@ -45,8 +73,7 @@ static int uvc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
45 | unsigned int sizes[], void *alloc_ctxs[]) | 73 | unsigned int sizes[], void *alloc_ctxs[]) |
46 | { | 74 | { |
47 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); | 75 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); |
48 | struct uvc_streaming *stream = | 76 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); |
49 | container_of(queue, struct uvc_streaming, queue); | ||
50 | 77 | ||
51 | /* Make sure the image size is large enough. */ | 78 | /* Make sure the image size is large enough. */ |
52 | if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize) | 79 | if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize) |
@@ -109,8 +136,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb) | |||
109 | static void uvc_buffer_finish(struct vb2_buffer *vb) | 136 | static void uvc_buffer_finish(struct vb2_buffer *vb) |
110 | { | 137 | { |
111 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 138 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
112 | struct uvc_streaming *stream = | 139 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); |
113 | container_of(queue, struct uvc_streaming, queue); | ||
114 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); | 140 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); |
115 | 141 | ||
116 | if (vb->state == VB2_BUF_STATE_DONE) | 142 | if (vb->state == VB2_BUF_STATE_DONE) |
@@ -131,6 +157,39 @@ static void uvc_wait_finish(struct vb2_queue *vq) | |||
131 | mutex_lock(&queue->mutex); | 157 | mutex_lock(&queue->mutex); |
132 | } | 158 | } |
133 | 159 | ||
160 | static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) | ||
161 | { | ||
162 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); | ||
163 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); | ||
164 | unsigned long flags; | ||
165 | int ret; | ||
166 | |||
167 | queue->buf_used = 0; | ||
168 | |||
169 | ret = uvc_video_enable(stream, 1); | ||
170 | if (ret == 0) | ||
171 | return 0; | ||
172 | |||
173 | spin_lock_irqsave(&queue->irqlock, flags); | ||
174 | uvc_queue_return_buffers(queue, UVC_BUF_STATE_QUEUED); | ||
175 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
176 | |||
177 | return ret; | ||
178 | } | ||
179 | |||
180 | static void uvc_stop_streaming(struct vb2_queue *vq) | ||
181 | { | ||
182 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); | ||
183 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); | ||
184 | unsigned long flags; | ||
185 | |||
186 | uvc_video_enable(stream, 0); | ||
187 | |||
188 | spin_lock_irqsave(&queue->irqlock, flags); | ||
189 | uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); | ||
190 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
191 | } | ||
192 | |||
134 | static struct vb2_ops uvc_queue_qops = { | 193 | static struct vb2_ops uvc_queue_qops = { |
135 | .queue_setup = uvc_queue_setup, | 194 | .queue_setup = uvc_queue_setup, |
136 | .buf_prepare = uvc_buffer_prepare, | 195 | .buf_prepare = uvc_buffer_prepare, |
@@ -138,6 +197,8 @@ static struct vb2_ops uvc_queue_qops = { | |||
138 | .buf_finish = uvc_buffer_finish, | 197 | .buf_finish = uvc_buffer_finish, |
139 | .wait_prepare = uvc_wait_prepare, | 198 | .wait_prepare = uvc_wait_prepare, |
140 | .wait_finish = uvc_wait_finish, | 199 | .wait_finish = uvc_wait_finish, |
200 | .start_streaming = uvc_start_streaming, | ||
201 | .stop_streaming = uvc_stop_streaming, | ||
141 | }; | 202 | }; |
142 | 203 | ||
143 | int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, | 204 | int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, |
@@ -165,12 +226,19 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, | |||
165 | return 0; | 226 | return 0; |
166 | } | 227 | } |
167 | 228 | ||
229 | void uvc_queue_release(struct uvc_video_queue *queue) | ||
230 | { | ||
231 | mutex_lock(&queue->mutex); | ||
232 | vb2_queue_release(&queue->queue); | ||
233 | mutex_unlock(&queue->mutex); | ||
234 | } | ||
235 | |||
168 | /* ----------------------------------------------------------------------------- | 236 | /* ----------------------------------------------------------------------------- |
169 | * V4L2 queue operations | 237 | * V4L2 queue operations |
170 | */ | 238 | */ |
171 | 239 | ||
172 | int uvc_alloc_buffers(struct uvc_video_queue *queue, | 240 | int uvc_request_buffers(struct uvc_video_queue *queue, |
173 | struct v4l2_requestbuffers *rb) | 241 | struct v4l2_requestbuffers *rb) |
174 | { | 242 | { |
175 | int ret; | 243 | int ret; |
176 | 244 | ||
@@ -181,13 +249,6 @@ int uvc_alloc_buffers(struct uvc_video_queue *queue, | |||
181 | return ret ? ret : rb->count; | 249 | return ret ? ret : rb->count; |
182 | } | 250 | } |
183 | 251 | ||
184 | void uvc_free_buffers(struct uvc_video_queue *queue) | ||
185 | { | ||
186 | mutex_lock(&queue->mutex); | ||
187 | vb2_queue_release(&queue->queue); | ||
188 | mutex_unlock(&queue->mutex); | ||
189 | } | ||
190 | |||
191 | int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) | 252 | int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) |
192 | { | 253 | { |
193 | int ret; | 254 | int ret; |
@@ -234,6 +295,28 @@ int uvc_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf, | |||
234 | return ret; | 295 | return ret; |
235 | } | 296 | } |
236 | 297 | ||
298 | int uvc_queue_streamon(struct uvc_video_queue *queue, enum v4l2_buf_type type) | ||
299 | { | ||
300 | int ret; | ||
301 | |||
302 | mutex_lock(&queue->mutex); | ||
303 | ret = vb2_streamon(&queue->queue, type); | ||
304 | mutex_unlock(&queue->mutex); | ||
305 | |||
306 | return ret; | ||
307 | } | ||
308 | |||
309 | int uvc_queue_streamoff(struct uvc_video_queue *queue, enum v4l2_buf_type type) | ||
310 | { | ||
311 | int ret; | ||
312 | |||
313 | mutex_lock(&queue->mutex); | ||
314 | ret = vb2_streamoff(&queue->queue, type); | ||
315 | mutex_unlock(&queue->mutex); | ||
316 | |||
317 | return ret; | ||
318 | } | ||
319 | |||
237 | int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) | 320 | int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) |
238 | { | 321 | { |
239 | int ret; | 322 | int ret; |
@@ -289,49 +372,6 @@ int uvc_queue_allocated(struct uvc_video_queue *queue) | |||
289 | } | 372 | } |
290 | 373 | ||
291 | /* | 374 | /* |
292 | * Enable or disable the video buffers queue. | ||
293 | * | ||
294 | * The queue must be enabled before starting video acquisition and must be | ||
295 | * disabled after stopping it. This ensures that the video buffers queue | ||
296 | * state can be properly initialized before buffers are accessed from the | ||
297 | * interrupt handler. | ||
298 | * | ||
299 | * Enabling the video queue returns -EBUSY if the queue is already enabled. | ||
300 | * | ||
301 | * Disabling the video queue cancels the queue and removes all buffers from | ||
302 | * the main queue. | ||
303 | * | ||
304 | * This function can't be called from interrupt context. Use | ||
305 | * uvc_queue_cancel() instead. | ||
306 | */ | ||
307 | int uvc_queue_enable(struct uvc_video_queue *queue, int enable) | ||
308 | { | ||
309 | unsigned long flags; | ||
310 | int ret; | ||
311 | |||
312 | mutex_lock(&queue->mutex); | ||
313 | if (enable) { | ||
314 | ret = vb2_streamon(&queue->queue, queue->queue.type); | ||
315 | if (ret < 0) | ||
316 | goto done; | ||
317 | |||
318 | queue->buf_used = 0; | ||
319 | } else { | ||
320 | ret = vb2_streamoff(&queue->queue, queue->queue.type); | ||
321 | if (ret < 0) | ||
322 | goto done; | ||
323 | |||
324 | spin_lock_irqsave(&queue->irqlock, flags); | ||
325 | INIT_LIST_HEAD(&queue->irqqueue); | ||
326 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
327 | } | ||
328 | |||
329 | done: | ||
330 | mutex_unlock(&queue->mutex); | ||
331 | return ret; | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * Cancel the video buffers queue. | 375 | * Cancel the video buffers queue. |
336 | * | 376 | * |
337 | * Cancelling the queue marks all buffers on the irq queue as erroneous, | 377 | * Cancelling the queue marks all buffers on the irq queue as erroneous, |
@@ -345,17 +385,10 @@ done: | |||
345 | */ | 385 | */ |
346 | void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect) | 386 | void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect) |
347 | { | 387 | { |
348 | struct uvc_buffer *buf; | ||
349 | unsigned long flags; | 388 | unsigned long flags; |
350 | 389 | ||
351 | spin_lock_irqsave(&queue->irqlock, flags); | 390 | spin_lock_irqsave(&queue->irqlock, flags); |
352 | while (!list_empty(&queue->irqqueue)) { | 391 | uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); |
353 | buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, | ||
354 | queue); | ||
355 | list_del(&buf->queue); | ||
356 | buf->state = UVC_BUF_STATE_ERROR; | ||
357 | vb2_buffer_done(&buf->buf, VB2_BUF_STATE_ERROR); | ||
358 | } | ||
359 | /* This must be protected by the irqlock spinlock to avoid race | 392 | /* This must be protected by the irqlock spinlock to avoid race |
360 | * conditions between uvc_buffer_queue and the disconnection event that | 393 | * conditions between uvc_buffer_queue and the disconnection event that |
361 | * could result in an interruptible wait in uvc_dequeue_buffer. Do not | 394 | * could result in an interruptible wait in uvc_dequeue_buffer. Do not |
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 378ae02e593b..9c5cbcf16529 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c | |||
@@ -530,10 +530,8 @@ static int uvc_v4l2_release(struct file *file) | |||
530 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n"); | 530 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n"); |
531 | 531 | ||
532 | /* Only free resources if this is a privileged handle. */ | 532 | /* Only free resources if this is a privileged handle. */ |
533 | if (uvc_has_privileges(handle)) { | 533 | if (uvc_has_privileges(handle)) |
534 | uvc_video_enable(stream, 0); | 534 | uvc_queue_release(&stream->queue); |
535 | uvc_free_buffers(&stream->queue); | ||
536 | } | ||
537 | 535 | ||
538 | /* Release the file handle. */ | 536 | /* Release the file handle. */ |
539 | uvc_dismiss_privileges(handle); | 537 | uvc_dismiss_privileges(handle); |
@@ -551,553 +549,628 @@ static int uvc_v4l2_release(struct file *file) | |||
551 | return 0; | 549 | return 0; |
552 | } | 550 | } |
553 | 551 | ||
554 | static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 552 | static int uvc_ioctl_querycap(struct file *file, void *fh, |
553 | struct v4l2_capability *cap) | ||
555 | { | 554 | { |
556 | struct video_device *vdev = video_devdata(file); | 555 | struct video_device *vdev = video_devdata(file); |
557 | struct uvc_fh *handle = file->private_data; | 556 | struct uvc_fh *handle = file->private_data; |
558 | struct uvc_video_chain *chain = handle->chain; | 557 | struct uvc_video_chain *chain = handle->chain; |
559 | struct uvc_streaming *stream = handle->stream; | 558 | struct uvc_streaming *stream = handle->stream; |
560 | long ret = 0; | ||
561 | 559 | ||
562 | switch (cmd) { | 560 | strlcpy(cap->driver, "uvcvideo", sizeof(cap->driver)); |
563 | /* Query capabilities */ | 561 | strlcpy(cap->card, vdev->name, sizeof(cap->card)); |
564 | case VIDIOC_QUERYCAP: | 562 | usb_make_path(stream->dev->udev, cap->bus_info, sizeof(cap->bus_info)); |
565 | { | 563 | cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING |
566 | struct v4l2_capability *cap = arg; | 564 | | chain->caps; |
567 | 565 | if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | |
568 | memset(cap, 0, sizeof *cap); | 566 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; |
569 | strlcpy(cap->driver, "uvcvideo", sizeof cap->driver); | 567 | else |
570 | strlcpy(cap->card, vdev->name, sizeof cap->card); | 568 | cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; |
571 | usb_make_path(stream->dev->udev, | ||
572 | cap->bus_info, sizeof(cap->bus_info)); | ||
573 | cap->version = LINUX_VERSION_CODE; | ||
574 | cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING | ||
575 | | chain->caps; | ||
576 | if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
577 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | ||
578 | | V4L2_CAP_STREAMING; | ||
579 | else | ||
580 | cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | ||
581 | | V4L2_CAP_STREAMING; | ||
582 | break; | ||
583 | } | ||
584 | 569 | ||
585 | /* Priority */ | 570 | return 0; |
586 | case VIDIOC_G_PRIORITY: | 571 | } |
587 | *(u32 *)arg = v4l2_prio_max(vdev->prio); | ||
588 | break; | ||
589 | 572 | ||
590 | case VIDIOC_S_PRIORITY: | 573 | static int uvc_ioctl_enum_fmt(struct uvc_streaming *stream, |
591 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 574 | struct v4l2_fmtdesc *fmt) |
592 | if (ret < 0) | 575 | { |
593 | return ret; | 576 | struct uvc_format *format; |
577 | enum v4l2_buf_type type = fmt->type; | ||
578 | __u32 index = fmt->index; | ||
594 | 579 | ||
595 | return v4l2_prio_change(vdev->prio, &handle->vfh.prio, | 580 | if (fmt->type != stream->type || fmt->index >= stream->nformats) |
596 | *(u32 *)arg); | 581 | return -EINVAL; |
597 | 582 | ||
598 | /* Get, Set & Query control */ | 583 | memset(fmt, 0, sizeof(*fmt)); |
599 | case VIDIOC_QUERYCTRL: | 584 | fmt->index = index; |
600 | return uvc_query_v4l2_ctrl(chain, arg); | 585 | fmt->type = type; |
586 | |||
587 | format = &stream->format[fmt->index]; | ||
588 | fmt->flags = 0; | ||
589 | if (format->flags & UVC_FMT_FLAG_COMPRESSED) | ||
590 | fmt->flags |= V4L2_FMT_FLAG_COMPRESSED; | ||
591 | strlcpy(fmt->description, format->name, sizeof(fmt->description)); | ||
592 | fmt->description[sizeof(fmt->description) - 1] = 0; | ||
593 | fmt->pixelformat = format->fcc; | ||
594 | return 0; | ||
595 | } | ||
601 | 596 | ||
602 | case VIDIOC_G_CTRL: | 597 | static int uvc_ioctl_enum_fmt_vid_cap(struct file *file, void *fh, |
603 | { | 598 | struct v4l2_fmtdesc *fmt) |
604 | struct v4l2_control *ctrl = arg; | 599 | { |
605 | struct v4l2_ext_control xctrl; | 600 | struct uvc_fh *handle = fh; |
601 | struct uvc_streaming *stream = handle->stream; | ||
606 | 602 | ||
607 | memset(&xctrl, 0, sizeof xctrl); | 603 | return uvc_ioctl_enum_fmt(stream, fmt); |
608 | xctrl.id = ctrl->id; | 604 | } |
609 | 605 | ||
610 | ret = uvc_ctrl_begin(chain); | 606 | static int uvc_ioctl_enum_fmt_vid_out(struct file *file, void *fh, |
611 | if (ret < 0) | 607 | struct v4l2_fmtdesc *fmt) |
612 | return ret; | 608 | { |
609 | struct uvc_fh *handle = fh; | ||
610 | struct uvc_streaming *stream = handle->stream; | ||
613 | 611 | ||
614 | ret = uvc_ctrl_get(chain, &xctrl); | 612 | return uvc_ioctl_enum_fmt(stream, fmt); |
615 | uvc_ctrl_rollback(handle); | 613 | } |
616 | if (ret >= 0) | ||
617 | ctrl->value = xctrl.value; | ||
618 | break; | ||
619 | } | ||
620 | 614 | ||
621 | case VIDIOC_S_CTRL: | 615 | static int uvc_ioctl_g_fmt_vid_cap(struct file *file, void *fh, |
622 | { | 616 | struct v4l2_format *fmt) |
623 | struct v4l2_control *ctrl = arg; | 617 | { |
624 | struct v4l2_ext_control xctrl; | 618 | struct uvc_fh *handle = fh; |
619 | struct uvc_streaming *stream = handle->stream; | ||
625 | 620 | ||
626 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 621 | return uvc_v4l2_get_format(stream, fmt); |
627 | if (ret < 0) | 622 | } |
628 | return ret; | ||
629 | 623 | ||
630 | memset(&xctrl, 0, sizeof xctrl); | 624 | static int uvc_ioctl_g_fmt_vid_out(struct file *file, void *fh, |
631 | xctrl.id = ctrl->id; | 625 | struct v4l2_format *fmt) |
632 | xctrl.value = ctrl->value; | 626 | { |
627 | struct uvc_fh *handle = fh; | ||
628 | struct uvc_streaming *stream = handle->stream; | ||
633 | 629 | ||
634 | ret = uvc_ctrl_begin(chain); | 630 | return uvc_v4l2_get_format(stream, fmt); |
635 | if (ret < 0) | 631 | } |
636 | return ret; | ||
637 | 632 | ||
638 | ret = uvc_ctrl_set(chain, &xctrl); | 633 | static int uvc_ioctl_s_fmt_vid_cap(struct file *file, void *fh, |
639 | if (ret < 0) { | 634 | struct v4l2_format *fmt) |
640 | uvc_ctrl_rollback(handle); | 635 | { |
641 | return ret; | 636 | struct uvc_fh *handle = fh; |
642 | } | 637 | struct uvc_streaming *stream = handle->stream; |
643 | ret = uvc_ctrl_commit(handle, &xctrl, 1); | 638 | int ret; |
644 | if (ret == 0) | ||
645 | ctrl->value = xctrl.value; | ||
646 | break; | ||
647 | } | ||
648 | 639 | ||
649 | case VIDIOC_QUERYMENU: | 640 | ret = uvc_acquire_privileges(handle); |
650 | return uvc_query_v4l2_menu(chain, arg); | 641 | if (ret < 0) |
642 | return ret; | ||
651 | 643 | ||
652 | case VIDIOC_G_EXT_CTRLS: | 644 | return uvc_v4l2_set_format(stream, fmt); |
653 | { | 645 | } |
654 | struct v4l2_ext_controls *ctrls = arg; | ||
655 | struct v4l2_ext_control *ctrl = ctrls->controls; | ||
656 | unsigned int i; | ||
657 | 646 | ||
658 | ret = uvc_ctrl_begin(chain); | 647 | static int uvc_ioctl_s_fmt_vid_out(struct file *file, void *fh, |
659 | if (ret < 0) | 648 | struct v4l2_format *fmt) |
660 | return ret; | 649 | { |
650 | struct uvc_fh *handle = fh; | ||
651 | struct uvc_streaming *stream = handle->stream; | ||
652 | int ret; | ||
661 | 653 | ||
662 | for (i = 0; i < ctrls->count; ++ctrl, ++i) { | 654 | ret = uvc_acquire_privileges(handle); |
663 | ret = uvc_ctrl_get(chain, ctrl); | 655 | if (ret < 0) |
664 | if (ret < 0) { | 656 | return ret; |
665 | uvc_ctrl_rollback(handle); | ||
666 | ctrls->error_idx = i; | ||
667 | return ret; | ||
668 | } | ||
669 | } | ||
670 | ctrls->error_idx = 0; | ||
671 | ret = uvc_ctrl_rollback(handle); | ||
672 | break; | ||
673 | } | ||
674 | 657 | ||
675 | case VIDIOC_S_EXT_CTRLS: | 658 | return uvc_v4l2_set_format(stream, fmt); |
676 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 659 | } |
677 | if (ret < 0) | ||
678 | return ret; | ||
679 | /* Fall through */ | ||
680 | case VIDIOC_TRY_EXT_CTRLS: | ||
681 | { | ||
682 | struct v4l2_ext_controls *ctrls = arg; | ||
683 | struct v4l2_ext_control *ctrl = ctrls->controls; | ||
684 | unsigned int i; | ||
685 | |||
686 | ret = uvc_ctrl_begin(chain); | ||
687 | if (ret < 0) | ||
688 | return ret; | ||
689 | 660 | ||
690 | for (i = 0; i < ctrls->count; ++ctrl, ++i) { | 661 | static int uvc_ioctl_try_fmt_vid_cap(struct file *file, void *fh, |
691 | ret = uvc_ctrl_set(chain, ctrl); | 662 | struct v4l2_format *fmt) |
692 | if (ret < 0) { | 663 | { |
693 | uvc_ctrl_rollback(handle); | 664 | struct uvc_fh *handle = fh; |
694 | ctrls->error_idx = cmd == VIDIOC_S_EXT_CTRLS | 665 | struct uvc_streaming *stream = handle->stream; |
695 | ? ctrls->count : i; | 666 | struct uvc_streaming_control probe; |
696 | return ret; | ||
697 | } | ||
698 | } | ||
699 | 667 | ||
700 | ctrls->error_idx = 0; | 668 | return uvc_v4l2_try_format(stream, fmt, &probe, NULL, NULL); |
669 | } | ||
701 | 670 | ||
702 | if (cmd == VIDIOC_S_EXT_CTRLS) | 671 | static int uvc_ioctl_try_fmt_vid_out(struct file *file, void *fh, |
703 | ret = uvc_ctrl_commit(handle, | 672 | struct v4l2_format *fmt) |
704 | ctrls->controls, ctrls->count); | 673 | { |
705 | else | 674 | struct uvc_fh *handle = fh; |
706 | ret = uvc_ctrl_rollback(handle); | 675 | struct uvc_streaming *stream = handle->stream; |
707 | break; | 676 | struct uvc_streaming_control probe; |
708 | } | ||
709 | 677 | ||
710 | /* Get, Set & Enum input */ | 678 | return uvc_v4l2_try_format(stream, fmt, &probe, NULL, NULL); |
711 | case VIDIOC_ENUMINPUT: | 679 | } |
712 | { | ||
713 | const struct uvc_entity *selector = chain->selector; | ||
714 | struct v4l2_input *input = arg; | ||
715 | struct uvc_entity *iterm = NULL; | ||
716 | u32 index = input->index; | ||
717 | int pin = 0; | ||
718 | |||
719 | if (selector == NULL || | ||
720 | (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { | ||
721 | if (index != 0) | ||
722 | return -EINVAL; | ||
723 | list_for_each_entry(iterm, &chain->entities, chain) { | ||
724 | if (UVC_ENTITY_IS_ITERM(iterm)) | ||
725 | break; | ||
726 | } | ||
727 | pin = iterm->id; | ||
728 | } else if (index < selector->bNrInPins) { | ||
729 | pin = selector->baSourceID[index]; | ||
730 | list_for_each_entry(iterm, &chain->entities, chain) { | ||
731 | if (!UVC_ENTITY_IS_ITERM(iterm)) | ||
732 | continue; | ||
733 | if (iterm->id == pin) | ||
734 | break; | ||
735 | } | ||
736 | } | ||
737 | 680 | ||
738 | if (iterm == NULL || iterm->id != pin) | 681 | static int uvc_ioctl_reqbufs(struct file *file, void *fh, |
739 | return -EINVAL; | 682 | struct v4l2_requestbuffers *rb) |
683 | { | ||
684 | struct uvc_fh *handle = fh; | ||
685 | struct uvc_streaming *stream = handle->stream; | ||
686 | int ret; | ||
740 | 687 | ||
741 | memset(input, 0, sizeof *input); | 688 | ret = uvc_acquire_privileges(handle); |
742 | input->index = index; | 689 | if (ret < 0) |
743 | strlcpy(input->name, iterm->name, sizeof input->name); | 690 | return ret; |
744 | if (UVC_ENTITY_TYPE(iterm) == UVC_ITT_CAMERA) | ||
745 | input->type = V4L2_INPUT_TYPE_CAMERA; | ||
746 | break; | ||
747 | } | ||
748 | 691 | ||
749 | case VIDIOC_G_INPUT: | 692 | mutex_lock(&stream->mutex); |
750 | { | 693 | ret = uvc_request_buffers(&stream->queue, rb); |
751 | u8 input; | 694 | mutex_unlock(&stream->mutex); |
695 | if (ret < 0) | ||
696 | return ret; | ||
752 | 697 | ||
753 | if (chain->selector == NULL || | 698 | if (ret == 0) |
754 | (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { | 699 | uvc_dismiss_privileges(handle); |
755 | *(int *)arg = 0; | ||
756 | break; | ||
757 | } | ||
758 | 700 | ||
759 | ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, | 701 | return 0; |
760 | chain->selector->id, chain->dev->intfnum, | 702 | } |
761 | UVC_SU_INPUT_SELECT_CONTROL, &input, 1); | ||
762 | if (ret < 0) | ||
763 | return ret; | ||
764 | 703 | ||
765 | *(int *)arg = input - 1; | 704 | static int uvc_ioctl_querybuf(struct file *file, void *fh, |
766 | break; | 705 | struct v4l2_buffer *buf) |
767 | } | 706 | { |
707 | struct uvc_fh *handle = fh; | ||
708 | struct uvc_streaming *stream = handle->stream; | ||
768 | 709 | ||
769 | case VIDIOC_S_INPUT: | 710 | if (!uvc_has_privileges(handle)) |
770 | { | 711 | return -EBUSY; |
771 | u32 input = *(u32 *)arg + 1; | ||
772 | 712 | ||
773 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 713 | return uvc_query_buffer(&stream->queue, buf); |
774 | if (ret < 0) | 714 | } |
775 | return ret; | ||
776 | 715 | ||
777 | if ((ret = uvc_acquire_privileges(handle)) < 0) | 716 | static int uvc_ioctl_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) |
778 | return ret; | 717 | { |
718 | struct uvc_fh *handle = fh; | ||
719 | struct uvc_streaming *stream = handle->stream; | ||
779 | 720 | ||
780 | if (chain->selector == NULL || | 721 | if (!uvc_has_privileges(handle)) |
781 | (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { | 722 | return -EBUSY; |
782 | if (input != 1) | ||
783 | return -EINVAL; | ||
784 | break; | ||
785 | } | ||
786 | 723 | ||
787 | if (input == 0 || input > chain->selector->bNrInPins) | 724 | return uvc_queue_buffer(&stream->queue, buf); |
788 | return -EINVAL; | 725 | } |
789 | 726 | ||
790 | return uvc_query_ctrl(chain->dev, UVC_SET_CUR, | 727 | static int uvc_ioctl_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) |
791 | chain->selector->id, chain->dev->intfnum, | 728 | { |
792 | UVC_SU_INPUT_SELECT_CONTROL, &input, 1); | 729 | struct uvc_fh *handle = fh; |
793 | } | 730 | struct uvc_streaming *stream = handle->stream; |
794 | 731 | ||
795 | /* Try, Get, Set & Enum format */ | 732 | if (!uvc_has_privileges(handle)) |
796 | case VIDIOC_ENUM_FMT: | 733 | return -EBUSY; |
797 | { | ||
798 | struct v4l2_fmtdesc *fmt = arg; | ||
799 | struct uvc_format *format; | ||
800 | enum v4l2_buf_type type = fmt->type; | ||
801 | __u32 index = fmt->index; | ||
802 | 734 | ||
803 | if (fmt->type != stream->type || | 735 | return uvc_dequeue_buffer(&stream->queue, buf, |
804 | fmt->index >= stream->nformats) | 736 | file->f_flags & O_NONBLOCK); |
805 | return -EINVAL; | 737 | } |
806 | 738 | ||
807 | memset(fmt, 0, sizeof(*fmt)); | 739 | static int uvc_ioctl_create_bufs(struct file *file, void *fh, |
808 | fmt->index = index; | 740 | struct v4l2_create_buffers *cb) |
809 | fmt->type = type; | 741 | { |
810 | 742 | struct uvc_fh *handle = fh; | |
811 | format = &stream->format[fmt->index]; | 743 | struct uvc_streaming *stream = handle->stream; |
812 | fmt->flags = 0; | 744 | int ret; |
813 | if (format->flags & UVC_FMT_FLAG_COMPRESSED) | ||
814 | fmt->flags |= V4L2_FMT_FLAG_COMPRESSED; | ||
815 | strlcpy(fmt->description, format->name, | ||
816 | sizeof fmt->description); | ||
817 | fmt->description[sizeof fmt->description - 1] = 0; | ||
818 | fmt->pixelformat = format->fcc; | ||
819 | break; | ||
820 | } | ||
821 | 745 | ||
822 | case VIDIOC_TRY_FMT: | 746 | ret = uvc_acquire_privileges(handle); |
823 | { | 747 | if (ret < 0) |
824 | struct uvc_streaming_control probe; | 748 | return ret; |
825 | 749 | ||
826 | return uvc_v4l2_try_format(stream, arg, &probe, NULL, NULL); | 750 | return uvc_create_buffers(&stream->queue, cb); |
827 | } | 751 | } |
828 | 752 | ||
829 | case VIDIOC_S_FMT: | 753 | static int uvc_ioctl_streamon(struct file *file, void *fh, |
830 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 754 | enum v4l2_buf_type type) |
831 | if (ret < 0) | 755 | { |
832 | return ret; | 756 | struct uvc_fh *handle = fh; |
757 | struct uvc_streaming *stream = handle->stream; | ||
758 | int ret; | ||
833 | 759 | ||
834 | if ((ret = uvc_acquire_privileges(handle)) < 0) | 760 | if (!uvc_has_privileges(handle)) |
835 | return ret; | 761 | return -EBUSY; |
836 | 762 | ||
837 | return uvc_v4l2_set_format(stream, arg); | 763 | mutex_lock(&stream->mutex); |
764 | ret = uvc_queue_streamon(&stream->queue, type); | ||
765 | mutex_unlock(&stream->mutex); | ||
838 | 766 | ||
839 | case VIDIOC_G_FMT: | 767 | return ret; |
840 | return uvc_v4l2_get_format(stream, arg); | 768 | } |
841 | 769 | ||
842 | /* Frame size enumeration */ | 770 | static int uvc_ioctl_streamoff(struct file *file, void *fh, |
843 | case VIDIOC_ENUM_FRAMESIZES: | 771 | enum v4l2_buf_type type) |
844 | { | 772 | { |
845 | struct v4l2_frmsizeenum *fsize = arg; | 773 | struct uvc_fh *handle = fh; |
846 | struct uvc_format *format = NULL; | 774 | struct uvc_streaming *stream = handle->stream; |
847 | struct uvc_frame *frame; | ||
848 | int i; | ||
849 | 775 | ||
850 | /* Look for the given pixel format */ | 776 | if (!uvc_has_privileges(handle)) |
851 | for (i = 0; i < stream->nformats; i++) { | 777 | return -EBUSY; |
852 | if (stream->format[i].fcc == | ||
853 | fsize->pixel_format) { | ||
854 | format = &stream->format[i]; | ||
855 | break; | ||
856 | } | ||
857 | } | ||
858 | if (format == NULL) | ||
859 | return -EINVAL; | ||
860 | 778 | ||
861 | if (fsize->index >= format->nframes) | 779 | mutex_lock(&stream->mutex); |
862 | return -EINVAL; | 780 | uvc_queue_streamoff(&stream->queue, type); |
781 | mutex_unlock(&stream->mutex); | ||
863 | 782 | ||
864 | frame = &format->frame[fsize->index]; | 783 | return 0; |
865 | fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; | 784 | } |
866 | fsize->discrete.width = frame->wWidth; | ||
867 | fsize->discrete.height = frame->wHeight; | ||
868 | break; | ||
869 | } | ||
870 | 785 | ||
871 | /* Frame interval enumeration */ | 786 | static int uvc_ioctl_enum_input(struct file *file, void *fh, |
872 | case VIDIOC_ENUM_FRAMEINTERVALS: | 787 | struct v4l2_input *input) |
873 | { | 788 | { |
874 | struct v4l2_frmivalenum *fival = arg; | 789 | struct uvc_fh *handle = fh; |
875 | struct uvc_format *format = NULL; | 790 | struct uvc_video_chain *chain = handle->chain; |
876 | struct uvc_frame *frame = NULL; | 791 | const struct uvc_entity *selector = chain->selector; |
877 | int i; | 792 | struct uvc_entity *iterm = NULL; |
878 | 793 | u32 index = input->index; | |
879 | /* Look for the given pixel format and frame size */ | 794 | int pin = 0; |
880 | for (i = 0; i < stream->nformats; i++) { | 795 | |
881 | if (stream->format[i].fcc == | 796 | if (selector == NULL || |
882 | fival->pixel_format) { | 797 | (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { |
883 | format = &stream->format[i]; | 798 | if (index != 0) |
884 | break; | ||
885 | } | ||
886 | } | ||
887 | if (format == NULL) | ||
888 | return -EINVAL; | 799 | return -EINVAL; |
889 | 800 | list_for_each_entry(iterm, &chain->entities, chain) { | |
890 | for (i = 0; i < format->nframes; i++) { | 801 | if (UVC_ENTITY_IS_ITERM(iterm)) |
891 | if (format->frame[i].wWidth == fival->width && | ||
892 | format->frame[i].wHeight == fival->height) { | ||
893 | frame = &format->frame[i]; | ||
894 | break; | 802 | break; |
895 | } | ||
896 | } | 803 | } |
897 | if (frame == NULL) | 804 | pin = iterm->id; |
898 | return -EINVAL; | 805 | } else if (index < selector->bNrInPins) { |
899 | 806 | pin = selector->baSourceID[index]; | |
900 | if (frame->bFrameIntervalType) { | 807 | list_for_each_entry(iterm, &chain->entities, chain) { |
901 | if (fival->index >= frame->bFrameIntervalType) | 808 | if (!UVC_ENTITY_IS_ITERM(iterm)) |
902 | return -EINVAL; | 809 | continue; |
903 | 810 | if (iterm->id == pin) | |
904 | fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; | 811 | break; |
905 | fival->discrete.numerator = | ||
906 | frame->dwFrameInterval[fival->index]; | ||
907 | fival->discrete.denominator = 10000000; | ||
908 | uvc_simplify_fraction(&fival->discrete.numerator, | ||
909 | &fival->discrete.denominator, 8, 333); | ||
910 | } else { | ||
911 | fival->type = V4L2_FRMIVAL_TYPE_STEPWISE; | ||
912 | fival->stepwise.min.numerator = | ||
913 | frame->dwFrameInterval[0]; | ||
914 | fival->stepwise.min.denominator = 10000000; | ||
915 | fival->stepwise.max.numerator = | ||
916 | frame->dwFrameInterval[1]; | ||
917 | fival->stepwise.max.denominator = 10000000; | ||
918 | fival->stepwise.step.numerator = | ||
919 | frame->dwFrameInterval[2]; | ||
920 | fival->stepwise.step.denominator = 10000000; | ||
921 | uvc_simplify_fraction(&fival->stepwise.min.numerator, | ||
922 | &fival->stepwise.min.denominator, 8, 333); | ||
923 | uvc_simplify_fraction(&fival->stepwise.max.numerator, | ||
924 | &fival->stepwise.max.denominator, 8, 333); | ||
925 | uvc_simplify_fraction(&fival->stepwise.step.numerator, | ||
926 | &fival->stepwise.step.denominator, 8, 333); | ||
927 | } | 812 | } |
928 | break; | ||
929 | } | 813 | } |
930 | 814 | ||
931 | /* Get & Set streaming parameters */ | 815 | if (iterm == NULL || iterm->id != pin) |
932 | case VIDIOC_G_PARM: | 816 | return -EINVAL; |
933 | return uvc_v4l2_get_streamparm(stream, arg); | ||
934 | 817 | ||
935 | case VIDIOC_S_PARM: | 818 | memset(input, 0, sizeof(*input)); |
936 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 819 | input->index = index; |
937 | if (ret < 0) | 820 | strlcpy(input->name, iterm->name, sizeof(input->name)); |
938 | return ret; | 821 | if (UVC_ENTITY_TYPE(iterm) == UVC_ITT_CAMERA) |
822 | input->type = V4L2_INPUT_TYPE_CAMERA; | ||
939 | 823 | ||
940 | if ((ret = uvc_acquire_privileges(handle)) < 0) | 824 | return 0; |
941 | return ret; | 825 | } |
942 | 826 | ||
943 | return uvc_v4l2_set_streamparm(stream, arg); | 827 | static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input) |
828 | { | ||
829 | struct uvc_fh *handle = fh; | ||
830 | struct uvc_video_chain *chain = handle->chain; | ||
831 | int ret; | ||
832 | u8 i; | ||
944 | 833 | ||
945 | /* Cropping and scaling */ | 834 | if (chain->selector == NULL || |
946 | case VIDIOC_CROPCAP: | 835 | (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { |
947 | { | 836 | *input = 0; |
948 | struct v4l2_cropcap *ccap = arg; | 837 | return 0; |
838 | } | ||
949 | 839 | ||
950 | if (ccap->type != stream->type) | 840 | ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, chain->selector->id, |
951 | return -EINVAL; | 841 | chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL, |
842 | &i, 1); | ||
843 | if (ret < 0) | ||
844 | return ret; | ||
952 | 845 | ||
953 | ccap->bounds.left = 0; | 846 | *input = i - 1; |
954 | ccap->bounds.top = 0; | 847 | return 0; |
848 | } | ||
955 | 849 | ||
956 | mutex_lock(&stream->mutex); | 850 | static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input) |
957 | ccap->bounds.width = stream->cur_frame->wWidth; | 851 | { |
958 | ccap->bounds.height = stream->cur_frame->wHeight; | 852 | struct uvc_fh *handle = fh; |
959 | mutex_unlock(&stream->mutex); | 853 | struct uvc_video_chain *chain = handle->chain; |
854 | int ret; | ||
855 | u32 i; | ||
960 | 856 | ||
961 | ccap->defrect = ccap->bounds; | 857 | ret = uvc_acquire_privileges(handle); |
858 | if (ret < 0) | ||
859 | return ret; | ||
962 | 860 | ||
963 | ccap->pixelaspect.numerator = 1; | 861 | if (chain->selector == NULL || |
964 | ccap->pixelaspect.denominator = 1; | 862 | (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { |
965 | break; | 863 | if (input) |
864 | return -EINVAL; | ||
865 | return 0; | ||
966 | } | 866 | } |
967 | 867 | ||
968 | case VIDIOC_G_CROP: | 868 | if (input >= chain->selector->bNrInPins) |
969 | case VIDIOC_S_CROP: | 869 | return -EINVAL; |
970 | return -ENOTTY; | ||
971 | 870 | ||
972 | /* Buffers & streaming */ | 871 | i = input + 1; |
973 | case VIDIOC_REQBUFS: | 872 | return uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id, |
974 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 873 | chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL, |
975 | if (ret < 0) | 874 | &i, 1); |
976 | return ret; | 875 | } |
977 | 876 | ||
978 | if ((ret = uvc_acquire_privileges(handle)) < 0) | 877 | static int uvc_ioctl_queryctrl(struct file *file, void *fh, |
979 | return ret; | 878 | struct v4l2_queryctrl *qc) |
879 | { | ||
880 | struct uvc_fh *handle = fh; | ||
881 | struct uvc_video_chain *chain = handle->chain; | ||
980 | 882 | ||
981 | mutex_lock(&stream->mutex); | 883 | return uvc_query_v4l2_ctrl(chain, qc); |
982 | ret = uvc_alloc_buffers(&stream->queue, arg); | 884 | } |
983 | mutex_unlock(&stream->mutex); | ||
984 | if (ret < 0) | ||
985 | return ret; | ||
986 | 885 | ||
987 | if (ret == 0) | 886 | static int uvc_ioctl_g_ctrl(struct file *file, void *fh, |
988 | uvc_dismiss_privileges(handle); | 887 | struct v4l2_control *ctrl) |
888 | { | ||
889 | struct uvc_fh *handle = fh; | ||
890 | struct uvc_video_chain *chain = handle->chain; | ||
891 | struct v4l2_ext_control xctrl; | ||
892 | int ret; | ||
989 | 893 | ||
990 | ret = 0; | 894 | memset(&xctrl, 0, sizeof(xctrl)); |
991 | break; | 895 | xctrl.id = ctrl->id; |
896 | |||
897 | ret = uvc_ctrl_begin(chain); | ||
898 | if (ret < 0) | ||
899 | return ret; | ||
992 | 900 | ||
993 | case VIDIOC_QUERYBUF: | 901 | ret = uvc_ctrl_get(chain, &xctrl); |
994 | { | 902 | uvc_ctrl_rollback(handle); |
995 | struct v4l2_buffer *buf = arg; | 903 | if (ret < 0) |
904 | return ret; | ||
996 | 905 | ||
997 | if (!uvc_has_privileges(handle)) | 906 | ctrl->value = xctrl.value; |
998 | return -EBUSY; | 907 | return 0; |
908 | } | ||
999 | 909 | ||
1000 | return uvc_query_buffer(&stream->queue, buf); | 910 | static int uvc_ioctl_s_ctrl(struct file *file, void *fh, |
1001 | } | 911 | struct v4l2_control *ctrl) |
912 | { | ||
913 | struct uvc_fh *handle = fh; | ||
914 | struct uvc_video_chain *chain = handle->chain; | ||
915 | struct v4l2_ext_control xctrl; | ||
916 | int ret; | ||
1002 | 917 | ||
1003 | case VIDIOC_CREATE_BUFS: | 918 | memset(&xctrl, 0, sizeof(xctrl)); |
1004 | { | 919 | xctrl.id = ctrl->id; |
1005 | struct v4l2_create_buffers *cb = arg; | 920 | xctrl.value = ctrl->value; |
1006 | 921 | ||
1007 | ret = uvc_acquire_privileges(handle); | 922 | ret = uvc_ctrl_begin(chain); |
1008 | if (ret < 0) | 923 | if (ret < 0) |
1009 | return ret; | 924 | return ret; |
1010 | 925 | ||
1011 | return uvc_create_buffers(&stream->queue, cb); | 926 | ret = uvc_ctrl_set(chain, &xctrl); |
927 | if (ret < 0) { | ||
928 | uvc_ctrl_rollback(handle); | ||
929 | return ret; | ||
1012 | } | 930 | } |
1013 | 931 | ||
1014 | case VIDIOC_QBUF: | 932 | ret = uvc_ctrl_commit(handle, &xctrl, 1); |
1015 | if (!uvc_has_privileges(handle)) | 933 | if (ret < 0) |
1016 | return -EBUSY; | 934 | return ret; |
1017 | 935 | ||
1018 | return uvc_queue_buffer(&stream->queue, arg); | 936 | ctrl->value = xctrl.value; |
937 | return 0; | ||
938 | } | ||
939 | |||
940 | static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, | ||
941 | struct v4l2_ext_controls *ctrls) | ||
942 | { | ||
943 | struct uvc_fh *handle = fh; | ||
944 | struct uvc_video_chain *chain = handle->chain; | ||
945 | struct v4l2_ext_control *ctrl = ctrls->controls; | ||
946 | unsigned int i; | ||
947 | int ret; | ||
1019 | 948 | ||
1020 | case VIDIOC_DQBUF: | 949 | ret = uvc_ctrl_begin(chain); |
1021 | if (!uvc_has_privileges(handle)) | 950 | if (ret < 0) |
1022 | return -EBUSY; | 951 | return ret; |
1023 | 952 | ||
1024 | return uvc_dequeue_buffer(&stream->queue, arg, | 953 | for (i = 0; i < ctrls->count; ++ctrl, ++i) { |
1025 | file->f_flags & O_NONBLOCK); | 954 | ret = uvc_ctrl_get(chain, ctrl); |
955 | if (ret < 0) { | ||
956 | uvc_ctrl_rollback(handle); | ||
957 | ctrls->error_idx = i; | ||
958 | return ret; | ||
959 | } | ||
960 | } | ||
1026 | 961 | ||
1027 | case VIDIOC_STREAMON: | 962 | ctrls->error_idx = 0; |
1028 | { | ||
1029 | int *type = arg; | ||
1030 | 963 | ||
1031 | if (*type != stream->type) | 964 | return uvc_ctrl_rollback(handle); |
1032 | return -EINVAL; | 965 | } |
1033 | 966 | ||
1034 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 967 | static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle, |
1035 | if (ret < 0) | 968 | struct v4l2_ext_controls *ctrls, |
1036 | return ret; | 969 | bool commit) |
970 | { | ||
971 | struct v4l2_ext_control *ctrl = ctrls->controls; | ||
972 | struct uvc_video_chain *chain = handle->chain; | ||
973 | unsigned int i; | ||
974 | int ret; | ||
1037 | 975 | ||
1038 | if (!uvc_has_privileges(handle)) | 976 | ret = uvc_ctrl_begin(chain); |
1039 | return -EBUSY; | 977 | if (ret < 0) |
978 | return ret; | ||
1040 | 979 | ||
1041 | mutex_lock(&stream->mutex); | 980 | for (i = 0; i < ctrls->count; ++ctrl, ++i) { |
1042 | ret = uvc_video_enable(stream, 1); | 981 | ret = uvc_ctrl_set(chain, ctrl); |
1043 | mutex_unlock(&stream->mutex); | 982 | if (ret < 0) { |
1044 | if (ret < 0) | 983 | uvc_ctrl_rollback(handle); |
984 | ctrls->error_idx = commit ? ctrls->count : i; | ||
1045 | return ret; | 985 | return ret; |
1046 | break; | 986 | } |
1047 | } | 987 | } |
1048 | 988 | ||
1049 | case VIDIOC_STREAMOFF: | 989 | ctrls->error_idx = 0; |
1050 | { | ||
1051 | int *type = arg; | ||
1052 | 990 | ||
1053 | if (*type != stream->type) | 991 | if (commit) |
1054 | return -EINVAL; | 992 | return uvc_ctrl_commit(handle, ctrls->controls, ctrls->count); |
993 | else | ||
994 | return uvc_ctrl_rollback(handle); | ||
995 | } | ||
1055 | 996 | ||
1056 | ret = v4l2_prio_check(vdev->prio, handle->vfh.prio); | 997 | static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh, |
1057 | if (ret < 0) | 998 | struct v4l2_ext_controls *ctrls) |
1058 | return ret; | 999 | { |
1000 | struct uvc_fh *handle = fh; | ||
1001 | |||
1002 | return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, true); | ||
1003 | } | ||
1059 | 1004 | ||
1060 | if (!uvc_has_privileges(handle)) | 1005 | static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh, |
1061 | return -EBUSY; | 1006 | struct v4l2_ext_controls *ctrls) |
1007 | { | ||
1008 | struct uvc_fh *handle = fh; | ||
1062 | 1009 | ||
1063 | return uvc_video_enable(stream, 0); | 1010 | return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, false); |
1011 | } | ||
1012 | |||
1013 | static int uvc_ioctl_querymenu(struct file *file, void *fh, | ||
1014 | struct v4l2_querymenu *qm) | ||
1015 | { | ||
1016 | struct uvc_fh *handle = fh; | ||
1017 | struct uvc_video_chain *chain = handle->chain; | ||
1018 | |||
1019 | return uvc_query_v4l2_menu(chain, qm); | ||
1020 | } | ||
1021 | |||
1022 | static int uvc_ioctl_cropcap(struct file *file, void *fh, | ||
1023 | struct v4l2_cropcap *ccap) | ||
1024 | { | ||
1025 | struct uvc_fh *handle = fh; | ||
1026 | struct uvc_streaming *stream = handle->stream; | ||
1027 | |||
1028 | if (ccap->type != stream->type) | ||
1029 | return -EINVAL; | ||
1030 | |||
1031 | ccap->bounds.left = 0; | ||
1032 | ccap->bounds.top = 0; | ||
1033 | mutex_lock(&stream->mutex); | ||
1034 | ccap->bounds.width = stream->cur_frame->wWidth; | ||
1035 | ccap->bounds.height = stream->cur_frame->wHeight; | ||
1036 | mutex_unlock(&stream->mutex); | ||
1037 | |||
1038 | ccap->defrect = ccap->bounds; | ||
1039 | |||
1040 | ccap->pixelaspect.numerator = 1; | ||
1041 | ccap->pixelaspect.denominator = 1; | ||
1042 | return 0; | ||
1043 | } | ||
1044 | |||
1045 | static int uvc_ioctl_g_parm(struct file *file, void *fh, | ||
1046 | struct v4l2_streamparm *parm) | ||
1047 | { | ||
1048 | struct uvc_fh *handle = fh; | ||
1049 | struct uvc_streaming *stream = handle->stream; | ||
1050 | |||
1051 | return uvc_v4l2_get_streamparm(stream, parm); | ||
1052 | } | ||
1053 | |||
1054 | static int uvc_ioctl_s_parm(struct file *file, void *fh, | ||
1055 | struct v4l2_streamparm *parm) | ||
1056 | { | ||
1057 | struct uvc_fh *handle = fh; | ||
1058 | struct uvc_streaming *stream = handle->stream; | ||
1059 | int ret; | ||
1060 | |||
1061 | ret = uvc_acquire_privileges(handle); | ||
1062 | if (ret < 0) | ||
1063 | return ret; | ||
1064 | |||
1065 | return uvc_v4l2_set_streamparm(stream, parm); | ||
1066 | } | ||
1067 | |||
1068 | static int uvc_ioctl_enum_framesizes(struct file *file, void *fh, | ||
1069 | struct v4l2_frmsizeenum *fsize) | ||
1070 | { | ||
1071 | struct uvc_fh *handle = fh; | ||
1072 | struct uvc_streaming *stream = handle->stream; | ||
1073 | struct uvc_format *format = NULL; | ||
1074 | struct uvc_frame *frame; | ||
1075 | int i; | ||
1076 | |||
1077 | /* Look for the given pixel format */ | ||
1078 | for (i = 0; i < stream->nformats; i++) { | ||
1079 | if (stream->format[i].fcc == fsize->pixel_format) { | ||
1080 | format = &stream->format[i]; | ||
1081 | break; | ||
1082 | } | ||
1064 | } | 1083 | } |
1084 | if (format == NULL) | ||
1085 | return -EINVAL; | ||
1065 | 1086 | ||
1066 | case VIDIOC_SUBSCRIBE_EVENT: | 1087 | if (fsize->index >= format->nframes) |
1067 | { | 1088 | return -EINVAL; |
1068 | struct v4l2_event_subscription *sub = arg; | ||
1069 | 1089 | ||
1070 | switch (sub->type) { | 1090 | frame = &format->frame[fsize->index]; |
1071 | case V4L2_EVENT_CTRL: | 1091 | fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; |
1072 | return v4l2_event_subscribe(&handle->vfh, sub, 0, | 1092 | fsize->discrete.width = frame->wWidth; |
1073 | &uvc_ctrl_sub_ev_ops); | 1093 | fsize->discrete.height = frame->wHeight; |
1074 | default: | 1094 | return 0; |
1075 | return -EINVAL; | 1095 | } |
1096 | |||
1097 | static int uvc_ioctl_enum_frameintervals(struct file *file, void *fh, | ||
1098 | struct v4l2_frmivalenum *fival) | ||
1099 | { | ||
1100 | struct uvc_fh *handle = fh; | ||
1101 | struct uvc_streaming *stream = handle->stream; | ||
1102 | struct uvc_format *format = NULL; | ||
1103 | struct uvc_frame *frame = NULL; | ||
1104 | int i; | ||
1105 | |||
1106 | /* Look for the given pixel format and frame size */ | ||
1107 | for (i = 0; i < stream->nformats; i++) { | ||
1108 | if (stream->format[i].fcc == fival->pixel_format) { | ||
1109 | format = &stream->format[i]; | ||
1110 | break; | ||
1076 | } | 1111 | } |
1077 | } | 1112 | } |
1113 | if (format == NULL) | ||
1114 | return -EINVAL; | ||
1078 | 1115 | ||
1079 | case VIDIOC_UNSUBSCRIBE_EVENT: | 1116 | for (i = 0; i < format->nframes; i++) { |
1080 | return v4l2_event_unsubscribe(&handle->vfh, arg); | 1117 | if (format->frame[i].wWidth == fival->width && |
1118 | format->frame[i].wHeight == fival->height) { | ||
1119 | frame = &format->frame[i]; | ||
1120 | break; | ||
1121 | } | ||
1122 | } | ||
1123 | if (frame == NULL) | ||
1124 | return -EINVAL; | ||
1081 | 1125 | ||
1082 | case VIDIOC_DQEVENT: | 1126 | if (frame->bFrameIntervalType) { |
1083 | return v4l2_event_dequeue(&handle->vfh, arg, | 1127 | if (fival->index >= frame->bFrameIntervalType) |
1084 | file->f_flags & O_NONBLOCK); | 1128 | return -EINVAL; |
1085 | 1129 | ||
1086 | /* Analog video standards make no sense for digital cameras. */ | 1130 | fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; |
1087 | case VIDIOC_ENUMSTD: | 1131 | fival->discrete.numerator = |
1088 | case VIDIOC_QUERYSTD: | 1132 | frame->dwFrameInterval[fival->index]; |
1089 | case VIDIOC_G_STD: | 1133 | fival->discrete.denominator = 10000000; |
1090 | case VIDIOC_S_STD: | 1134 | uvc_simplify_fraction(&fival->discrete.numerator, |
1135 | &fival->discrete.denominator, 8, 333); | ||
1136 | } else { | ||
1137 | fival->type = V4L2_FRMIVAL_TYPE_STEPWISE; | ||
1138 | fival->stepwise.min.numerator = frame->dwFrameInterval[0]; | ||
1139 | fival->stepwise.min.denominator = 10000000; | ||
1140 | fival->stepwise.max.numerator = frame->dwFrameInterval[1]; | ||
1141 | fival->stepwise.max.denominator = 10000000; | ||
1142 | fival->stepwise.step.numerator = frame->dwFrameInterval[2]; | ||
1143 | fival->stepwise.step.denominator = 10000000; | ||
1144 | uvc_simplify_fraction(&fival->stepwise.min.numerator, | ||
1145 | &fival->stepwise.min.denominator, 8, 333); | ||
1146 | uvc_simplify_fraction(&fival->stepwise.max.numerator, | ||
1147 | &fival->stepwise.max.denominator, 8, 333); | ||
1148 | uvc_simplify_fraction(&fival->stepwise.step.numerator, | ||
1149 | &fival->stepwise.step.denominator, 8, 333); | ||
1150 | } | ||
1091 | 1151 | ||
1092 | case VIDIOC_OVERLAY: | 1152 | return 0; |
1153 | } | ||
1093 | 1154 | ||
1094 | case VIDIOC_ENUMAUDIO: | 1155 | static int uvc_ioctl_subscribe_event(struct v4l2_fh *fh, |
1095 | case VIDIOC_ENUMAUDOUT: | 1156 | const struct v4l2_event_subscription *sub) |
1157 | { | ||
1158 | switch (sub->type) { | ||
1159 | case V4L2_EVENT_CTRL: | ||
1160 | return v4l2_event_subscribe(fh, sub, 0, &uvc_ctrl_sub_ev_ops); | ||
1161 | default: | ||
1162 | return -EINVAL; | ||
1163 | } | ||
1164 | } | ||
1096 | 1165 | ||
1097 | case VIDIOC_ENUMOUTPUT: | 1166 | static long uvc_ioctl_default(struct file *file, void *fh, bool valid_prio, |
1098 | uvc_trace(UVC_TRACE_IOCTL, "Unsupported ioctl 0x%08x\n", cmd); | 1167 | unsigned int cmd, void *arg) |
1099 | return -ENOTTY; | 1168 | { |
1169 | struct uvc_fh *handle = fh; | ||
1170 | struct uvc_video_chain *chain = handle->chain; | ||
1100 | 1171 | ||
1172 | switch (cmd) { | ||
1173 | /* Dynamic controls. */ | ||
1101 | case UVCIOC_CTRL_MAP: | 1174 | case UVCIOC_CTRL_MAP: |
1102 | return uvc_ioctl_ctrl_map(chain, arg); | 1175 | return uvc_ioctl_ctrl_map(chain, arg); |
1103 | 1176 | ||
@@ -1105,23 +1178,8 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
1105 | return uvc_xu_ctrl_query(chain, arg); | 1178 | return uvc_xu_ctrl_query(chain, arg); |
1106 | 1179 | ||
1107 | default: | 1180 | default: |
1108 | uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n", cmd); | ||
1109 | return -ENOTTY; | 1181 | return -ENOTTY; |
1110 | } | 1182 | } |
1111 | |||
1112 | return ret; | ||
1113 | } | ||
1114 | |||
1115 | static long uvc_v4l2_ioctl(struct file *file, | ||
1116 | unsigned int cmd, unsigned long arg) | ||
1117 | { | ||
1118 | if (uvc_trace_param & UVC_TRACE_IOCTL) { | ||
1119 | uvc_printk(KERN_DEBUG, "uvc_v4l2_ioctl("); | ||
1120 | v4l_printk_ioctl(NULL, cmd); | ||
1121 | printk(")\n"); | ||
1122 | } | ||
1123 | |||
1124 | return video_usercopy(file, cmd, arg, uvc_v4l2_do_ioctl); | ||
1125 | } | 1183 | } |
1126 | 1184 | ||
1127 | #ifdef CONFIG_COMPAT | 1185 | #ifdef CONFIG_COMPAT |
@@ -1304,7 +1362,7 @@ static long uvc_v4l2_compat_ioctl32(struct file *file, | |||
1304 | 1362 | ||
1305 | old_fs = get_fs(); | 1363 | old_fs = get_fs(); |
1306 | set_fs(KERNEL_DS); | 1364 | set_fs(KERNEL_DS); |
1307 | ret = uvc_v4l2_ioctl(file, cmd, (unsigned long)&karg); | 1365 | ret = video_ioctl2(file, cmd, (unsigned long)&karg); |
1308 | set_fs(old_fs); | 1366 | set_fs(old_fs); |
1309 | 1367 | ||
1310 | if (ret < 0) | 1368 | if (ret < 0) |
@@ -1365,11 +1423,48 @@ static unsigned long uvc_v4l2_get_unmapped_area(struct file *file, | |||
1365 | } | 1423 | } |
1366 | #endif | 1424 | #endif |
1367 | 1425 | ||
1426 | const struct v4l2_ioctl_ops uvc_ioctl_ops = { | ||
1427 | .vidioc_querycap = uvc_ioctl_querycap, | ||
1428 | .vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt_vid_cap, | ||
1429 | .vidioc_enum_fmt_vid_out = uvc_ioctl_enum_fmt_vid_out, | ||
1430 | .vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt_vid_cap, | ||
1431 | .vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt_vid_out, | ||
1432 | .vidioc_s_fmt_vid_cap = uvc_ioctl_s_fmt_vid_cap, | ||
1433 | .vidioc_s_fmt_vid_out = uvc_ioctl_s_fmt_vid_out, | ||
1434 | .vidioc_try_fmt_vid_cap = uvc_ioctl_try_fmt_vid_cap, | ||
1435 | .vidioc_try_fmt_vid_out = uvc_ioctl_try_fmt_vid_out, | ||
1436 | .vidioc_reqbufs = uvc_ioctl_reqbufs, | ||
1437 | .vidioc_querybuf = uvc_ioctl_querybuf, | ||
1438 | .vidioc_qbuf = uvc_ioctl_qbuf, | ||
1439 | .vidioc_dqbuf = uvc_ioctl_dqbuf, | ||
1440 | .vidioc_create_bufs = uvc_ioctl_create_bufs, | ||
1441 | .vidioc_streamon = uvc_ioctl_streamon, | ||
1442 | .vidioc_streamoff = uvc_ioctl_streamoff, | ||
1443 | .vidioc_enum_input = uvc_ioctl_enum_input, | ||
1444 | .vidioc_g_input = uvc_ioctl_g_input, | ||
1445 | .vidioc_s_input = uvc_ioctl_s_input, | ||
1446 | .vidioc_queryctrl = uvc_ioctl_queryctrl, | ||
1447 | .vidioc_g_ctrl = uvc_ioctl_g_ctrl, | ||
1448 | .vidioc_s_ctrl = uvc_ioctl_s_ctrl, | ||
1449 | .vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls, | ||
1450 | .vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls, | ||
1451 | .vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls, | ||
1452 | .vidioc_querymenu = uvc_ioctl_querymenu, | ||
1453 | .vidioc_cropcap = uvc_ioctl_cropcap, | ||
1454 | .vidioc_g_parm = uvc_ioctl_g_parm, | ||
1455 | .vidioc_s_parm = uvc_ioctl_s_parm, | ||
1456 | .vidioc_enum_framesizes = uvc_ioctl_enum_framesizes, | ||
1457 | .vidioc_enum_frameintervals = uvc_ioctl_enum_frameintervals, | ||
1458 | .vidioc_subscribe_event = uvc_ioctl_subscribe_event, | ||
1459 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1460 | .vidioc_default = uvc_ioctl_default, | ||
1461 | }; | ||
1462 | |||
1368 | const struct v4l2_file_operations uvc_fops = { | 1463 | const struct v4l2_file_operations uvc_fops = { |
1369 | .owner = THIS_MODULE, | 1464 | .owner = THIS_MODULE, |
1370 | .open = uvc_v4l2_open, | 1465 | .open = uvc_v4l2_open, |
1371 | .release = uvc_v4l2_release, | 1466 | .release = uvc_v4l2_release, |
1372 | .unlocked_ioctl = uvc_v4l2_ioctl, | 1467 | .unlocked_ioctl = video_ioctl2, |
1373 | #ifdef CONFIG_COMPAT | 1468 | #ifdef CONFIG_COMPAT |
1374 | .compat_ioctl32 = uvc_v4l2_compat_ioctl32, | 1469 | .compat_ioctl32 = uvc_v4l2_compat_ioctl32, |
1375 | #endif | 1470 | #endif |
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index df81b9c4faf1..9637e8b86949 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c | |||
@@ -1021,6 +1021,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream, | |||
1021 | 1021 | ||
1022 | uvc_video_get_ts(&ts); | 1022 | uvc_video_get_ts(&ts); |
1023 | 1023 | ||
1024 | buf->buf.v4l2_buf.field = V4L2_FIELD_NONE; | ||
1024 | buf->buf.v4l2_buf.sequence = stream->sequence; | 1025 | buf->buf.v4l2_buf.sequence = stream->sequence; |
1025 | buf->buf.v4l2_buf.timestamp.tv_sec = ts.tv_sec; | 1026 | buf->buf.v4l2_buf.timestamp.tv_sec = ts.tv_sec; |
1026 | buf->buf.v4l2_buf.timestamp.tv_usec = | 1027 | buf->buf.v4l2_buf.timestamp.tv_usec = |
@@ -1734,19 +1735,13 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset) | |||
1734 | uvc_video_clock_reset(stream); | 1735 | uvc_video_clock_reset(stream); |
1735 | 1736 | ||
1736 | ret = uvc_commit_video(stream, &stream->ctrl); | 1737 | ret = uvc_commit_video(stream, &stream->ctrl); |
1737 | if (ret < 0) { | 1738 | if (ret < 0) |
1738 | uvc_queue_enable(&stream->queue, 0); | ||
1739 | return ret; | 1739 | return ret; |
1740 | } | ||
1741 | 1740 | ||
1742 | if (!uvc_queue_streaming(&stream->queue)) | 1741 | if (!uvc_queue_streaming(&stream->queue)) |
1743 | return 0; | 1742 | return 0; |
1744 | 1743 | ||
1745 | ret = uvc_init_video(stream, GFP_NOIO); | 1744 | return uvc_init_video(stream, GFP_NOIO); |
1746 | if (ret < 0) | ||
1747 | uvc_queue_enable(&stream->queue, 0); | ||
1748 | |||
1749 | return ret; | ||
1750 | } | 1745 | } |
1751 | 1746 | ||
1752 | /* ------------------------------------------------------------------------ | 1747 | /* ------------------------------------------------------------------------ |
@@ -1778,11 +1773,6 @@ int uvc_video_init(struct uvc_streaming *stream) | |||
1778 | 1773 | ||
1779 | atomic_set(&stream->active, 0); | 1774 | atomic_set(&stream->active, 0); |
1780 | 1775 | ||
1781 | /* Initialize the video buffers queue. */ | ||
1782 | ret = uvc_queue_init(&stream->queue, stream->type, !uvc_no_drop_param); | ||
1783 | if (ret) | ||
1784 | return ret; | ||
1785 | |||
1786 | /* Alternate setting 0 should be the default, yet the XBox Live Vision | 1776 | /* Alternate setting 0 should be the default, yet the XBox Live Vision |
1787 | * Cam (and possibly other devices) crash or otherwise misbehave if | 1777 | * Cam (and possibly other devices) crash or otherwise misbehave if |
1788 | * they don't receive a SET_INTERFACE request before any other video | 1778 | * they don't receive a SET_INTERFACE request before any other video |
@@ -1889,7 +1879,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) | |||
1889 | usb_clear_halt(stream->dev->udev, pipe); | 1879 | usb_clear_halt(stream->dev->udev, pipe); |
1890 | } | 1880 | } |
1891 | 1881 | ||
1892 | uvc_queue_enable(&stream->queue, 0); | ||
1893 | uvc_video_clock_cleanup(stream); | 1882 | uvc_video_clock_cleanup(stream); |
1894 | return 0; | 1883 | return 0; |
1895 | } | 1884 | } |
@@ -1898,10 +1887,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) | |||
1898 | if (ret < 0) | 1887 | if (ret < 0) |
1899 | return ret; | 1888 | return ret; |
1900 | 1889 | ||
1901 | ret = uvc_queue_enable(&stream->queue, 1); | ||
1902 | if (ret < 0) | ||
1903 | goto error_queue; | ||
1904 | |||
1905 | /* Commit the streaming parameters. */ | 1890 | /* Commit the streaming parameters. */ |
1906 | ret = uvc_commit_video(stream, &stream->ctrl); | 1891 | ret = uvc_commit_video(stream, &stream->ctrl); |
1907 | if (ret < 0) | 1892 | if (ret < 0) |
@@ -1916,8 +1901,6 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) | |||
1916 | error_video: | 1901 | error_video: |
1917 | usb_set_interface(stream->dev->udev, stream->intfnum, 0); | 1902 | usb_set_interface(stream->dev->udev, stream->intfnum, 0); |
1918 | error_commit: | 1903 | error_commit: |
1919 | uvc_queue_enable(&stream->queue, 0); | ||
1920 | error_queue: | ||
1921 | uvc_video_clock_cleanup(stream); | 1904 | uvc_video_clock_cleanup(stream); |
1922 | 1905 | ||
1923 | return ret; | 1906 | return ret; |
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 864ada740360..f0a04b532ede 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h | |||
@@ -148,6 +148,7 @@ | |||
148 | #define UVC_QUIRK_PROBE_DEF 0x00000100 | 148 | #define UVC_QUIRK_PROBE_DEF 0x00000100 |
149 | #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 | 149 | #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 |
150 | #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 | 150 | #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 |
151 | #define UVC_QUIRK_FORCE_Y8 0x00000800 | ||
151 | 152 | ||
152 | /* Format flags */ | 153 | /* Format flags */ |
153 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 | 154 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 |
@@ -579,7 +580,6 @@ struct uvc_driver { | |||
579 | #define UVC_TRACE_FORMAT (1 << 3) | 580 | #define UVC_TRACE_FORMAT (1 << 3) |
580 | #define UVC_TRACE_CAPTURE (1 << 4) | 581 | #define UVC_TRACE_CAPTURE (1 << 4) |
581 | #define UVC_TRACE_CALLS (1 << 5) | 582 | #define UVC_TRACE_CALLS (1 << 5) |
582 | #define UVC_TRACE_IOCTL (1 << 6) | ||
583 | #define UVC_TRACE_FRAME (1 << 7) | 583 | #define UVC_TRACE_FRAME (1 << 7) |
584 | #define UVC_TRACE_SUSPEND (1 << 8) | 584 | #define UVC_TRACE_SUSPEND (1 << 8) |
585 | #define UVC_TRACE_STATUS (1 << 9) | 585 | #define UVC_TRACE_STATUS (1 << 9) |
@@ -623,9 +623,9 @@ extern struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id); | |||
623 | /* Video buffers queue management. */ | 623 | /* Video buffers queue management. */ |
624 | extern int uvc_queue_init(struct uvc_video_queue *queue, | 624 | extern int uvc_queue_init(struct uvc_video_queue *queue, |
625 | enum v4l2_buf_type type, int drop_corrupted); | 625 | enum v4l2_buf_type type, int drop_corrupted); |
626 | extern int uvc_alloc_buffers(struct uvc_video_queue *queue, | 626 | extern void uvc_queue_release(struct uvc_video_queue *queue); |
627 | extern int uvc_request_buffers(struct uvc_video_queue *queue, | ||
627 | struct v4l2_requestbuffers *rb); | 628 | struct v4l2_requestbuffers *rb); |
628 | extern void uvc_free_buffers(struct uvc_video_queue *queue); | ||
629 | extern int uvc_query_buffer(struct uvc_video_queue *queue, | 629 | extern int uvc_query_buffer(struct uvc_video_queue *queue, |
630 | struct v4l2_buffer *v4l2_buf); | 630 | struct v4l2_buffer *v4l2_buf); |
631 | extern int uvc_create_buffers(struct uvc_video_queue *queue, | 631 | extern int uvc_create_buffers(struct uvc_video_queue *queue, |
@@ -634,7 +634,10 @@ extern int uvc_queue_buffer(struct uvc_video_queue *queue, | |||
634 | struct v4l2_buffer *v4l2_buf); | 634 | struct v4l2_buffer *v4l2_buf); |
635 | extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, | 635 | extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, |
636 | struct v4l2_buffer *v4l2_buf, int nonblocking); | 636 | struct v4l2_buffer *v4l2_buf, int nonblocking); |
637 | extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable); | 637 | extern int uvc_queue_streamon(struct uvc_video_queue *queue, |
638 | enum v4l2_buf_type type); | ||
639 | extern int uvc_queue_streamoff(struct uvc_video_queue *queue, | ||
640 | enum v4l2_buf_type type); | ||
638 | extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); | 641 | extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); |
639 | extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, | 642 | extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, |
640 | struct uvc_buffer *buf); | 643 | struct uvc_buffer *buf); |
@@ -653,6 +656,7 @@ static inline int uvc_queue_streaming(struct uvc_video_queue *queue) | |||
653 | } | 656 | } |
654 | 657 | ||
655 | /* V4L2 interface */ | 658 | /* V4L2 interface */ |
659 | extern const struct v4l2_ioctl_ops uvc_ioctl_ops; | ||
656 | extern const struct v4l2_file_operations uvc_fops; | 660 | extern const struct v4l2_file_operations uvc_fops; |
657 | 661 | ||
658 | /* Media controller */ | 662 | /* Media controller */ |
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 2e9d81f4c1a5..5b808500e7e7 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c | |||
@@ -80,36 +80,6 @@ MODULE_LICENSE("GPL"); | |||
80 | 80 | ||
81 | /* Helper functions for control handling */ | 81 | /* Helper functions for control handling */ |
82 | 82 | ||
83 | /* Check for correctness of the ctrl's value based on the data from | ||
84 | struct v4l2_queryctrl and the available menu items. Note that | ||
85 | menu_items may be NULL, in that case it is ignored. */ | ||
86 | int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, | ||
87 | const char * const *menu_items) | ||
88 | { | ||
89 | if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED) | ||
90 | return -EINVAL; | ||
91 | if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED) | ||
92 | return -EBUSY; | ||
93 | if (qctrl->type == V4L2_CTRL_TYPE_STRING) | ||
94 | return 0; | ||
95 | if (qctrl->type == V4L2_CTRL_TYPE_BUTTON || | ||
96 | qctrl->type == V4L2_CTRL_TYPE_INTEGER64 || | ||
97 | qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) | ||
98 | return 0; | ||
99 | if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum) | ||
100 | return -ERANGE; | ||
101 | if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) { | ||
102 | if (menu_items[ctrl->value] == NULL || | ||
103 | menu_items[ctrl->value][0] == '\0') | ||
104 | return -EINVAL; | ||
105 | } | ||
106 | if (qctrl->type == V4L2_CTRL_TYPE_BITMASK && | ||
107 | (ctrl->value & ~qctrl->maximum)) | ||
108 | return -ERANGE; | ||
109 | return 0; | ||
110 | } | ||
111 | EXPORT_SYMBOL(v4l2_ctrl_check); | ||
112 | |||
113 | /* Fill in a struct v4l2_queryctrl */ | 83 | /* Fill in a struct v4l2_queryctrl */ |
114 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 _step, s32 _def) | 84 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 _step, s32 _def) |
115 | { | 85 | { |
@@ -135,101 +105,6 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 _ | |||
135 | } | 105 | } |
136 | EXPORT_SYMBOL(v4l2_ctrl_query_fill); | 106 | EXPORT_SYMBOL(v4l2_ctrl_query_fill); |
137 | 107 | ||
138 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and | ||
139 | the menu. The qctrl pointer may be NULL, in which case it is ignored. | ||
140 | If menu_items is NULL, then the menu items are retrieved using | ||
141 | v4l2_ctrl_get_menu. */ | ||
142 | int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl, | ||
143 | const char * const *menu_items) | ||
144 | { | ||
145 | int i; | ||
146 | |||
147 | qmenu->reserved = 0; | ||
148 | if (menu_items == NULL) | ||
149 | menu_items = v4l2_ctrl_get_menu(qmenu->id); | ||
150 | if (menu_items == NULL || | ||
151 | (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum))) | ||
152 | return -EINVAL; | ||
153 | for (i = 0; i < qmenu->index && menu_items[i]; i++) ; | ||
154 | if (menu_items[i] == NULL || menu_items[i][0] == '\0') | ||
155 | return -EINVAL; | ||
156 | strlcpy(qmenu->name, menu_items[qmenu->index], sizeof(qmenu->name)); | ||
157 | return 0; | ||
158 | } | ||
159 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); | ||
160 | |||
161 | /* Fill in a struct v4l2_querymenu based on the specified array of valid | ||
162 | menu items (terminated by V4L2_CTRL_MENU_IDS_END). | ||
163 | Use this if there are 'holes' in the list of valid menu items. */ | ||
164 | int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids) | ||
165 | { | ||
166 | const char * const *menu_items = v4l2_ctrl_get_menu(qmenu->id); | ||
167 | |||
168 | qmenu->reserved = 0; | ||
169 | if (menu_items == NULL || ids == NULL) | ||
170 | return -EINVAL; | ||
171 | while (*ids != V4L2_CTRL_MENU_IDS_END) { | ||
172 | if (*ids++ == qmenu->index) { | ||
173 | strlcpy(qmenu->name, menu_items[qmenu->index], | ||
174 | sizeof(qmenu->name)); | ||
175 | return 0; | ||
176 | } | ||
177 | } | ||
178 | return -EINVAL; | ||
179 | } | ||
180 | EXPORT_SYMBOL(v4l2_ctrl_query_menu_valid_items); | ||
181 | |||
182 | /* ctrl_classes points to an array of u32 pointers, the last element is | ||
183 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. | ||
184 | Each array must be sorted low to high and belong to the same control | ||
185 | class. The array of u32 pointers must also be sorted, from low class IDs | ||
186 | to high class IDs. | ||
187 | |||
188 | This function returns the first ID that follows after the given ID. | ||
189 | When no more controls are available 0 is returned. */ | ||
190 | u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) | ||
191 | { | ||
192 | u32 ctrl_class = V4L2_CTRL_ID2CLASS(id); | ||
193 | const u32 *pctrl; | ||
194 | |||
195 | if (ctrl_classes == NULL) | ||
196 | return 0; | ||
197 | |||
198 | /* if no query is desired, then check if the ID is part of ctrl_classes */ | ||
199 | if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0) { | ||
200 | /* find class */ | ||
201 | while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) != ctrl_class) | ||
202 | ctrl_classes++; | ||
203 | if (*ctrl_classes == NULL) | ||
204 | return 0; | ||
205 | pctrl = *ctrl_classes; | ||
206 | /* find control ID */ | ||
207 | while (*pctrl && *pctrl != id) pctrl++; | ||
208 | return *pctrl ? id : 0; | ||
209 | } | ||
210 | id &= V4L2_CTRL_ID_MASK; | ||
211 | id++; /* select next control */ | ||
212 | /* find first class that matches (or is greater than) the class of | ||
213 | the ID */ | ||
214 | while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) < ctrl_class) | ||
215 | ctrl_classes++; | ||
216 | /* no more classes */ | ||
217 | if (*ctrl_classes == NULL) | ||
218 | return 0; | ||
219 | pctrl = *ctrl_classes; | ||
220 | /* find first ctrl within the class that is >= ID */ | ||
221 | while (*pctrl && *pctrl < id) pctrl++; | ||
222 | if (*pctrl) | ||
223 | return *pctrl; | ||
224 | /* we are at the end of the controls of the current class. */ | ||
225 | /* continue with next class if available */ | ||
226 | ctrl_classes++; | ||
227 | if (*ctrl_classes == NULL) | ||
228 | return 0; | ||
229 | return **ctrl_classes; | ||
230 | } | ||
231 | EXPORT_SYMBOL(v4l2_ctrl_next); | ||
232 | |||
233 | /* I2C Helper functions */ | 108 | /* I2C Helper functions */ |
234 | 109 | ||
235 | #if IS_ENABLED(CONFIG_I2C) | 110 | #if IS_ENABLED(CONFIG_I2C) |
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index e502a5fb2994..af635430524e 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c | |||
@@ -222,6 +222,9 @@ static int get_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_ | |||
222 | 222 | ||
223 | static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) | 223 | static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) |
224 | { | 224 | { |
225 | if (put_user(kp->type, &up->type)) | ||
226 | return -EFAULT; | ||
227 | |||
225 | switch (kp->type) { | 228 | switch (kp->type) { |
226 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 229 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
227 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 230 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
@@ -248,8 +251,7 @@ static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us | |||
248 | 251 | ||
249 | static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) | 252 | static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) |
250 | { | 253 | { |
251 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_format32)) || | 254 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_format32))) |
252 | put_user(kp->type, &up->type)) | ||
253 | return -EFAULT; | 255 | return -EFAULT; |
254 | return __put_v4l2_format32(kp, up); | 256 | return __put_v4l2_format32(kp, up); |
255 | } | 257 | } |
@@ -257,8 +259,8 @@ static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user | |||
257 | static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up) | 259 | static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up) |
258 | { | 260 | { |
259 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) || | 261 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) || |
260 | copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format.fmt))) | 262 | copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format))) |
261 | return -EFAULT; | 263 | return -EFAULT; |
262 | return __put_v4l2_format32(&kp->format, &up->format); | 264 | return __put_v4l2_format32(&kp->format, &up->format); |
263 | } | 265 | } |
264 | 266 | ||
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 86012140923f..45c5b4710601 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c | |||
@@ -1658,10 +1658,8 @@ static int check_range(enum v4l2_ctrl_type type, | |||
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | /* Validate a new control */ | 1660 | /* Validate a new control */ |
1661 | static int validate_new(const struct v4l2_ctrl *ctrl, | 1661 | static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) |
1662 | struct v4l2_ext_control *c) | ||
1663 | { | 1662 | { |
1664 | union v4l2_ctrl_ptr ptr; | ||
1665 | unsigned idx; | 1663 | unsigned idx; |
1666 | int err = 0; | 1664 | int err = 0; |
1667 | 1665 | ||
@@ -1674,19 +1672,14 @@ static int validate_new(const struct v4l2_ctrl *ctrl, | |||
1674 | case V4L2_CTRL_TYPE_BOOLEAN: | 1672 | case V4L2_CTRL_TYPE_BOOLEAN: |
1675 | case V4L2_CTRL_TYPE_BUTTON: | 1673 | case V4L2_CTRL_TYPE_BUTTON: |
1676 | case V4L2_CTRL_TYPE_CTRL_CLASS: | 1674 | case V4L2_CTRL_TYPE_CTRL_CLASS: |
1677 | ptr.p_s32 = &c->value; | ||
1678 | return ctrl->type_ops->validate(ctrl, 0, ptr); | ||
1679 | |||
1680 | case V4L2_CTRL_TYPE_INTEGER64: | 1675 | case V4L2_CTRL_TYPE_INTEGER64: |
1681 | ptr.p_s64 = &c->value64; | 1676 | return ctrl->type_ops->validate(ctrl, 0, p_new); |
1682 | return ctrl->type_ops->validate(ctrl, 0, ptr); | ||
1683 | default: | 1677 | default: |
1684 | break; | 1678 | break; |
1685 | } | 1679 | } |
1686 | } | 1680 | } |
1687 | ptr.p = c->ptr; | 1681 | for (idx = 0; !err && idx < ctrl->elems; idx++) |
1688 | for (idx = 0; !err && idx < c->size / ctrl->elem_size; idx++) | 1682 | err = ctrl->type_ops->validate(ctrl, idx, p_new); |
1689 | err = ctrl->type_ops->validate(ctrl, idx, ptr); | ||
1690 | return err; | 1683 | return err; |
1691 | } | 1684 | } |
1692 | 1685 | ||
@@ -3012,6 +3005,7 @@ static int validate_ctrls(struct v4l2_ext_controls *cs, | |||
3012 | cs->error_idx = cs->count; | 3005 | cs->error_idx = cs->count; |
3013 | for (i = 0; i < cs->count; i++) { | 3006 | for (i = 0; i < cs->count; i++) { |
3014 | struct v4l2_ctrl *ctrl = helpers[i].ctrl; | 3007 | struct v4l2_ctrl *ctrl = helpers[i].ctrl; |
3008 | union v4l2_ctrl_ptr p_new; | ||
3015 | 3009 | ||
3016 | cs->error_idx = i; | 3010 | cs->error_idx = i; |
3017 | 3011 | ||
@@ -3025,7 +3019,17 @@ static int validate_ctrls(struct v4l2_ext_controls *cs, | |||
3025 | best-effort to avoid that. */ | 3019 | best-effort to avoid that. */ |
3026 | if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) | 3020 | if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) |
3027 | return -EBUSY; | 3021 | return -EBUSY; |
3028 | ret = validate_new(ctrl, &cs->controls[i]); | 3022 | /* |
3023 | * Skip validation for now if the payload needs to be copied | ||
3024 | * from userspace into kernelspace. We'll validate those later. | ||
3025 | */ | ||
3026 | if (ctrl->is_ptr) | ||
3027 | continue; | ||
3028 | if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) | ||
3029 | p_new.p_s64 = &cs->controls[i].value64; | ||
3030 | else | ||
3031 | p_new.p_s32 = &cs->controls[i].value; | ||
3032 | ret = validate_new(ctrl, p_new); | ||
3029 | if (ret) | 3033 | if (ret) |
3030 | return ret; | 3034 | return ret; |
3031 | } | 3035 | } |
@@ -3120,7 +3124,11 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, | |||
3120 | /* Copy the new caller-supplied control values. | 3124 | /* Copy the new caller-supplied control values. |
3121 | user_to_new() sets 'is_new' to 1. */ | 3125 | user_to_new() sets 'is_new' to 1. */ |
3122 | do { | 3126 | do { |
3123 | ret = user_to_new(cs->controls + idx, helpers[idx].ctrl); | 3127 | struct v4l2_ctrl *ctrl = helpers[idx].ctrl; |
3128 | |||
3129 | ret = user_to_new(cs->controls + idx, ctrl); | ||
3130 | if (!ret && ctrl->is_ptr) | ||
3131 | ret = validate_new(ctrl, ctrl->p_new); | ||
3124 | idx = helpers[idx].next; | 3132 | idx = helpers[idx].next; |
3125 | } while (!ret && idx); | 3133 | } while (!ret && idx); |
3126 | 3134 | ||
@@ -3170,10 +3178,10 @@ int v4l2_subdev_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs | |||
3170 | EXPORT_SYMBOL(v4l2_subdev_s_ext_ctrls); | 3178 | EXPORT_SYMBOL(v4l2_subdev_s_ext_ctrls); |
3171 | 3179 | ||
3172 | /* Helper function for VIDIOC_S_CTRL compatibility */ | 3180 | /* Helper function for VIDIOC_S_CTRL compatibility */ |
3173 | static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, | 3181 | static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags) |
3174 | struct v4l2_ext_control *c, u32 ch_flags) | ||
3175 | { | 3182 | { |
3176 | struct v4l2_ctrl *master = ctrl->cluster[0]; | 3183 | struct v4l2_ctrl *master = ctrl->cluster[0]; |
3184 | int ret; | ||
3177 | int i; | 3185 | int i; |
3178 | 3186 | ||
3179 | /* Reset the 'is_new' flags of the cluster */ | 3187 | /* Reset the 'is_new' flags of the cluster */ |
@@ -3181,8 +3189,9 @@ static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, | |||
3181 | if (master->cluster[i]) | 3189 | if (master->cluster[i]) |
3182 | master->cluster[i]->is_new = 0; | 3190 | master->cluster[i]->is_new = 0; |
3183 | 3191 | ||
3184 | if (c) | 3192 | ret = validate_new(ctrl, ctrl->p_new); |
3185 | user_to_new(c, ctrl); | 3193 | if (ret) |
3194 | return ret; | ||
3186 | 3195 | ||
3187 | /* For autoclusters with volatiles that are switched from auto to | 3196 | /* For autoclusters with volatiles that are switched from auto to |
3188 | manual mode we have to update the current volatile values since | 3197 | manual mode we have to update the current volatile values since |
@@ -3199,15 +3208,14 @@ static int set_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, | |||
3199 | static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, | 3208 | static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, |
3200 | struct v4l2_ext_control *c) | 3209 | struct v4l2_ext_control *c) |
3201 | { | 3210 | { |
3202 | int ret = validate_new(ctrl, c); | 3211 | int ret; |
3203 | 3212 | ||
3204 | if (!ret) { | 3213 | v4l2_ctrl_lock(ctrl); |
3205 | v4l2_ctrl_lock(ctrl); | 3214 | user_to_new(c, ctrl); |
3206 | ret = set_ctrl(fh, ctrl, c, 0); | 3215 | ret = set_ctrl(fh, ctrl, 0); |
3207 | if (!ret) | 3216 | if (!ret) |
3208 | cur_to_user(c, ctrl); | 3217 | cur_to_user(c, ctrl); |
3209 | v4l2_ctrl_unlock(ctrl); | 3218 | v4l2_ctrl_unlock(ctrl); |
3210 | } | ||
3211 | return ret; | 3219 | return ret; |
3212 | } | 3220 | } |
3213 | 3221 | ||
@@ -3215,7 +3223,7 @@ int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, | |||
3215 | struct v4l2_control *control) | 3223 | struct v4l2_control *control) |
3216 | { | 3224 | { |
3217 | struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); | 3225 | struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); |
3218 | struct v4l2_ext_control c; | 3226 | struct v4l2_ext_control c = { control->id }; |
3219 | int ret; | 3227 | int ret; |
3220 | 3228 | ||
3221 | if (ctrl == NULL || !ctrl->is_int) | 3229 | if (ctrl == NULL || !ctrl->is_int) |
@@ -3244,7 +3252,7 @@ int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) | |||
3244 | /* It's a driver bug if this happens. */ | 3252 | /* It's a driver bug if this happens. */ |
3245 | WARN_ON(!ctrl->is_int); | 3253 | WARN_ON(!ctrl->is_int); |
3246 | ctrl->val = val; | 3254 | ctrl->val = val; |
3247 | return set_ctrl(NULL, ctrl, NULL, 0); | 3255 | return set_ctrl(NULL, ctrl, 0); |
3248 | } | 3256 | } |
3249 | EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl); | 3257 | EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl); |
3250 | 3258 | ||
@@ -3255,7 +3263,7 @@ int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) | |||
3255 | /* It's a driver bug if this happens. */ | 3263 | /* It's a driver bug if this happens. */ |
3256 | WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); | 3264 | WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); |
3257 | *ctrl->p_new.p_s64 = val; | 3265 | *ctrl->p_new.p_s64 = val; |
3258 | return set_ctrl(NULL, ctrl, NULL, 0); | 3266 | return set_ctrl(NULL, ctrl, 0); |
3259 | } | 3267 | } |
3260 | EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_int64); | 3268 | EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_int64); |
3261 | 3269 | ||
@@ -3266,7 +3274,7 @@ int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) | |||
3266 | /* It's a driver bug if this happens. */ | 3274 | /* It's a driver bug if this happens. */ |
3267 | WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); | 3275 | WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING); |
3268 | strlcpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); | 3276 | strlcpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); |
3269 | return set_ctrl(NULL, ctrl, NULL, 0); | 3277 | return set_ctrl(NULL, ctrl, 0); |
3270 | } | 3278 | } |
3271 | EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string); | 3279 | EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string); |
3272 | 3280 | ||
@@ -3289,8 +3297,8 @@ EXPORT_SYMBOL(v4l2_ctrl_notify); | |||
3289 | int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, | 3297 | int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, |
3290 | s64 min, s64 max, u64 step, s64 def) | 3298 | s64 min, s64 max, u64 step, s64 def) |
3291 | { | 3299 | { |
3300 | bool changed; | ||
3292 | int ret; | 3301 | int ret; |
3293 | struct v4l2_ext_control c; | ||
3294 | 3302 | ||
3295 | lockdep_assert_held(ctrl->handler->lock); | 3303 | lockdep_assert_held(ctrl->handler->lock); |
3296 | 3304 | ||
@@ -3317,11 +3325,20 @@ int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, | |||
3317 | ctrl->maximum = max; | 3325 | ctrl->maximum = max; |
3318 | ctrl->step = step; | 3326 | ctrl->step = step; |
3319 | ctrl->default_value = def; | 3327 | ctrl->default_value = def; |
3320 | c.value = *ctrl->p_cur.p_s32; | 3328 | cur_to_new(ctrl); |
3321 | if (validate_new(ctrl, &c)) | 3329 | if (validate_new(ctrl, ctrl->p_new)) { |
3322 | c.value = def; | 3330 | if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) |
3323 | if (c.value != *ctrl->p_cur.p_s32) | 3331 | *ctrl->p_new.p_s64 = def; |
3324 | ret = set_ctrl(NULL, ctrl, &c, V4L2_EVENT_CTRL_CH_RANGE); | 3332 | else |
3333 | *ctrl->p_new.p_s32 = def; | ||
3334 | } | ||
3335 | |||
3336 | if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) | ||
3337 | changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; | ||
3338 | else | ||
3339 | changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; | ||
3340 | if (changed) | ||
3341 | ret = set_ctrl(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); | ||
3325 | else | 3342 | else |
3326 | send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); | 3343 | send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE); |
3327 | return ret; | 3344 | return ret; |
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 33617c365acc..9aa530a8bea9 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c | |||
@@ -194,7 +194,7 @@ static void v4l2_device_release(struct device *cd) | |||
194 | mutex_unlock(&videodev_lock); | 194 | mutex_unlock(&videodev_lock); |
195 | 195 | ||
196 | #if defined(CONFIG_MEDIA_CONTROLLER) | 196 | #if defined(CONFIG_MEDIA_CONTROLLER) |
197 | if (v4l2_dev && v4l2_dev->mdev && | 197 | if (v4l2_dev->mdev && |
198 | vdev->vfl_type != VFL_TYPE_SUBDEV) | 198 | vdev->vfl_type != VFL_TYPE_SUBDEV) |
199 | media_device_unregister_entity(&vdev->entity); | 199 | media_device_unregister_entity(&vdev->entity); |
200 | #endif | 200 | #endif |
@@ -207,7 +207,7 @@ static void v4l2_device_release(struct device *cd) | |||
207 | * TODO: In the long run all drivers that use v4l2_device should use the | 207 | * TODO: In the long run all drivers that use v4l2_device should use the |
208 | * v4l2_device release callback. This check will then be unnecessary. | 208 | * v4l2_device release callback. This check will then be unnecessary. |
209 | */ | 209 | */ |
210 | if (v4l2_dev && v4l2_dev->release == NULL) | 210 | if (v4l2_dev->release == NULL) |
211 | v4l2_dev = NULL; | 211 | v4l2_dev = NULL; |
212 | 212 | ||
213 | /* Release video_device and perform other | 213 | /* Release video_device and perform other |
@@ -360,27 +360,22 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
360 | * hack but it will have to do for those drivers that are not | 360 | * hack but it will have to do for those drivers that are not |
361 | * yet converted to use unlocked_ioctl. | 361 | * yet converted to use unlocked_ioctl. |
362 | * | 362 | * |
363 | * There are two options: if the driver implements struct | 363 | * All drivers implement struct v4l2_device, so we use the |
364 | * v4l2_device, then the lock defined there is used to | 364 | * lock defined there to serialize the ioctls. |
365 | * serialize the ioctls. Otherwise the v4l2 core lock defined | ||
366 | * below is used. This lock is really bad since it serializes | ||
367 | * completely independent devices. | ||
368 | * | 365 | * |
369 | * Both variants suffer from the same problem: if the driver | 366 | * However, if the driver sleeps, then it blocks all ioctls |
370 | * sleeps, then it blocks all ioctls since the lock is still | 367 | * since the lock is still held. This is very common for |
371 | * held. This is very common for VIDIOC_DQBUF since that | 368 | * VIDIOC_DQBUF since that normally waits for a frame to arrive. |
372 | * normally waits for a frame to arrive. As a result any other | 369 | * As a result any other ioctl calls will proceed very, very |
373 | * ioctl calls will proceed very, very slowly since each call | 370 | * slowly since each call will have to wait for the VIDIOC_QBUF |
374 | * will have to wait for the VIDIOC_QBUF to finish. Things that | 371 | * to finish. Things that should take 0.01s may now take 10-20 |
375 | * should take 0.01s may now take 10-20 seconds. | 372 | * seconds. |
376 | * | 373 | * |
377 | * The workaround is to *not* take the lock for VIDIOC_DQBUF. | 374 | * The workaround is to *not* take the lock for VIDIOC_DQBUF. |
378 | * This actually works OK for videobuf-based drivers, since | 375 | * This actually works OK for videobuf-based drivers, since |
379 | * videobuf will take its own internal lock. | 376 | * videobuf will take its own internal lock. |
380 | */ | 377 | */ |
381 | static DEFINE_MUTEX(v4l2_ioctl_mutex); | 378 | struct mutex *m = &vdev->v4l2_dev->ioctl_lock; |
382 | struct mutex *m = vdev->v4l2_dev ? | ||
383 | &vdev->v4l2_dev->ioctl_lock : &v4l2_ioctl_mutex; | ||
384 | 379 | ||
385 | if (cmd != VIDIOC_DQBUF && mutex_lock_interruptible(m)) | 380 | if (cmd != VIDIOC_DQBUF && mutex_lock_interruptible(m)) |
386 | return -ERESTARTSYS; | 381 | return -ERESTARTSYS; |
@@ -938,12 +933,11 @@ int __video_register_device(struct video_device *vdev, int type, int nr, | |||
938 | name_base, nr, video_device_node_name(vdev)); | 933 | name_base, nr, video_device_node_name(vdev)); |
939 | 934 | ||
940 | /* Increase v4l2_device refcount */ | 935 | /* Increase v4l2_device refcount */ |
941 | if (vdev->v4l2_dev) | 936 | v4l2_device_get(vdev->v4l2_dev); |
942 | v4l2_device_get(vdev->v4l2_dev); | ||
943 | 937 | ||
944 | #if defined(CONFIG_MEDIA_CONTROLLER) | 938 | #if defined(CONFIG_MEDIA_CONTROLLER) |
945 | /* Part 5: Register the entity. */ | 939 | /* Part 5: Register the entity. */ |
946 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && | 940 | if (vdev->v4l2_dev->mdev && |
947 | vdev->vfl_type != VFL_TYPE_SUBDEV) { | 941 | vdev->vfl_type != VFL_TYPE_SUBDEV) { |
948 | vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; | 942 | vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; |
949 | vdev->entity.name = vdev->name; | 943 | vdev->entity.name = vdev->name; |
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9ccb19a435ef..75658717961f 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -257,7 +257,7 @@ static void v4l_print_format(const void *arg, bool write_only) | |||
257 | pr_cont(", width=%u, height=%u, " | 257 | pr_cont(", width=%u, height=%u, " |
258 | "pixelformat=%c%c%c%c, field=%s, " | 258 | "pixelformat=%c%c%c%c, field=%s, " |
259 | "bytesperline=%u, sizeimage=%u, colorspace=%d, " | 259 | "bytesperline=%u, sizeimage=%u, colorspace=%d, " |
260 | "flags %u\n", | 260 | "flags %x, ycbcr_enc=%u, quantization=%u\n", |
261 | pix->width, pix->height, | 261 | pix->width, pix->height, |
262 | (pix->pixelformat & 0xff), | 262 | (pix->pixelformat & 0xff), |
263 | (pix->pixelformat >> 8) & 0xff, | 263 | (pix->pixelformat >> 8) & 0xff, |
@@ -265,21 +265,24 @@ static void v4l_print_format(const void *arg, bool write_only) | |||
265 | (pix->pixelformat >> 24) & 0xff, | 265 | (pix->pixelformat >> 24) & 0xff, |
266 | prt_names(pix->field, v4l2_field_names), | 266 | prt_names(pix->field, v4l2_field_names), |
267 | pix->bytesperline, pix->sizeimage, | 267 | pix->bytesperline, pix->sizeimage, |
268 | pix->colorspace, pix->flags); | 268 | pix->colorspace, pix->flags, pix->ycbcr_enc, |
269 | pix->quantization); | ||
269 | break; | 270 | break; |
270 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 271 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
271 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 272 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
272 | mp = &p->fmt.pix_mp; | 273 | mp = &p->fmt.pix_mp; |
273 | pr_cont(", width=%u, height=%u, " | 274 | pr_cont(", width=%u, height=%u, " |
274 | "format=%c%c%c%c, field=%s, " | 275 | "format=%c%c%c%c, field=%s, " |
275 | "colorspace=%d, num_planes=%u\n", | 276 | "colorspace=%d, num_planes=%u, flags=%x, " |
277 | "ycbcr_enc=%u, quantization=%u\n", | ||
276 | mp->width, mp->height, | 278 | mp->width, mp->height, |
277 | (mp->pixelformat & 0xff), | 279 | (mp->pixelformat & 0xff), |
278 | (mp->pixelformat >> 8) & 0xff, | 280 | (mp->pixelformat >> 8) & 0xff, |
279 | (mp->pixelformat >> 16) & 0xff, | 281 | (mp->pixelformat >> 16) & 0xff, |
280 | (mp->pixelformat >> 24) & 0xff, | 282 | (mp->pixelformat >> 24) & 0xff, |
281 | prt_names(mp->field, v4l2_field_names), | 283 | prt_names(mp->field, v4l2_field_names), |
282 | mp->colorspace, mp->num_planes); | 284 | mp->colorspace, mp->num_planes, mp->flags, |
285 | mp->ycbcr_enc, mp->quantization); | ||
283 | for (i = 0; i < mp->num_planes; i++) | 286 | for (i = 0; i < mp->num_planes; i++) |
284 | printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, | 287 | printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, |
285 | mp->plane_fmt[i].bytesperline, | 288 | mp->plane_fmt[i].bytesperline, |
@@ -1040,7 +1043,7 @@ static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, | |||
1040 | if (ops->vidioc_g_priority) | 1043 | if (ops->vidioc_g_priority) |
1041 | return ops->vidioc_g_priority(file, fh, arg); | 1044 | return ops->vidioc_g_priority(file, fh, arg); |
1042 | vfd = video_devdata(file); | 1045 | vfd = video_devdata(file); |
1043 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); | 1046 | *p = v4l2_prio_max(vfd->prio); |
1044 | return 0; | 1047 | return 0; |
1045 | } | 1048 | } |
1046 | 1049 | ||
@@ -1055,7 +1058,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, | |||
1055 | return ops->vidioc_s_priority(file, fh, *p); | 1058 | return ops->vidioc_s_priority(file, fh, *p); |
1056 | vfd = video_devdata(file); | 1059 | vfd = video_devdata(file); |
1057 | vfh = file->private_data; | 1060 | vfh = file->private_data; |
1058 | return v4l2_prio_change(&vfd->v4l2_dev->prio, &vfh->prio, *p); | 1061 | return v4l2_prio_change(vfd->prio, &vfh->prio, *p); |
1059 | } | 1062 | } |
1060 | 1063 | ||
1061 | static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, | 1064 | static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, |
diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c index b91a266d0b7e..926836d1813a 100644 --- a/drivers/media/v4l2-core/videobuf-core.c +++ b/drivers/media/v4l2-core/videobuf-core.c | |||
@@ -51,6 +51,8 @@ MODULE_LICENSE("GPL"); | |||
51 | 51 | ||
52 | #define CALL(q, f, arg...) \ | 52 | #define CALL(q, f, arg...) \ |
53 | ((q->int_ops->f) ? q->int_ops->f(arg) : 0) | 53 | ((q->int_ops->f) ? q->int_ops->f(arg) : 0) |
54 | #define CALLPTR(q, f, arg...) \ | ||
55 | ((q->int_ops->f) ? q->int_ops->f(arg) : NULL) | ||
54 | 56 | ||
55 | struct videobuf_buffer *videobuf_alloc_vb(struct videobuf_queue *q) | 57 | struct videobuf_buffer *videobuf_alloc_vb(struct videobuf_queue *q) |
56 | { | 58 | { |
@@ -831,7 +833,7 @@ static int __videobuf_copy_to_user(struct videobuf_queue *q, | |||
831 | char __user *data, size_t count, | 833 | char __user *data, size_t count, |
832 | int nonblocking) | 834 | int nonblocking) |
833 | { | 835 | { |
834 | void *vaddr = CALL(q, vaddr, buf); | 836 | void *vaddr = CALLPTR(q, vaddr, buf); |
835 | 837 | ||
836 | /* copy to userspace */ | 838 | /* copy to userspace */ |
837 | if (count > buf->size - q->read_off) | 839 | if (count > buf->size - q->read_off) |
@@ -848,7 +850,7 @@ static int __videobuf_copy_stream(struct videobuf_queue *q, | |||
848 | char __user *data, size_t count, size_t pos, | 850 | char __user *data, size_t count, size_t pos, |
849 | int vbihack, int nonblocking) | 851 | int vbihack, int nonblocking) |
850 | { | 852 | { |
851 | unsigned int *fc = CALL(q, vaddr, buf); | 853 | unsigned int *fc = CALLPTR(q, vaddr, buf); |
852 | 854 | ||
853 | if (vbihack) { | 855 | if (vbihack) { |
854 | /* dirty, undocumented hack -- pass the frame counter | 856 | /* dirty, undocumented hack -- pass the frame counter |
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index f2e43de3dd87..d09a8916e940 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -189,6 +189,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q); | |||
189 | static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) | 189 | static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) |
190 | { | 190 | { |
191 | struct vb2_queue *q = vb->vb2_queue; | 191 | struct vb2_queue *q = vb->vb2_queue; |
192 | enum dma_data_direction dma_dir = | ||
193 | V4L2_TYPE_IS_OUTPUT(q->type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
192 | void *mem_priv; | 194 | void *mem_priv; |
193 | int plane; | 195 | int plane; |
194 | 196 | ||
@@ -200,7 +202,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) | |||
200 | unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]); | 202 | unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]); |
201 | 203 | ||
202 | mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane], | 204 | mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane], |
203 | size, q->gfp_flags); | 205 | size, dma_dir, q->gfp_flags); |
204 | if (IS_ERR_OR_NULL(mem_priv)) | 206 | if (IS_ERR_OR_NULL(mem_priv)) |
205 | goto free; | 207 | goto free; |
206 | 208 | ||
@@ -1358,7 +1360,8 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1358 | void *mem_priv; | 1360 | void *mem_priv; |
1359 | unsigned int plane; | 1361 | unsigned int plane; |
1360 | int ret; | 1362 | int ret; |
1361 | int write = !V4L2_TYPE_IS_OUTPUT(q->type); | 1363 | enum dma_data_direction dma_dir = |
1364 | V4L2_TYPE_IS_OUTPUT(q->type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
1362 | bool reacquired = vb->planes[0].mem_priv == NULL; | 1365 | bool reacquired = vb->planes[0].mem_priv == NULL; |
1363 | 1366 | ||
1364 | memset(planes, 0, sizeof(planes[0]) * vb->num_planes); | 1367 | memset(planes, 0, sizeof(planes[0]) * vb->num_planes); |
@@ -1400,7 +1403,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1400 | /* Acquire each plane's memory */ | 1403 | /* Acquire each plane's memory */ |
1401 | mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane], | 1404 | mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane], |
1402 | planes[plane].m.userptr, | 1405 | planes[plane].m.userptr, |
1403 | planes[plane].length, write); | 1406 | planes[plane].length, dma_dir); |
1404 | if (IS_ERR_OR_NULL(mem_priv)) { | 1407 | if (IS_ERR_OR_NULL(mem_priv)) { |
1405 | dprintk(1, "failed acquiring userspace " | 1408 | dprintk(1, "failed acquiring userspace " |
1406 | "memory for plane %d\n", plane); | 1409 | "memory for plane %d\n", plane); |
@@ -1461,7 +1464,8 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1461 | void *mem_priv; | 1464 | void *mem_priv; |
1462 | unsigned int plane; | 1465 | unsigned int plane; |
1463 | int ret; | 1466 | int ret; |
1464 | int write = !V4L2_TYPE_IS_OUTPUT(q->type); | 1467 | enum dma_data_direction dma_dir = |
1468 | V4L2_TYPE_IS_OUTPUT(q->type) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
1465 | bool reacquired = vb->planes[0].mem_priv == NULL; | 1469 | bool reacquired = vb->planes[0].mem_priv == NULL; |
1466 | 1470 | ||
1467 | memset(planes, 0, sizeof(planes[0]) * vb->num_planes); | 1471 | memset(planes, 0, sizeof(planes[0]) * vb->num_planes); |
@@ -1509,7 +1513,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1509 | 1513 | ||
1510 | /* Acquire each plane's memory */ | 1514 | /* Acquire each plane's memory */ |
1511 | mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], | 1515 | mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], |
1512 | dbuf, planes[plane].length, write); | 1516 | dbuf, planes[plane].length, dma_dir); |
1513 | if (IS_ERR(mem_priv)) { | 1517 | if (IS_ERR(mem_priv)) { |
1514 | dprintk(1, "failed to attach dmabuf\n"); | 1518 | dprintk(1, "failed to attach dmabuf\n"); |
1515 | ret = PTR_ERR(mem_priv); | 1519 | ret = PTR_ERR(mem_priv); |
@@ -3385,14 +3389,14 @@ int _vb2_fop_release(struct file *file, struct mutex *lock) | |||
3385 | { | 3389 | { |
3386 | struct video_device *vdev = video_devdata(file); | 3390 | struct video_device *vdev = video_devdata(file); |
3387 | 3391 | ||
3392 | if (lock) | ||
3393 | mutex_lock(lock); | ||
3388 | if (file->private_data == vdev->queue->owner) { | 3394 | if (file->private_data == vdev->queue->owner) { |
3389 | if (lock) | ||
3390 | mutex_lock(lock); | ||
3391 | vb2_queue_release(vdev->queue); | 3395 | vb2_queue_release(vdev->queue); |
3392 | vdev->queue->owner = NULL; | 3396 | vdev->queue->owner = NULL; |
3393 | if (lock) | ||
3394 | mutex_unlock(lock); | ||
3395 | } | 3397 | } |
3398 | if (lock) | ||
3399 | mutex_unlock(lock); | ||
3396 | return v4l2_fh_release(file); | 3400 | return v4l2_fh_release(file); |
3397 | } | 3401 | } |
3398 | EXPORT_SYMBOL_GPL(_vb2_fop_release); | 3402 | EXPORT_SYMBOL_GPL(_vb2_fop_release); |
@@ -3455,27 +3459,16 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) | |||
3455 | struct video_device *vdev = video_devdata(file); | 3459 | struct video_device *vdev = video_devdata(file); |
3456 | struct vb2_queue *q = vdev->queue; | 3460 | struct vb2_queue *q = vdev->queue; |
3457 | struct mutex *lock = q->lock ? q->lock : vdev->lock; | 3461 | struct mutex *lock = q->lock ? q->lock : vdev->lock; |
3458 | unsigned long req_events = poll_requested_events(wait); | ||
3459 | unsigned res; | 3462 | unsigned res; |
3460 | void *fileio; | 3463 | void *fileio; |
3461 | bool must_lock = false; | ||
3462 | |||
3463 | /* Try to be smart: only lock if polling might start fileio, | ||
3464 | otherwise locking will only introduce unwanted delays. */ | ||
3465 | if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) { | ||
3466 | if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) && | ||
3467 | (req_events & (POLLIN | POLLRDNORM))) | ||
3468 | must_lock = true; | ||
3469 | else if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE) && | ||
3470 | (req_events & (POLLOUT | POLLWRNORM))) | ||
3471 | must_lock = true; | ||
3472 | } | ||
3473 | 3464 | ||
3474 | /* If locking is needed, but this helper doesn't know how, then you | 3465 | /* |
3475 | shouldn't be using this helper but you should write your own. */ | 3466 | * If this helper doesn't know how to lock, then you shouldn't be using |
3476 | WARN_ON(must_lock && !lock); | 3467 | * it but you should write your own. |
3468 | */ | ||
3469 | WARN_ON(!lock); | ||
3477 | 3470 | ||
3478 | if (must_lock && lock && mutex_lock_interruptible(lock)) | 3471 | if (lock && mutex_lock_interruptible(lock)) |
3479 | return POLLERR; | 3472 | return POLLERR; |
3480 | 3473 | ||
3481 | fileio = q->fileio; | 3474 | fileio = q->fileio; |
@@ -3483,9 +3476,9 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) | |||
3483 | res = vb2_poll(vdev->queue, file, wait); | 3476 | res = vb2_poll(vdev->queue, file, wait); |
3484 | 3477 | ||
3485 | /* If fileio was started, then we have a new queue owner. */ | 3478 | /* If fileio was started, then we have a new queue owner. */ |
3486 | if (must_lock && !fileio && q->fileio) | 3479 | if (!fileio && q->fileio) |
3487 | q->owner = file->private_data; | 3480 | q->owner = file->private_data; |
3488 | if (must_lock && lock) | 3481 | if (lock) |
3489 | mutex_unlock(lock); | 3482 | mutex_unlock(lock); |
3490 | return res; | 3483 | return res; |
3491 | } | 3484 | } |
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 4a02ade14b4f..b481d20c8372 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c | |||
@@ -155,7 +155,8 @@ static void vb2_dc_put(void *buf_priv) | |||
155 | kfree(buf); | 155 | kfree(buf); |
156 | } | 156 | } |
157 | 157 | ||
158 | static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) | 158 | static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, |
159 | enum dma_data_direction dma_dir, gfp_t gfp_flags) | ||
159 | { | 160 | { |
160 | struct vb2_dc_conf *conf = alloc_ctx; | 161 | struct vb2_dc_conf *conf = alloc_ctx; |
161 | struct device *dev = conf->dev; | 162 | struct device *dev = conf->dev; |
@@ -176,6 +177,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) | |||
176 | /* Prevent the device from being released while the buffer is used */ | 177 | /* Prevent the device from being released while the buffer is used */ |
177 | buf->dev = get_device(dev); | 178 | buf->dev = get_device(dev); |
178 | buf->size = size; | 179 | buf->size = size; |
180 | buf->dma_dir = dma_dir; | ||
179 | 181 | ||
180 | buf->handler.refcount = &buf->refcount; | 182 | buf->handler.refcount = &buf->refcount; |
181 | buf->handler.put = vb2_dc_put; | 183 | buf->handler.put = vb2_dc_put; |
@@ -229,7 +231,7 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma) | |||
229 | 231 | ||
230 | struct vb2_dc_attachment { | 232 | struct vb2_dc_attachment { |
231 | struct sg_table sgt; | 233 | struct sg_table sgt; |
232 | enum dma_data_direction dir; | 234 | enum dma_data_direction dma_dir; |
233 | }; | 235 | }; |
234 | 236 | ||
235 | static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev, | 237 | static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev, |
@@ -264,7 +266,7 @@ static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev, | |||
264 | wr = sg_next(wr); | 266 | wr = sg_next(wr); |
265 | } | 267 | } |
266 | 268 | ||
267 | attach->dir = DMA_NONE; | 269 | attach->dma_dir = DMA_NONE; |
268 | dbuf_attach->priv = attach; | 270 | dbuf_attach->priv = attach; |
269 | 271 | ||
270 | return 0; | 272 | return 0; |
@@ -282,16 +284,16 @@ static void vb2_dc_dmabuf_ops_detach(struct dma_buf *dbuf, | |||
282 | sgt = &attach->sgt; | 284 | sgt = &attach->sgt; |
283 | 285 | ||
284 | /* release the scatterlist cache */ | 286 | /* release the scatterlist cache */ |
285 | if (attach->dir != DMA_NONE) | 287 | if (attach->dma_dir != DMA_NONE) |
286 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | 288 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, |
287 | attach->dir); | 289 | attach->dma_dir); |
288 | sg_free_table(sgt); | 290 | sg_free_table(sgt); |
289 | kfree(attach); | 291 | kfree(attach); |
290 | db_attach->priv = NULL; | 292 | db_attach->priv = NULL; |
291 | } | 293 | } |
292 | 294 | ||
293 | static struct sg_table *vb2_dc_dmabuf_ops_map( | 295 | static struct sg_table *vb2_dc_dmabuf_ops_map( |
294 | struct dma_buf_attachment *db_attach, enum dma_data_direction dir) | 296 | struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir) |
295 | { | 297 | { |
296 | struct vb2_dc_attachment *attach = db_attach->priv; | 298 | struct vb2_dc_attachment *attach = db_attach->priv; |
297 | /* stealing dmabuf mutex to serialize map/unmap operations */ | 299 | /* stealing dmabuf mutex to serialize map/unmap operations */ |
@@ -303,27 +305,27 @@ static struct sg_table *vb2_dc_dmabuf_ops_map( | |||
303 | 305 | ||
304 | sgt = &attach->sgt; | 306 | sgt = &attach->sgt; |
305 | /* return previously mapped sg table */ | 307 | /* return previously mapped sg table */ |
306 | if (attach->dir == dir) { | 308 | if (attach->dma_dir == dma_dir) { |
307 | mutex_unlock(lock); | 309 | mutex_unlock(lock); |
308 | return sgt; | 310 | return sgt; |
309 | } | 311 | } |
310 | 312 | ||
311 | /* release any previous cache */ | 313 | /* release any previous cache */ |
312 | if (attach->dir != DMA_NONE) { | 314 | if (attach->dma_dir != DMA_NONE) { |
313 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | 315 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, |
314 | attach->dir); | 316 | attach->dma_dir); |
315 | attach->dir = DMA_NONE; | 317 | attach->dma_dir = DMA_NONE; |
316 | } | 318 | } |
317 | 319 | ||
318 | /* mapping to the client with new direction */ | 320 | /* mapping to the client with new direction */ |
319 | ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dir); | 321 | ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dma_dir); |
320 | if (ret <= 0) { | 322 | if (ret <= 0) { |
321 | pr_err("failed to map scatterlist\n"); | 323 | pr_err("failed to map scatterlist\n"); |
322 | mutex_unlock(lock); | 324 | mutex_unlock(lock); |
323 | return ERR_PTR(-EIO); | 325 | return ERR_PTR(-EIO); |
324 | } | 326 | } |
325 | 327 | ||
326 | attach->dir = dir; | 328 | attach->dma_dir = dma_dir; |
327 | 329 | ||
328 | mutex_unlock(lock); | 330 | mutex_unlock(lock); |
329 | 331 | ||
@@ -331,7 +333,7 @@ static struct sg_table *vb2_dc_dmabuf_ops_map( | |||
331 | } | 333 | } |
332 | 334 | ||
333 | static void vb2_dc_dmabuf_ops_unmap(struct dma_buf_attachment *db_attach, | 335 | static void vb2_dc_dmabuf_ops_unmap(struct dma_buf_attachment *db_attach, |
334 | struct sg_table *sgt, enum dma_data_direction dir) | 336 | struct sg_table *sgt, enum dma_data_direction dma_dir) |
335 | { | 337 | { |
336 | /* nothing to be done here */ | 338 | /* nothing to be done here */ |
337 | } | 339 | } |
@@ -460,7 +462,8 @@ static int vb2_dc_get_user_pfn(unsigned long start, int n_pages, | |||
460 | } | 462 | } |
461 | 463 | ||
462 | static int vb2_dc_get_user_pages(unsigned long start, struct page **pages, | 464 | static int vb2_dc_get_user_pages(unsigned long start, struct page **pages, |
463 | int n_pages, struct vm_area_struct *vma, int write) | 465 | int n_pages, struct vm_area_struct *vma, |
466 | enum dma_data_direction dma_dir) | ||
464 | { | 467 | { |
465 | if (vma_is_io(vma)) { | 468 | if (vma_is_io(vma)) { |
466 | unsigned int i; | 469 | unsigned int i; |
@@ -482,7 +485,7 @@ static int vb2_dc_get_user_pages(unsigned long start, struct page **pages, | |||
482 | int n; | 485 | int n; |
483 | 486 | ||
484 | n = get_user_pages(current, current->mm, start & PAGE_MASK, | 487 | n = get_user_pages(current, current->mm, start & PAGE_MASK, |
485 | n_pages, write, 1, pages, NULL); | 488 | n_pages, dma_dir == DMA_FROM_DEVICE, 1, pages, NULL); |
486 | /* negative error means that no page was pinned */ | 489 | /* negative error means that no page was pinned */ |
487 | n = max(n, 0); | 490 | n = max(n, 0); |
488 | if (n != n_pages) { | 491 | if (n != n_pages) { |
@@ -508,7 +511,15 @@ static void vb2_dc_put_userptr(void *buf_priv) | |||
508 | struct sg_table *sgt = buf->dma_sgt; | 511 | struct sg_table *sgt = buf->dma_sgt; |
509 | 512 | ||
510 | if (sgt) { | 513 | if (sgt) { |
511 | dma_unmap_sg(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir); | 514 | DEFINE_DMA_ATTRS(attrs); |
515 | |||
516 | dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); | ||
517 | /* | ||
518 | * No need to sync to CPU, it's already synced to the CPU | ||
519 | * since the finish() memop will have been called before this. | ||
520 | */ | ||
521 | dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, | ||
522 | buf->dma_dir, &attrs); | ||
512 | if (!vma_is_io(buf->vma)) | 523 | if (!vma_is_io(buf->vma)) |
513 | vb2_dc_sgt_foreach_page(sgt, vb2_dc_put_dirty_page); | 524 | vb2_dc_sgt_foreach_page(sgt, vb2_dc_put_dirty_page); |
514 | 525 | ||
@@ -551,7 +562,7 @@ static inline dma_addr_t vb2_dc_pfn_to_dma(struct device *dev, unsigned long pfn | |||
551 | #endif | 562 | #endif |
552 | 563 | ||
553 | static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, | 564 | static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, |
554 | unsigned long size, int write) | 565 | unsigned long size, enum dma_data_direction dma_dir) |
555 | { | 566 | { |
556 | struct vb2_dc_conf *conf = alloc_ctx; | 567 | struct vb2_dc_conf *conf = alloc_ctx; |
557 | struct vb2_dc_buf *buf; | 568 | struct vb2_dc_buf *buf; |
@@ -565,6 +576,9 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
565 | struct sg_table *sgt; | 576 | struct sg_table *sgt; |
566 | unsigned long contig_size; | 577 | unsigned long contig_size; |
567 | unsigned long dma_align = dma_get_cache_alignment(); | 578 | unsigned long dma_align = dma_get_cache_alignment(); |
579 | DEFINE_DMA_ATTRS(attrs); | ||
580 | |||
581 | dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); | ||
568 | 582 | ||
569 | /* Only cache aligned DMA transfers are reliable */ | 583 | /* Only cache aligned DMA transfers are reliable */ |
570 | if (!IS_ALIGNED(vaddr | size, dma_align)) { | 584 | if (!IS_ALIGNED(vaddr | size, dma_align)) { |
@@ -582,7 +596,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
582 | return ERR_PTR(-ENOMEM); | 596 | return ERR_PTR(-ENOMEM); |
583 | 597 | ||
584 | buf->dev = conf->dev; | 598 | buf->dev = conf->dev; |
585 | buf->dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | 599 | buf->dma_dir = dma_dir; |
586 | 600 | ||
587 | start = vaddr & PAGE_MASK; | 601 | start = vaddr & PAGE_MASK; |
588 | offset = vaddr & ~PAGE_MASK; | 602 | offset = vaddr & ~PAGE_MASK; |
@@ -618,7 +632,8 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
618 | } | 632 | } |
619 | 633 | ||
620 | /* extract page list from userspace mapping */ | 634 | /* extract page list from userspace mapping */ |
621 | ret = vb2_dc_get_user_pages(start, pages, n_pages, vma, write); | 635 | ret = vb2_dc_get_user_pages(start, pages, n_pages, vma, |
636 | dma_dir == DMA_FROM_DEVICE); | ||
622 | if (ret) { | 637 | if (ret) { |
623 | unsigned long pfn; | 638 | unsigned long pfn; |
624 | if (vb2_dc_get_user_pfn(start, n_pages, vma, &pfn) == 0) { | 639 | if (vb2_dc_get_user_pfn(start, n_pages, vma, &pfn) == 0) { |
@@ -650,8 +665,12 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
650 | kfree(pages); | 665 | kfree(pages); |
651 | pages = NULL; | 666 | pages = NULL; |
652 | 667 | ||
653 | sgt->nents = dma_map_sg(buf->dev, sgt->sgl, sgt->orig_nents, | 668 | /* |
654 | buf->dma_dir); | 669 | * No need to sync to the device, this will happen later when the |
670 | * prepare() memop is called. | ||
671 | */ | ||
672 | sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, | ||
673 | buf->dma_dir, &attrs); | ||
655 | if (sgt->nents <= 0) { | 674 | if (sgt->nents <= 0) { |
656 | pr_err("failed to map scatterlist\n"); | 675 | pr_err("failed to map scatterlist\n"); |
657 | ret = -EIO; | 676 | ret = -EIO; |
@@ -673,7 +692,8 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
673 | return buf; | 692 | return buf; |
674 | 693 | ||
675 | fail_map_sg: | 694 | fail_map_sg: |
676 | dma_unmap_sg(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir); | 695 | dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, |
696 | buf->dma_dir, &attrs); | ||
677 | 697 | ||
678 | fail_sgt_init: | 698 | fail_sgt_init: |
679 | if (!vma_is_io(buf->vma)) | 699 | if (!vma_is_io(buf->vma)) |
@@ -782,7 +802,7 @@ static void vb2_dc_detach_dmabuf(void *mem_priv) | |||
782 | } | 802 | } |
783 | 803 | ||
784 | static void *vb2_dc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, | 804 | static void *vb2_dc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, |
785 | unsigned long size, int write) | 805 | unsigned long size, enum dma_data_direction dma_dir) |
786 | { | 806 | { |
787 | struct vb2_dc_conf *conf = alloc_ctx; | 807 | struct vb2_dc_conf *conf = alloc_ctx; |
788 | struct vb2_dc_buf *buf; | 808 | struct vb2_dc_buf *buf; |
@@ -804,7 +824,7 @@ static void *vb2_dc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, | |||
804 | return dba; | 824 | return dba; |
805 | } | 825 | } |
806 | 826 | ||
807 | buf->dma_dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | 827 | buf->dma_dir = dma_dir; |
808 | buf->size = size; | 828 | buf->size = size; |
809 | buf->db_attach = dba; | 829 | buf->db_attach = dba; |
810 | 830 | ||
@@ -850,7 +870,8 @@ EXPORT_SYMBOL_GPL(vb2_dma_contig_init_ctx); | |||
850 | 870 | ||
851 | void vb2_dma_contig_cleanup_ctx(void *alloc_ctx) | 871 | void vb2_dma_contig_cleanup_ctx(void *alloc_ctx) |
852 | { | 872 | { |
853 | kfree(alloc_ctx); | 873 | if (!IS_ERR_OR_NULL(alloc_ctx)) |
874 | kfree(alloc_ctx); | ||
854 | } | 875 | } |
855 | EXPORT_SYMBOL_GPL(vb2_dma_contig_cleanup_ctx); | 876 | EXPORT_SYMBOL_GPL(vb2_dma_contig_cleanup_ctx); |
856 | 877 | ||
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index 9b163a440f89..b1838abb6d00 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c | |||
@@ -30,17 +30,30 @@ module_param(debug, int, 0644); | |||
30 | printk(KERN_DEBUG "vb2-dma-sg: " fmt, ## arg); \ | 30 | printk(KERN_DEBUG "vb2-dma-sg: " fmt, ## arg); \ |
31 | } while (0) | 31 | } while (0) |
32 | 32 | ||
33 | struct vb2_dma_sg_conf { | ||
34 | struct device *dev; | ||
35 | }; | ||
36 | |||
33 | struct vb2_dma_sg_buf { | 37 | struct vb2_dma_sg_buf { |
38 | struct device *dev; | ||
34 | void *vaddr; | 39 | void *vaddr; |
35 | struct page **pages; | 40 | struct page **pages; |
36 | int write; | ||
37 | int offset; | 41 | int offset; |
42 | enum dma_data_direction dma_dir; | ||
38 | struct sg_table sg_table; | 43 | struct sg_table sg_table; |
44 | /* | ||
45 | * This will point to sg_table when used with the MMAP or USERPTR | ||
46 | * memory model, and to the dma_buf sglist when used with the | ||
47 | * DMABUF memory model. | ||
48 | */ | ||
49 | struct sg_table *dma_sgt; | ||
39 | size_t size; | 50 | size_t size; |
40 | unsigned int num_pages; | 51 | unsigned int num_pages; |
41 | atomic_t refcount; | 52 | atomic_t refcount; |
42 | struct vb2_vmarea_handler handler; | 53 | struct vb2_vmarea_handler handler; |
43 | struct vm_area_struct *vma; | 54 | struct vm_area_struct *vma; |
55 | |||
56 | struct dma_buf_attachment *db_attach; | ||
44 | }; | 57 | }; |
45 | 58 | ||
46 | static void vb2_dma_sg_put(void *buf_priv); | 59 | static void vb2_dma_sg_put(void *buf_priv); |
@@ -86,22 +99,31 @@ static int vb2_dma_sg_alloc_compacted(struct vb2_dma_sg_buf *buf, | |||
86 | return 0; | 99 | return 0; |
87 | } | 100 | } |
88 | 101 | ||
89 | static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) | 102 | static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, |
103 | enum dma_data_direction dma_dir, gfp_t gfp_flags) | ||
90 | { | 104 | { |
105 | struct vb2_dma_sg_conf *conf = alloc_ctx; | ||
91 | struct vb2_dma_sg_buf *buf; | 106 | struct vb2_dma_sg_buf *buf; |
107 | struct sg_table *sgt; | ||
92 | int ret; | 108 | int ret; |
93 | int num_pages; | 109 | int num_pages; |
110 | DEFINE_DMA_ATTRS(attrs); | ||
94 | 111 | ||
112 | dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); | ||
113 | |||
114 | if (WARN_ON(alloc_ctx == NULL)) | ||
115 | return NULL; | ||
95 | buf = kzalloc(sizeof *buf, GFP_KERNEL); | 116 | buf = kzalloc(sizeof *buf, GFP_KERNEL); |
96 | if (!buf) | 117 | if (!buf) |
97 | return NULL; | 118 | return NULL; |
98 | 119 | ||
99 | buf->vaddr = NULL; | 120 | buf->vaddr = NULL; |
100 | buf->write = 0; | 121 | buf->dma_dir = dma_dir; |
101 | buf->offset = 0; | 122 | buf->offset = 0; |
102 | buf->size = size; | 123 | buf->size = size; |
103 | /* size is already page aligned */ | 124 | /* size is already page aligned */ |
104 | buf->num_pages = size >> PAGE_SHIFT; | 125 | buf->num_pages = size >> PAGE_SHIFT; |
126 | buf->dma_sgt = &buf->sg_table; | ||
105 | 127 | ||
106 | buf->pages = kzalloc(buf->num_pages * sizeof(struct page *), | 128 | buf->pages = kzalloc(buf->num_pages * sizeof(struct page *), |
107 | GFP_KERNEL); | 129 | GFP_KERNEL); |
@@ -112,11 +134,23 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fla | |||
112 | if (ret) | 134 | if (ret) |
113 | goto fail_pages_alloc; | 135 | goto fail_pages_alloc; |
114 | 136 | ||
115 | ret = sg_alloc_table_from_pages(&buf->sg_table, buf->pages, | 137 | ret = sg_alloc_table_from_pages(buf->dma_sgt, buf->pages, |
116 | buf->num_pages, 0, size, GFP_KERNEL); | 138 | buf->num_pages, 0, size, GFP_KERNEL); |
117 | if (ret) | 139 | if (ret) |
118 | goto fail_table_alloc; | 140 | goto fail_table_alloc; |
119 | 141 | ||
142 | /* Prevent the device from being released while the buffer is used */ | ||
143 | buf->dev = get_device(conf->dev); | ||
144 | |||
145 | sgt = &buf->sg_table; | ||
146 | /* | ||
147 | * No need to sync to the device, this will happen later when the | ||
148 | * prepare() memop is called. | ||
149 | */ | ||
150 | if (dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->nents, | ||
151 | buf->dma_dir, &attrs) == 0) | ||
152 | goto fail_map; | ||
153 | |||
120 | buf->handler.refcount = &buf->refcount; | 154 | buf->handler.refcount = &buf->refcount; |
121 | buf->handler.put = vb2_dma_sg_put; | 155 | buf->handler.put = vb2_dma_sg_put; |
122 | buf->handler.arg = buf; | 156 | buf->handler.arg = buf; |
@@ -127,6 +161,9 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fla | |||
127 | __func__, buf->num_pages); | 161 | __func__, buf->num_pages); |
128 | return buf; | 162 | return buf; |
129 | 163 | ||
164 | fail_map: | ||
165 | put_device(buf->dev); | ||
166 | sg_free_table(buf->dma_sgt); | ||
130 | fail_table_alloc: | 167 | fail_table_alloc: |
131 | num_pages = buf->num_pages; | 168 | num_pages = buf->num_pages; |
132 | while (num_pages--) | 169 | while (num_pages--) |
@@ -141,42 +178,81 @@ fail_pages_array_alloc: | |||
141 | static void vb2_dma_sg_put(void *buf_priv) | 178 | static void vb2_dma_sg_put(void *buf_priv) |
142 | { | 179 | { |
143 | struct vb2_dma_sg_buf *buf = buf_priv; | 180 | struct vb2_dma_sg_buf *buf = buf_priv; |
181 | struct sg_table *sgt = &buf->sg_table; | ||
144 | int i = buf->num_pages; | 182 | int i = buf->num_pages; |
145 | 183 | ||
146 | if (atomic_dec_and_test(&buf->refcount)) { | 184 | if (atomic_dec_and_test(&buf->refcount)) { |
185 | DEFINE_DMA_ATTRS(attrs); | ||
186 | |||
187 | dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); | ||
147 | dprintk(1, "%s: Freeing buffer of %d pages\n", __func__, | 188 | dprintk(1, "%s: Freeing buffer of %d pages\n", __func__, |
148 | buf->num_pages); | 189 | buf->num_pages); |
190 | dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->nents, | ||
191 | buf->dma_dir, &attrs); | ||
149 | if (buf->vaddr) | 192 | if (buf->vaddr) |
150 | vm_unmap_ram(buf->vaddr, buf->num_pages); | 193 | vm_unmap_ram(buf->vaddr, buf->num_pages); |
151 | sg_free_table(&buf->sg_table); | 194 | sg_free_table(buf->dma_sgt); |
152 | while (--i >= 0) | 195 | while (--i >= 0) |
153 | __free_page(buf->pages[i]); | 196 | __free_page(buf->pages[i]); |
154 | kfree(buf->pages); | 197 | kfree(buf->pages); |
198 | put_device(buf->dev); | ||
155 | kfree(buf); | 199 | kfree(buf); |
156 | } | 200 | } |
157 | } | 201 | } |
158 | 202 | ||
203 | static void vb2_dma_sg_prepare(void *buf_priv) | ||
204 | { | ||
205 | struct vb2_dma_sg_buf *buf = buf_priv; | ||
206 | struct sg_table *sgt = buf->dma_sgt; | ||
207 | |||
208 | /* DMABUF exporter will flush the cache for us */ | ||
209 | if (buf->db_attach) | ||
210 | return; | ||
211 | |||
212 | dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); | ||
213 | } | ||
214 | |||
215 | static void vb2_dma_sg_finish(void *buf_priv) | ||
216 | { | ||
217 | struct vb2_dma_sg_buf *buf = buf_priv; | ||
218 | struct sg_table *sgt = buf->dma_sgt; | ||
219 | |||
220 | /* DMABUF exporter will flush the cache for us */ | ||
221 | if (buf->db_attach) | ||
222 | return; | ||
223 | |||
224 | dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); | ||
225 | } | ||
226 | |||
159 | static inline int vma_is_io(struct vm_area_struct *vma) | 227 | static inline int vma_is_io(struct vm_area_struct *vma) |
160 | { | 228 | { |
161 | return !!(vma->vm_flags & (VM_IO | VM_PFNMAP)); | 229 | return !!(vma->vm_flags & (VM_IO | VM_PFNMAP)); |
162 | } | 230 | } |
163 | 231 | ||
164 | static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, | 232 | static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, |
165 | unsigned long size, int write) | 233 | unsigned long size, |
234 | enum dma_data_direction dma_dir) | ||
166 | { | 235 | { |
236 | struct vb2_dma_sg_conf *conf = alloc_ctx; | ||
167 | struct vb2_dma_sg_buf *buf; | 237 | struct vb2_dma_sg_buf *buf; |
168 | unsigned long first, last; | 238 | unsigned long first, last; |
169 | int num_pages_from_user; | 239 | int num_pages_from_user; |
170 | struct vm_area_struct *vma; | 240 | struct vm_area_struct *vma; |
241 | struct sg_table *sgt; | ||
242 | DEFINE_DMA_ATTRS(attrs); | ||
243 | |||
244 | dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); | ||
171 | 245 | ||
172 | buf = kzalloc(sizeof *buf, GFP_KERNEL); | 246 | buf = kzalloc(sizeof *buf, GFP_KERNEL); |
173 | if (!buf) | 247 | if (!buf) |
174 | return NULL; | 248 | return NULL; |
175 | 249 | ||
176 | buf->vaddr = NULL; | 250 | buf->vaddr = NULL; |
177 | buf->write = write; | 251 | buf->dev = conf->dev; |
252 | buf->dma_dir = dma_dir; | ||
178 | buf->offset = vaddr & ~PAGE_MASK; | 253 | buf->offset = vaddr & ~PAGE_MASK; |
179 | buf->size = size; | 254 | buf->size = size; |
255 | buf->dma_sgt = &buf->sg_table; | ||
180 | 256 | ||
181 | first = (vaddr & PAGE_MASK) >> PAGE_SHIFT; | 257 | first = (vaddr & PAGE_MASK) >> PAGE_SHIFT; |
182 | last = ((vaddr + size - 1) & PAGE_MASK) >> PAGE_SHIFT; | 258 | last = ((vaddr + size - 1) & PAGE_MASK) >> PAGE_SHIFT; |
@@ -221,7 +297,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
221 | num_pages_from_user = get_user_pages(current, current->mm, | 297 | num_pages_from_user = get_user_pages(current, current->mm, |
222 | vaddr & PAGE_MASK, | 298 | vaddr & PAGE_MASK, |
223 | buf->num_pages, | 299 | buf->num_pages, |
224 | write, | 300 | buf->dma_dir == DMA_FROM_DEVICE, |
225 | 1, /* force */ | 301 | 1, /* force */ |
226 | buf->pages, | 302 | buf->pages, |
227 | NULL); | 303 | NULL); |
@@ -229,12 +305,22 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
229 | if (num_pages_from_user != buf->num_pages) | 305 | if (num_pages_from_user != buf->num_pages) |
230 | goto userptr_fail_get_user_pages; | 306 | goto userptr_fail_get_user_pages; |
231 | 307 | ||
232 | if (sg_alloc_table_from_pages(&buf->sg_table, buf->pages, | 308 | if (sg_alloc_table_from_pages(buf->dma_sgt, buf->pages, |
233 | buf->num_pages, buf->offset, size, 0)) | 309 | buf->num_pages, buf->offset, size, 0)) |
234 | goto userptr_fail_alloc_table_from_pages; | 310 | goto userptr_fail_alloc_table_from_pages; |
235 | 311 | ||
312 | sgt = &buf->sg_table; | ||
313 | /* | ||
314 | * No need to sync to the device, this will happen later when the | ||
315 | * prepare() memop is called. | ||
316 | */ | ||
317 | if (dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->nents, | ||
318 | buf->dma_dir, &attrs) == 0) | ||
319 | goto userptr_fail_map; | ||
236 | return buf; | 320 | return buf; |
237 | 321 | ||
322 | userptr_fail_map: | ||
323 | sg_free_table(&buf->sg_table); | ||
238 | userptr_fail_alloc_table_from_pages: | 324 | userptr_fail_alloc_table_from_pages: |
239 | userptr_fail_get_user_pages: | 325 | userptr_fail_get_user_pages: |
240 | dprintk(1, "get_user_pages requested/got: %d/%d]\n", | 326 | dprintk(1, "get_user_pages requested/got: %d/%d]\n", |
@@ -257,15 +343,20 @@ userptr_fail_alloc_pages: | |||
257 | static void vb2_dma_sg_put_userptr(void *buf_priv) | 343 | static void vb2_dma_sg_put_userptr(void *buf_priv) |
258 | { | 344 | { |
259 | struct vb2_dma_sg_buf *buf = buf_priv; | 345 | struct vb2_dma_sg_buf *buf = buf_priv; |
346 | struct sg_table *sgt = &buf->sg_table; | ||
260 | int i = buf->num_pages; | 347 | int i = buf->num_pages; |
348 | DEFINE_DMA_ATTRS(attrs); | ||
349 | |||
350 | dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); | ||
261 | 351 | ||
262 | dprintk(1, "%s: Releasing userspace buffer of %d pages\n", | 352 | dprintk(1, "%s: Releasing userspace buffer of %d pages\n", |
263 | __func__, buf->num_pages); | 353 | __func__, buf->num_pages); |
354 | dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir, &attrs); | ||
264 | if (buf->vaddr) | 355 | if (buf->vaddr) |
265 | vm_unmap_ram(buf->vaddr, buf->num_pages); | 356 | vm_unmap_ram(buf->vaddr, buf->num_pages); |
266 | sg_free_table(&buf->sg_table); | 357 | sg_free_table(buf->dma_sgt); |
267 | while (--i >= 0) { | 358 | while (--i >= 0) { |
268 | if (buf->write) | 359 | if (buf->dma_dir == DMA_FROM_DEVICE) |
269 | set_page_dirty_lock(buf->pages[i]); | 360 | set_page_dirty_lock(buf->pages[i]); |
270 | if (!vma_is_io(buf->vma)) | 361 | if (!vma_is_io(buf->vma)) |
271 | put_page(buf->pages[i]); | 362 | put_page(buf->pages[i]); |
@@ -281,14 +372,16 @@ static void *vb2_dma_sg_vaddr(void *buf_priv) | |||
281 | 372 | ||
282 | BUG_ON(!buf); | 373 | BUG_ON(!buf); |
283 | 374 | ||
284 | if (!buf->vaddr) | 375 | if (!buf->vaddr) { |
285 | buf->vaddr = vm_map_ram(buf->pages, | 376 | if (buf->db_attach) |
286 | buf->num_pages, | 377 | buf->vaddr = dma_buf_vmap(buf->db_attach->dmabuf); |
287 | -1, | 378 | else |
288 | PAGE_KERNEL); | 379 | buf->vaddr = vm_map_ram(buf->pages, |
380 | buf->num_pages, -1, PAGE_KERNEL); | ||
381 | } | ||
289 | 382 | ||
290 | /* add offset in case userptr is not page-aligned */ | 383 | /* add offset in case userptr is not page-aligned */ |
291 | return buf->vaddr + buf->offset; | 384 | return buf->vaddr ? buf->vaddr + buf->offset : NULL; |
292 | } | 385 | } |
293 | 386 | ||
294 | static unsigned int vb2_dma_sg_num_users(void *buf_priv) | 387 | static unsigned int vb2_dma_sg_num_users(void *buf_priv) |
@@ -335,11 +428,279 @@ static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma) | |||
335 | return 0; | 428 | return 0; |
336 | } | 429 | } |
337 | 430 | ||
431 | /*********************************************/ | ||
432 | /* DMABUF ops for exporters */ | ||
433 | /*********************************************/ | ||
434 | |||
435 | struct vb2_dma_sg_attachment { | ||
436 | struct sg_table sgt; | ||
437 | enum dma_data_direction dma_dir; | ||
438 | }; | ||
439 | |||
440 | static int vb2_dma_sg_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev, | ||
441 | struct dma_buf_attachment *dbuf_attach) | ||
442 | { | ||
443 | struct vb2_dma_sg_attachment *attach; | ||
444 | unsigned int i; | ||
445 | struct scatterlist *rd, *wr; | ||
446 | struct sg_table *sgt; | ||
447 | struct vb2_dma_sg_buf *buf = dbuf->priv; | ||
448 | int ret; | ||
449 | |||
450 | attach = kzalloc(sizeof(*attach), GFP_KERNEL); | ||
451 | if (!attach) | ||
452 | return -ENOMEM; | ||
453 | |||
454 | sgt = &attach->sgt; | ||
455 | /* Copy the buf->base_sgt scatter list to the attachment, as we can't | ||
456 | * map the same scatter list to multiple attachments at the same time. | ||
457 | */ | ||
458 | ret = sg_alloc_table(sgt, buf->dma_sgt->orig_nents, GFP_KERNEL); | ||
459 | if (ret) { | ||
460 | kfree(attach); | ||
461 | return -ENOMEM; | ||
462 | } | ||
463 | |||
464 | rd = buf->dma_sgt->sgl; | ||
465 | wr = sgt->sgl; | ||
466 | for (i = 0; i < sgt->orig_nents; ++i) { | ||
467 | sg_set_page(wr, sg_page(rd), rd->length, rd->offset); | ||
468 | rd = sg_next(rd); | ||
469 | wr = sg_next(wr); | ||
470 | } | ||
471 | |||
472 | attach->dma_dir = DMA_NONE; | ||
473 | dbuf_attach->priv = attach; | ||
474 | |||
475 | return 0; | ||
476 | } | ||
477 | |||
478 | static void vb2_dma_sg_dmabuf_ops_detach(struct dma_buf *dbuf, | ||
479 | struct dma_buf_attachment *db_attach) | ||
480 | { | ||
481 | struct vb2_dma_sg_attachment *attach = db_attach->priv; | ||
482 | struct sg_table *sgt; | ||
483 | |||
484 | if (!attach) | ||
485 | return; | ||
486 | |||
487 | sgt = &attach->sgt; | ||
488 | |||
489 | /* release the scatterlist cache */ | ||
490 | if (attach->dma_dir != DMA_NONE) | ||
491 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | ||
492 | attach->dma_dir); | ||
493 | sg_free_table(sgt); | ||
494 | kfree(attach); | ||
495 | db_attach->priv = NULL; | ||
496 | } | ||
497 | |||
498 | static struct sg_table *vb2_dma_sg_dmabuf_ops_map( | ||
499 | struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir) | ||
500 | { | ||
501 | struct vb2_dma_sg_attachment *attach = db_attach->priv; | ||
502 | /* stealing dmabuf mutex to serialize map/unmap operations */ | ||
503 | struct mutex *lock = &db_attach->dmabuf->lock; | ||
504 | struct sg_table *sgt; | ||
505 | int ret; | ||
506 | |||
507 | mutex_lock(lock); | ||
508 | |||
509 | sgt = &attach->sgt; | ||
510 | /* return previously mapped sg table */ | ||
511 | if (attach->dma_dir == dma_dir) { | ||
512 | mutex_unlock(lock); | ||
513 | return sgt; | ||
514 | } | ||
515 | |||
516 | /* release any previous cache */ | ||
517 | if (attach->dma_dir != DMA_NONE) { | ||
518 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | ||
519 | attach->dma_dir); | ||
520 | attach->dma_dir = DMA_NONE; | ||
521 | } | ||
522 | |||
523 | /* mapping to the client with new direction */ | ||
524 | ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dma_dir); | ||
525 | if (ret <= 0) { | ||
526 | pr_err("failed to map scatterlist\n"); | ||
527 | mutex_unlock(lock); | ||
528 | return ERR_PTR(-EIO); | ||
529 | } | ||
530 | |||
531 | attach->dma_dir = dma_dir; | ||
532 | |||
533 | mutex_unlock(lock); | ||
534 | |||
535 | return sgt; | ||
536 | } | ||
537 | |||
538 | static void vb2_dma_sg_dmabuf_ops_unmap(struct dma_buf_attachment *db_attach, | ||
539 | struct sg_table *sgt, enum dma_data_direction dma_dir) | ||
540 | { | ||
541 | /* nothing to be done here */ | ||
542 | } | ||
543 | |||
544 | static void vb2_dma_sg_dmabuf_ops_release(struct dma_buf *dbuf) | ||
545 | { | ||
546 | /* drop reference obtained in vb2_dma_sg_get_dmabuf */ | ||
547 | vb2_dma_sg_put(dbuf->priv); | ||
548 | } | ||
549 | |||
550 | static void *vb2_dma_sg_dmabuf_ops_kmap(struct dma_buf *dbuf, unsigned long pgnum) | ||
551 | { | ||
552 | struct vb2_dma_sg_buf *buf = dbuf->priv; | ||
553 | |||
554 | return buf->vaddr ? buf->vaddr + pgnum * PAGE_SIZE : NULL; | ||
555 | } | ||
556 | |||
557 | static void *vb2_dma_sg_dmabuf_ops_vmap(struct dma_buf *dbuf) | ||
558 | { | ||
559 | struct vb2_dma_sg_buf *buf = dbuf->priv; | ||
560 | |||
561 | return vb2_dma_sg_vaddr(buf); | ||
562 | } | ||
563 | |||
564 | static int vb2_dma_sg_dmabuf_ops_mmap(struct dma_buf *dbuf, | ||
565 | struct vm_area_struct *vma) | ||
566 | { | ||
567 | return vb2_dma_sg_mmap(dbuf->priv, vma); | ||
568 | } | ||
569 | |||
570 | static struct dma_buf_ops vb2_dma_sg_dmabuf_ops = { | ||
571 | .attach = vb2_dma_sg_dmabuf_ops_attach, | ||
572 | .detach = vb2_dma_sg_dmabuf_ops_detach, | ||
573 | .map_dma_buf = vb2_dma_sg_dmabuf_ops_map, | ||
574 | .unmap_dma_buf = vb2_dma_sg_dmabuf_ops_unmap, | ||
575 | .kmap = vb2_dma_sg_dmabuf_ops_kmap, | ||
576 | .kmap_atomic = vb2_dma_sg_dmabuf_ops_kmap, | ||
577 | .vmap = vb2_dma_sg_dmabuf_ops_vmap, | ||
578 | .mmap = vb2_dma_sg_dmabuf_ops_mmap, | ||
579 | .release = vb2_dma_sg_dmabuf_ops_release, | ||
580 | }; | ||
581 | |||
582 | static struct dma_buf *vb2_dma_sg_get_dmabuf(void *buf_priv, unsigned long flags) | ||
583 | { | ||
584 | struct vb2_dma_sg_buf *buf = buf_priv; | ||
585 | struct dma_buf *dbuf; | ||
586 | |||
587 | if (WARN_ON(!buf->dma_sgt)) | ||
588 | return NULL; | ||
589 | |||
590 | dbuf = dma_buf_export(buf, &vb2_dma_sg_dmabuf_ops, buf->size, flags, NULL); | ||
591 | if (IS_ERR(dbuf)) | ||
592 | return NULL; | ||
593 | |||
594 | /* dmabuf keeps reference to vb2 buffer */ | ||
595 | atomic_inc(&buf->refcount); | ||
596 | |||
597 | return dbuf; | ||
598 | } | ||
599 | |||
600 | /*********************************************/ | ||
601 | /* callbacks for DMABUF buffers */ | ||
602 | /*********************************************/ | ||
603 | |||
604 | static int vb2_dma_sg_map_dmabuf(void *mem_priv) | ||
605 | { | ||
606 | struct vb2_dma_sg_buf *buf = mem_priv; | ||
607 | struct sg_table *sgt; | ||
608 | |||
609 | if (WARN_ON(!buf->db_attach)) { | ||
610 | pr_err("trying to pin a non attached buffer\n"); | ||
611 | return -EINVAL; | ||
612 | } | ||
613 | |||
614 | if (WARN_ON(buf->dma_sgt)) { | ||
615 | pr_err("dmabuf buffer is already pinned\n"); | ||
616 | return 0; | ||
617 | } | ||
618 | |||
619 | /* get the associated scatterlist for this buffer */ | ||
620 | sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir); | ||
621 | if (IS_ERR(sgt)) { | ||
622 | pr_err("Error getting dmabuf scatterlist\n"); | ||
623 | return -EINVAL; | ||
624 | } | ||
625 | |||
626 | buf->dma_sgt = sgt; | ||
627 | buf->vaddr = NULL; | ||
628 | |||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | static void vb2_dma_sg_unmap_dmabuf(void *mem_priv) | ||
633 | { | ||
634 | struct vb2_dma_sg_buf *buf = mem_priv; | ||
635 | struct sg_table *sgt = buf->dma_sgt; | ||
636 | |||
637 | if (WARN_ON(!buf->db_attach)) { | ||
638 | pr_err("trying to unpin a not attached buffer\n"); | ||
639 | return; | ||
640 | } | ||
641 | |||
642 | if (WARN_ON(!sgt)) { | ||
643 | pr_err("dmabuf buffer is already unpinned\n"); | ||
644 | return; | ||
645 | } | ||
646 | |||
647 | if (buf->vaddr) { | ||
648 | dma_buf_vunmap(buf->db_attach->dmabuf, buf->vaddr); | ||
649 | buf->vaddr = NULL; | ||
650 | } | ||
651 | dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir); | ||
652 | |||
653 | buf->dma_sgt = NULL; | ||
654 | } | ||
655 | |||
656 | static void vb2_dma_sg_detach_dmabuf(void *mem_priv) | ||
657 | { | ||
658 | struct vb2_dma_sg_buf *buf = mem_priv; | ||
659 | |||
660 | /* if vb2 works correctly you should never detach mapped buffer */ | ||
661 | if (WARN_ON(buf->dma_sgt)) | ||
662 | vb2_dma_sg_unmap_dmabuf(buf); | ||
663 | |||
664 | /* detach this attachment */ | ||
665 | dma_buf_detach(buf->db_attach->dmabuf, buf->db_attach); | ||
666 | kfree(buf); | ||
667 | } | ||
668 | |||
669 | static void *vb2_dma_sg_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, | ||
670 | unsigned long size, enum dma_data_direction dma_dir) | ||
671 | { | ||
672 | struct vb2_dma_sg_conf *conf = alloc_ctx; | ||
673 | struct vb2_dma_sg_buf *buf; | ||
674 | struct dma_buf_attachment *dba; | ||
675 | |||
676 | if (dbuf->size < size) | ||
677 | return ERR_PTR(-EFAULT); | ||
678 | |||
679 | buf = kzalloc(sizeof(*buf), GFP_KERNEL); | ||
680 | if (!buf) | ||
681 | return ERR_PTR(-ENOMEM); | ||
682 | |||
683 | buf->dev = conf->dev; | ||
684 | /* create attachment for the dmabuf with the user device */ | ||
685 | dba = dma_buf_attach(dbuf, buf->dev); | ||
686 | if (IS_ERR(dba)) { | ||
687 | pr_err("failed to attach dmabuf\n"); | ||
688 | kfree(buf); | ||
689 | return dba; | ||
690 | } | ||
691 | |||
692 | buf->dma_dir = dma_dir; | ||
693 | buf->size = size; | ||
694 | buf->db_attach = dba; | ||
695 | |||
696 | return buf; | ||
697 | } | ||
698 | |||
338 | static void *vb2_dma_sg_cookie(void *buf_priv) | 699 | static void *vb2_dma_sg_cookie(void *buf_priv) |
339 | { | 700 | { |
340 | struct vb2_dma_sg_buf *buf = buf_priv; | 701 | struct vb2_dma_sg_buf *buf = buf_priv; |
341 | 702 | ||
342 | return &buf->sg_table; | 703 | return buf->dma_sgt; |
343 | } | 704 | } |
344 | 705 | ||
345 | const struct vb2_mem_ops vb2_dma_sg_memops = { | 706 | const struct vb2_mem_ops vb2_dma_sg_memops = { |
@@ -347,13 +708,41 @@ const struct vb2_mem_ops vb2_dma_sg_memops = { | |||
347 | .put = vb2_dma_sg_put, | 708 | .put = vb2_dma_sg_put, |
348 | .get_userptr = vb2_dma_sg_get_userptr, | 709 | .get_userptr = vb2_dma_sg_get_userptr, |
349 | .put_userptr = vb2_dma_sg_put_userptr, | 710 | .put_userptr = vb2_dma_sg_put_userptr, |
711 | .prepare = vb2_dma_sg_prepare, | ||
712 | .finish = vb2_dma_sg_finish, | ||
350 | .vaddr = vb2_dma_sg_vaddr, | 713 | .vaddr = vb2_dma_sg_vaddr, |
351 | .mmap = vb2_dma_sg_mmap, | 714 | .mmap = vb2_dma_sg_mmap, |
352 | .num_users = vb2_dma_sg_num_users, | 715 | .num_users = vb2_dma_sg_num_users, |
716 | .get_dmabuf = vb2_dma_sg_get_dmabuf, | ||
717 | .map_dmabuf = vb2_dma_sg_map_dmabuf, | ||
718 | .unmap_dmabuf = vb2_dma_sg_unmap_dmabuf, | ||
719 | .attach_dmabuf = vb2_dma_sg_attach_dmabuf, | ||
720 | .detach_dmabuf = vb2_dma_sg_detach_dmabuf, | ||
353 | .cookie = vb2_dma_sg_cookie, | 721 | .cookie = vb2_dma_sg_cookie, |
354 | }; | 722 | }; |
355 | EXPORT_SYMBOL_GPL(vb2_dma_sg_memops); | 723 | EXPORT_SYMBOL_GPL(vb2_dma_sg_memops); |
356 | 724 | ||
725 | void *vb2_dma_sg_init_ctx(struct device *dev) | ||
726 | { | ||
727 | struct vb2_dma_sg_conf *conf; | ||
728 | |||
729 | conf = kzalloc(sizeof(*conf), GFP_KERNEL); | ||
730 | if (!conf) | ||
731 | return ERR_PTR(-ENOMEM); | ||
732 | |||
733 | conf->dev = dev; | ||
734 | |||
735 | return conf; | ||
736 | } | ||
737 | EXPORT_SYMBOL_GPL(vb2_dma_sg_init_ctx); | ||
738 | |||
739 | void vb2_dma_sg_cleanup_ctx(void *alloc_ctx) | ||
740 | { | ||
741 | if (!IS_ERR_OR_NULL(alloc_ctx)) | ||
742 | kfree(alloc_ctx); | ||
743 | } | ||
744 | EXPORT_SYMBOL_GPL(vb2_dma_sg_cleanup_ctx); | ||
745 | |||
357 | MODULE_DESCRIPTION("dma scatter/gather memory handling routines for videobuf2"); | 746 | MODULE_DESCRIPTION("dma scatter/gather memory handling routines for videobuf2"); |
358 | MODULE_AUTHOR("Andrzej Pietrasiewicz"); | 747 | MODULE_AUTHOR("Andrzej Pietrasiewicz"); |
359 | MODULE_LICENSE("GPL"); | 748 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c index 313d9771b2bc..fba944e50227 100644 --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c | |||
@@ -25,7 +25,7 @@ struct vb2_vmalloc_buf { | |||
25 | void *vaddr; | 25 | void *vaddr; |
26 | struct page **pages; | 26 | struct page **pages; |
27 | struct vm_area_struct *vma; | 27 | struct vm_area_struct *vma; |
28 | int write; | 28 | enum dma_data_direction dma_dir; |
29 | unsigned long size; | 29 | unsigned long size; |
30 | unsigned int n_pages; | 30 | unsigned int n_pages; |
31 | atomic_t refcount; | 31 | atomic_t refcount; |
@@ -35,7 +35,8 @@ struct vb2_vmalloc_buf { | |||
35 | 35 | ||
36 | static void vb2_vmalloc_put(void *buf_priv); | 36 | static void vb2_vmalloc_put(void *buf_priv); |
37 | 37 | ||
38 | static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) | 38 | static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, |
39 | enum dma_data_direction dma_dir, gfp_t gfp_flags) | ||
39 | { | 40 | { |
40 | struct vb2_vmalloc_buf *buf; | 41 | struct vb2_vmalloc_buf *buf; |
41 | 42 | ||
@@ -45,6 +46,7 @@ static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fl | |||
45 | 46 | ||
46 | buf->size = size; | 47 | buf->size = size; |
47 | buf->vaddr = vmalloc_user(buf->size); | 48 | buf->vaddr = vmalloc_user(buf->size); |
49 | buf->dma_dir = dma_dir; | ||
48 | buf->handler.refcount = &buf->refcount; | 50 | buf->handler.refcount = &buf->refcount; |
49 | buf->handler.put = vb2_vmalloc_put; | 51 | buf->handler.put = vb2_vmalloc_put; |
50 | buf->handler.arg = buf; | 52 | buf->handler.arg = buf; |
@@ -70,7 +72,8 @@ static void vb2_vmalloc_put(void *buf_priv) | |||
70 | } | 72 | } |
71 | 73 | ||
72 | static void *vb2_vmalloc_get_userptr(void *alloc_ctx, unsigned long vaddr, | 74 | static void *vb2_vmalloc_get_userptr(void *alloc_ctx, unsigned long vaddr, |
73 | unsigned long size, int write) | 75 | unsigned long size, |
76 | enum dma_data_direction dma_dir) | ||
74 | { | 77 | { |
75 | struct vb2_vmalloc_buf *buf; | 78 | struct vb2_vmalloc_buf *buf; |
76 | unsigned long first, last; | 79 | unsigned long first, last; |
@@ -82,7 +85,7 @@ static void *vb2_vmalloc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
82 | if (!buf) | 85 | if (!buf) |
83 | return NULL; | 86 | return NULL; |
84 | 87 | ||
85 | buf->write = write; | 88 | buf->dma_dir = dma_dir; |
86 | offset = vaddr & ~PAGE_MASK; | 89 | offset = vaddr & ~PAGE_MASK; |
87 | buf->size = size; | 90 | buf->size = size; |
88 | 91 | ||
@@ -107,7 +110,8 @@ static void *vb2_vmalloc_get_userptr(void *alloc_ctx, unsigned long vaddr, | |||
107 | /* current->mm->mmap_sem is taken by videobuf2 core */ | 110 | /* current->mm->mmap_sem is taken by videobuf2 core */ |
108 | n_pages = get_user_pages(current, current->mm, | 111 | n_pages = get_user_pages(current, current->mm, |
109 | vaddr & PAGE_MASK, buf->n_pages, | 112 | vaddr & PAGE_MASK, buf->n_pages, |
110 | write, 1, /* force */ | 113 | dma_dir == DMA_FROM_DEVICE, |
114 | 1, /* force */ | ||
111 | buf->pages, NULL); | 115 | buf->pages, NULL); |
112 | if (n_pages != buf->n_pages) | 116 | if (n_pages != buf->n_pages) |
113 | goto fail_get_user_pages; | 117 | goto fail_get_user_pages; |
@@ -144,14 +148,13 @@ static void vb2_vmalloc_put_userptr(void *buf_priv) | |||
144 | if (vaddr) | 148 | if (vaddr) |
145 | vm_unmap_ram((void *)vaddr, buf->n_pages); | 149 | vm_unmap_ram((void *)vaddr, buf->n_pages); |
146 | for (i = 0; i < buf->n_pages; ++i) { | 150 | for (i = 0; i < buf->n_pages; ++i) { |
147 | if (buf->write) | 151 | if (buf->dma_dir == DMA_FROM_DEVICE) |
148 | set_page_dirty_lock(buf->pages[i]); | 152 | set_page_dirty_lock(buf->pages[i]); |
149 | put_page(buf->pages[i]); | 153 | put_page(buf->pages[i]); |
150 | } | 154 | } |
151 | kfree(buf->pages); | 155 | kfree(buf->pages); |
152 | } else { | 156 | } else { |
153 | if (buf->vma) | 157 | vb2_put_vma(buf->vma); |
154 | vb2_put_vma(buf->vma); | ||
155 | iounmap(buf->vaddr); | 158 | iounmap(buf->vaddr); |
156 | } | 159 | } |
157 | kfree(buf); | 160 | kfree(buf); |
@@ -209,6 +212,176 @@ static int vb2_vmalloc_mmap(void *buf_priv, struct vm_area_struct *vma) | |||
209 | } | 212 | } |
210 | 213 | ||
211 | /*********************************************/ | 214 | /*********************************************/ |
215 | /* DMABUF ops for exporters */ | ||
216 | /*********************************************/ | ||
217 | |||
218 | struct vb2_vmalloc_attachment { | ||
219 | struct sg_table sgt; | ||
220 | enum dma_data_direction dma_dir; | ||
221 | }; | ||
222 | |||
223 | static int vb2_vmalloc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev, | ||
224 | struct dma_buf_attachment *dbuf_attach) | ||
225 | { | ||
226 | struct vb2_vmalloc_attachment *attach; | ||
227 | struct vb2_vmalloc_buf *buf = dbuf->priv; | ||
228 | int num_pages = PAGE_ALIGN(buf->size) / PAGE_SIZE; | ||
229 | struct sg_table *sgt; | ||
230 | struct scatterlist *sg; | ||
231 | void *vaddr = buf->vaddr; | ||
232 | int ret; | ||
233 | int i; | ||
234 | |||
235 | attach = kzalloc(sizeof(*attach), GFP_KERNEL); | ||
236 | if (!attach) | ||
237 | return -ENOMEM; | ||
238 | |||
239 | sgt = &attach->sgt; | ||
240 | ret = sg_alloc_table(sgt, num_pages, GFP_KERNEL); | ||
241 | if (ret) { | ||
242 | kfree(attach); | ||
243 | return ret; | ||
244 | } | ||
245 | for_each_sg(sgt->sgl, sg, sgt->nents, i) { | ||
246 | struct page *page = vmalloc_to_page(vaddr); | ||
247 | |||
248 | if (!page) { | ||
249 | sg_free_table(sgt); | ||
250 | kfree(attach); | ||
251 | return -ENOMEM; | ||
252 | } | ||
253 | sg_set_page(sg, page, PAGE_SIZE, 0); | ||
254 | vaddr += PAGE_SIZE; | ||
255 | } | ||
256 | |||
257 | attach->dma_dir = DMA_NONE; | ||
258 | dbuf_attach->priv = attach; | ||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static void vb2_vmalloc_dmabuf_ops_detach(struct dma_buf *dbuf, | ||
263 | struct dma_buf_attachment *db_attach) | ||
264 | { | ||
265 | struct vb2_vmalloc_attachment *attach = db_attach->priv; | ||
266 | struct sg_table *sgt; | ||
267 | |||
268 | if (!attach) | ||
269 | return; | ||
270 | |||
271 | sgt = &attach->sgt; | ||
272 | |||
273 | /* release the scatterlist cache */ | ||
274 | if (attach->dma_dir != DMA_NONE) | ||
275 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | ||
276 | attach->dma_dir); | ||
277 | sg_free_table(sgt); | ||
278 | kfree(attach); | ||
279 | db_attach->priv = NULL; | ||
280 | } | ||
281 | |||
282 | static struct sg_table *vb2_vmalloc_dmabuf_ops_map( | ||
283 | struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir) | ||
284 | { | ||
285 | struct vb2_vmalloc_attachment *attach = db_attach->priv; | ||
286 | /* stealing dmabuf mutex to serialize map/unmap operations */ | ||
287 | struct mutex *lock = &db_attach->dmabuf->lock; | ||
288 | struct sg_table *sgt; | ||
289 | int ret; | ||
290 | |||
291 | mutex_lock(lock); | ||
292 | |||
293 | sgt = &attach->sgt; | ||
294 | /* return previously mapped sg table */ | ||
295 | if (attach->dma_dir == dma_dir) { | ||
296 | mutex_unlock(lock); | ||
297 | return sgt; | ||
298 | } | ||
299 | |||
300 | /* release any previous cache */ | ||
301 | if (attach->dma_dir != DMA_NONE) { | ||
302 | dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, | ||
303 | attach->dma_dir); | ||
304 | attach->dma_dir = DMA_NONE; | ||
305 | } | ||
306 | |||
307 | /* mapping to the client with new direction */ | ||
308 | ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dma_dir); | ||
309 | if (ret <= 0) { | ||
310 | pr_err("failed to map scatterlist\n"); | ||
311 | mutex_unlock(lock); | ||
312 | return ERR_PTR(-EIO); | ||
313 | } | ||
314 | |||
315 | attach->dma_dir = dma_dir; | ||
316 | |||
317 | mutex_unlock(lock); | ||
318 | |||
319 | return sgt; | ||
320 | } | ||
321 | |||
322 | static void vb2_vmalloc_dmabuf_ops_unmap(struct dma_buf_attachment *db_attach, | ||
323 | struct sg_table *sgt, enum dma_data_direction dma_dir) | ||
324 | { | ||
325 | /* nothing to be done here */ | ||
326 | } | ||
327 | |||
328 | static void vb2_vmalloc_dmabuf_ops_release(struct dma_buf *dbuf) | ||
329 | { | ||
330 | /* drop reference obtained in vb2_vmalloc_get_dmabuf */ | ||
331 | vb2_vmalloc_put(dbuf->priv); | ||
332 | } | ||
333 | |||
334 | static void *vb2_vmalloc_dmabuf_ops_kmap(struct dma_buf *dbuf, unsigned long pgnum) | ||
335 | { | ||
336 | struct vb2_vmalloc_buf *buf = dbuf->priv; | ||
337 | |||
338 | return buf->vaddr + pgnum * PAGE_SIZE; | ||
339 | } | ||
340 | |||
341 | static void *vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf) | ||
342 | { | ||
343 | struct vb2_vmalloc_buf *buf = dbuf->priv; | ||
344 | |||
345 | return buf->vaddr; | ||
346 | } | ||
347 | |||
348 | static int vb2_vmalloc_dmabuf_ops_mmap(struct dma_buf *dbuf, | ||
349 | struct vm_area_struct *vma) | ||
350 | { | ||
351 | return vb2_vmalloc_mmap(dbuf->priv, vma); | ||
352 | } | ||
353 | |||
354 | static struct dma_buf_ops vb2_vmalloc_dmabuf_ops = { | ||
355 | .attach = vb2_vmalloc_dmabuf_ops_attach, | ||
356 | .detach = vb2_vmalloc_dmabuf_ops_detach, | ||
357 | .map_dma_buf = vb2_vmalloc_dmabuf_ops_map, | ||
358 | .unmap_dma_buf = vb2_vmalloc_dmabuf_ops_unmap, | ||
359 | .kmap = vb2_vmalloc_dmabuf_ops_kmap, | ||
360 | .kmap_atomic = vb2_vmalloc_dmabuf_ops_kmap, | ||
361 | .vmap = vb2_vmalloc_dmabuf_ops_vmap, | ||
362 | .mmap = vb2_vmalloc_dmabuf_ops_mmap, | ||
363 | .release = vb2_vmalloc_dmabuf_ops_release, | ||
364 | }; | ||
365 | |||
366 | static struct dma_buf *vb2_vmalloc_get_dmabuf(void *buf_priv, unsigned long flags) | ||
367 | { | ||
368 | struct vb2_vmalloc_buf *buf = buf_priv; | ||
369 | struct dma_buf *dbuf; | ||
370 | |||
371 | if (WARN_ON(!buf->vaddr)) | ||
372 | return NULL; | ||
373 | |||
374 | dbuf = dma_buf_export(buf, &vb2_vmalloc_dmabuf_ops, buf->size, flags, NULL); | ||
375 | if (IS_ERR(dbuf)) | ||
376 | return NULL; | ||
377 | |||
378 | /* dmabuf keeps reference to vb2 buffer */ | ||
379 | atomic_inc(&buf->refcount); | ||
380 | |||
381 | return dbuf; | ||
382 | } | ||
383 | |||
384 | /*********************************************/ | ||
212 | /* callbacks for DMABUF buffers */ | 385 | /* callbacks for DMABUF buffers */ |
213 | /*********************************************/ | 386 | /*********************************************/ |
214 | 387 | ||
@@ -240,7 +413,7 @@ static void vb2_vmalloc_detach_dmabuf(void *mem_priv) | |||
240 | } | 413 | } |
241 | 414 | ||
242 | static void *vb2_vmalloc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, | 415 | static void *vb2_vmalloc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, |
243 | unsigned long size, int write) | 416 | unsigned long size, enum dma_data_direction dma_dir) |
244 | { | 417 | { |
245 | struct vb2_vmalloc_buf *buf; | 418 | struct vb2_vmalloc_buf *buf; |
246 | 419 | ||
@@ -252,7 +425,7 @@ static void *vb2_vmalloc_attach_dmabuf(void *alloc_ctx, struct dma_buf *dbuf, | |||
252 | return ERR_PTR(-ENOMEM); | 425 | return ERR_PTR(-ENOMEM); |
253 | 426 | ||
254 | buf->dbuf = dbuf; | 427 | buf->dbuf = dbuf; |
255 | buf->write = write; | 428 | buf->dma_dir = dma_dir; |
256 | buf->size = size; | 429 | buf->size = size; |
257 | 430 | ||
258 | return buf; | 431 | return buf; |
@@ -264,6 +437,7 @@ const struct vb2_mem_ops vb2_vmalloc_memops = { | |||
264 | .put = vb2_vmalloc_put, | 437 | .put = vb2_vmalloc_put, |
265 | .get_userptr = vb2_vmalloc_get_userptr, | 438 | .get_userptr = vb2_vmalloc_get_userptr, |
266 | .put_userptr = vb2_vmalloc_put_userptr, | 439 | .put_userptr = vb2_vmalloc_put_userptr, |
440 | .get_dmabuf = vb2_vmalloc_get_dmabuf, | ||
267 | .map_dmabuf = vb2_vmalloc_map_dmabuf, | 441 | .map_dmabuf = vb2_vmalloc_map_dmabuf, |
268 | .unmap_dmabuf = vb2_vmalloc_unmap_dmabuf, | 442 | .unmap_dmabuf = vb2_vmalloc_unmap_dmabuf, |
269 | .attach_dmabuf = vb2_vmalloc_attach_dmabuf, | 443 | .attach_dmabuf = vb2_vmalloc_attach_dmabuf, |