diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/tvaudio.c | 107 |
1 files changed, 86 insertions, 21 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 19625e6410d1..2bdbb39bff0f 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -46,16 +46,18 @@ MODULE_LICENSE("GPL"); | |||
46 | 46 | ||
47 | #define UNSET (-1U) | 47 | #define UNSET (-1U) |
48 | 48 | ||
49 | #define tvaudio_info(fmt, arg...) do {\ | 49 | #define tvaudio_info(fmt, arg...) do { \ |
50 | printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ | 50 | printk(KERN_INFO "%s %d-%04x: " fmt, chip->c.driver->name, \ |
51 | chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) | 51 | i2c_adapter_id(chip->c.adapter), chip->c.addr , ## arg); } while (0) |
52 | #define tvaudio_warn(fmt, arg...) do {\ | 52 | #define tvaudio_warn(fmt, arg...) do { \ |
53 | printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \ | 53 | printk(KERN_WARNING "%s %d-%04x: " fmt, chip->c.driver->name, \ |
54 | chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) | 54 | i2c_adapter_id(chip->c.adapter), chip->c.addr , ## arg); } while (0) |
55 | #define tvaudio_dbg(fmt, arg...) do {\ | 55 | #define tvaudio_dbg(fmt, arg...) \ |
56 | if (debug) \ | 56 | do { \ |
57 | printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ | 57 | if (debug) \ |
58 | chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) | 58 | printk(KERN_INFO "%s debug %d-%04x: " fmt, chip->c.driver->name, \ |
59 | i2c_adapter_id(chip->c.adapter), chip->c.addr , ## arg); \ | ||
60 | } while (0) | ||
59 | 61 | ||
60 | /* ---------------------------------------------------------------------- */ | 62 | /* ---------------------------------------------------------------------- */ |
61 | /* our structs */ | 63 | /* our structs */ |
@@ -131,7 +133,7 @@ struct CHIPSTATE { | |||
131 | /* current settings */ | 133 | /* current settings */ |
132 | __u16 left,right,treble,bass,mode; | 134 | __u16 left,right,treble,bass,mode; |
133 | int prevmode; | 135 | int prevmode; |
134 | int norm; | 136 | int radio; |
135 | 137 | ||
136 | /* thread */ | 138 | /* thread */ |
137 | pid_t tpid; | 139 | pid_t tpid; |
@@ -142,8 +144,6 @@ struct CHIPSTATE { | |||
142 | int watch_stereo; | 144 | int watch_stereo; |
143 | }; | 145 | }; |
144 | 146 | ||
145 | #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ | ||
146 | |||
147 | /* ---------------------------------------------------------------------- */ | 147 | /* ---------------------------------------------------------------------- */ |
148 | /* i2c addresses */ | 148 | /* i2c addresses */ |
149 | 149 | ||
@@ -301,7 +301,7 @@ static int chip_thread(void *data) | |||
301 | tvaudio_dbg("%s: thread wakeup\n", chip->c.name); | 301 | tvaudio_dbg("%s: thread wakeup\n", chip->c.name); |
302 | 302 | ||
303 | /* don't do anything for radio or if mode != auto */ | 303 | /* don't do anything for radio or if mode != auto */ |
304 | if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) | 304 | if (chip->radio || chip->mode != 0) |
305 | continue; | 305 | continue; |
306 | 306 | ||
307 | /* have a look what's going on */ | 307 | /* have a look what's going on */ |
@@ -1608,7 +1608,7 @@ static int chip_command(struct i2c_client *client, | |||
1608 | break; | 1608 | break; |
1609 | 1609 | ||
1610 | case AUDC_SET_RADIO: | 1610 | case AUDC_SET_RADIO: |
1611 | chip->norm = VIDEO_MODE_RADIO; | 1611 | chip->radio = 1; |
1612 | chip->watch_stereo = 0; | 1612 | chip->watch_stereo = 0; |
1613 | /* del_timer(&chip->wt); */ | 1613 | /* del_timer(&chip->wt); */ |
1614 | break; | 1614 | break; |
@@ -1634,7 +1634,7 @@ static int chip_command(struct i2c_client *client, | |||
1634 | va->bass = chip->bass; | 1634 | va->bass = chip->bass; |
1635 | va->treble = chip->treble; | 1635 | va->treble = chip->treble; |
1636 | } | 1636 | } |
1637 | if (chip->norm != VIDEO_MODE_RADIO) { | 1637 | if (!chip->radio) { |
1638 | if (desc->getmode) | 1638 | if (desc->getmode) |
1639 | va->mode = desc->getmode(chip); | 1639 | va->mode = desc->getmode(chip); |
1640 | else | 1640 | else |
@@ -1669,15 +1669,80 @@ static int chip_command(struct i2c_client *client, | |||
1669 | } | 1669 | } |
1670 | break; | 1670 | break; |
1671 | } | 1671 | } |
1672 | case VIDIOCSCHAN: | 1672 | |
1673 | case VIDIOC_S_TUNER: | ||
1673 | { | 1674 | { |
1674 | struct video_channel *vc = arg; | 1675 | struct v4l2_tuner *vt = arg; |
1676 | int mode = 0; | ||
1675 | 1677 | ||
1676 | chip->norm = vc->norm; | 1678 | switch (vt->audmode) { |
1679 | case V4L2_TUNER_MODE_MONO: | ||
1680 | mode = VIDEO_SOUND_MONO; | ||
1681 | break; | ||
1682 | case V4L2_TUNER_MODE_STEREO: | ||
1683 | mode = VIDEO_SOUND_STEREO; | ||
1684 | break; | ||
1685 | case V4L2_TUNER_MODE_LANG1: | ||
1686 | mode = VIDEO_SOUND_LANG1; | ||
1687 | break; | ||
1688 | case V4L2_TUNER_MODE_LANG2: | ||
1689 | mode = VIDEO_SOUND_LANG2; | ||
1690 | break; | ||
1691 | default: | ||
1692 | break; | ||
1693 | } | ||
1694 | |||
1695 | if (desc->setmode && mode) { | ||
1696 | chip->watch_stereo = 0; | ||
1697 | /* del_timer(&chip->wt); */ | ||
1698 | chip->mode = mode; | ||
1699 | desc->setmode(chip, mode); | ||
1700 | } | ||
1677 | break; | 1701 | break; |
1678 | } | 1702 | } |
1679 | case VIDIOCSFREQ: | 1703 | |
1704 | case VIDIOC_G_TUNER: | ||
1680 | { | 1705 | { |
1706 | struct v4l2_tuner *vt = arg; | ||
1707 | int mode = VIDEO_SOUND_MONO; | ||
1708 | |||
1709 | vt->audmode = 0; | ||
1710 | vt->rxsubchans = 0; | ||
1711 | vt->capability = V4L2_TUNER_CAP_STEREO | | ||
1712 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; | ||
1713 | if (chip->radio) | ||
1714 | break; | ||
1715 | |||
1716 | if (desc->getmode) | ||
1717 | mode = desc->getmode(chip); | ||
1718 | |||
1719 | if (mode & VIDEO_SOUND_MONO) | ||
1720 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; | ||
1721 | if (mode & VIDEO_SOUND_STEREO) | ||
1722 | vt->rxsubchans |= V4L2_TUNER_SUB_STEREO; | ||
1723 | if (mode & VIDEO_SOUND_LANG1) | ||
1724 | vt->rxsubchans |= V4L2_TUNER_SUB_LANG1 | | ||
1725 | V4L2_TUNER_SUB_LANG2; | ||
1726 | |||
1727 | mode = chip->mode; | ||
1728 | if (mode & VIDEO_SOUND_MONO) | ||
1729 | vt->audmode = V4L2_TUNER_MODE_MONO; | ||
1730 | if (mode & VIDEO_SOUND_STEREO) | ||
1731 | vt->audmode = V4L2_TUNER_MODE_STEREO; | ||
1732 | if (mode & VIDEO_SOUND_LANG1) | ||
1733 | vt->audmode = V4L2_TUNER_MODE_LANG1; | ||
1734 | if (mode & VIDEO_SOUND_LANG2) | ||
1735 | vt->audmode = V4L2_TUNER_MODE_LANG2; | ||
1736 | break; | ||
1737 | } | ||
1738 | |||
1739 | case VIDIOCSCHAN: | ||
1740 | case VIDIOC_S_STD: | ||
1741 | chip->radio = 0; | ||
1742 | break; | ||
1743 | |||
1744 | case VIDIOCSFREQ: | ||
1745 | case VIDIOC_S_FREQUENCY: | ||
1681 | chip->mode = 0; /* automatic */ | 1746 | chip->mode = 0; /* automatic */ |
1682 | if (desc->checkmode) { | 1747 | if (desc->checkmode) { |
1683 | desc->setmode(chip,VIDEO_SOUND_MONO); | 1748 | desc->setmode(chip,VIDEO_SOUND_MONO); |
@@ -1686,7 +1751,7 @@ static int chip_command(struct i2c_client *client, | |||
1686 | mod_timer(&chip->wt, jiffies+2*HZ); | 1751 | mod_timer(&chip->wt, jiffies+2*HZ); |
1687 | /* the thread will call checkmode() later */ | 1752 | /* the thread will call checkmode() later */ |
1688 | } | 1753 | } |
1689 | } | 1754 | break; |
1690 | } | 1755 | } |
1691 | return 0; | 1756 | return 0; |
1692 | } | 1757 | } |