Commit 07e4de30 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[media] em28xx: add support for GPO controlled analog capturing LEDs

Some devices are equipped with a capturing status LED that needs to be
switched on/off explicitly via a GPO port.
Signed-off-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 7b2f25c0
...@@ -608,21 +608,11 @@ int em28xx_capture_start(struct em28xx *dev, int start) ...@@ -608,21 +608,11 @@ int em28xx_capture_start(struct em28xx *dev, int start)
dev->chip_id == CHIP_ID_EM2884 || dev->chip_id == CHIP_ID_EM2884 ||
dev->chip_id == CHIP_ID_EM28174) { dev->chip_id == CHIP_ID_EM28174) {
/* The Transport Stream Enable Register moved in em2874 */ /* The Transport Stream Enable Register moved in em2874 */
if (!start) {
rc = em28xx_write_reg_bits(dev, EM2874_R5F_TS_ENABLE, rc = em28xx_write_reg_bits(dev, EM2874_R5F_TS_ENABLE,
0x00, start ?
EM2874_TS1_CAPTURE_ENABLE : 0x00,
EM2874_TS1_CAPTURE_ENABLE); EM2874_TS1_CAPTURE_ENABLE);
return rc; } else {
}
/* Enable Transport Stream */
rc = em28xx_write_reg_bits(dev, EM2874_R5F_TS_ENABLE,
EM2874_TS1_CAPTURE_ENABLE,
EM2874_TS1_CAPTURE_ENABLE);
return rc;
}
/* FIXME: which is the best order? */ /* FIXME: which is the best order? */
/* video registers are sampled by VREF */ /* video registers are sampled by VREF */
rc = em28xx_write_reg_bits(dev, EM28XX_R0C_USBSUSP, rc = em28xx_write_reg_bits(dev, EM28XX_R0C_USBSUSP,
...@@ -630,24 +620,39 @@ int em28xx_capture_start(struct em28xx *dev, int start) ...@@ -630,24 +620,39 @@ int em28xx_capture_start(struct em28xx *dev, int start)
if (rc < 0) if (rc < 0)
return rc; return rc;
if (!start) { if (start) {
/* disable video capture */
rc = em28xx_write_reg(dev, EM28XX_R12_VINENABLE, 0x27);
return rc;
}
if (dev->board.is_webcam) if (dev->board.is_webcam)
rc = em28xx_write_reg(dev, 0x13, 0x0c); rc = em28xx_write_reg(dev, 0x13, 0x0c);
/* enable video capture */ /* Enable video capture */
rc = em28xx_write_reg(dev, 0x48, 0x00); rc = em28xx_write_reg(dev, 0x48, 0x00);
if (dev->mode == EM28XX_ANALOG_MODE) if (dev->mode == EM28XX_ANALOG_MODE)
rc = em28xx_write_reg(dev, EM28XX_R12_VINENABLE, 0x67); rc = em28xx_write_reg(dev,
EM28XX_R12_VINENABLE, 0x67);
else else
rc = em28xx_write_reg(dev, EM28XX_R12_VINENABLE, 0x37); rc = em28xx_write_reg(dev,
EM28XX_R12_VINENABLE, 0x37);
msleep(6); msleep(6);
} else {
/* disable video capture */
rc = em28xx_write_reg(dev, EM28XX_R12_VINENABLE, 0x27);
}
}
if (rc < 0)
return rc;
/* Switch (explicitly controlled) analog capturing LED on/off */
if ((dev->mode == EM28XX_ANALOG_MODE)
&& dev->board.analog_capturing_led) {
struct em28xx_led *led = dev->board.analog_capturing_led;
em28xx_write_reg_bits(dev, led->gpio_reg,
(!start ^ led->inverted) ?
~led->gpio_mask : led->gpio_mask,
led->gpio_mask);
}
return rc; return rc;
} }
......
...@@ -374,6 +374,12 @@ enum em28xx_adecoder { ...@@ -374,6 +374,12 @@ enum em28xx_adecoder {
EM28XX_TVAUDIO, EM28XX_TVAUDIO,
}; };
struct em28xx_led {
u8 gpio_reg;
u8 gpio_mask;
bool inverted;
};
struct em28xx_board { struct em28xx_board {
char *name; char *name;
int vchannels; int vchannels;
...@@ -410,6 +416,9 @@ struct em28xx_board { ...@@ -410,6 +416,9 @@ struct em28xx_board {
struct em28xx_input input[MAX_EM28XX_INPUT]; struct em28xx_input input[MAX_EM28XX_INPUT];
struct em28xx_input radio; struct em28xx_input radio;
char *ir_codes; char *ir_codes;
/* LEDs that need to be controlled explicitly */
struct em28xx_led *analog_capturing_led;
}; };
struct em28xx_eeprom { struct em28xx_eeprom {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment