aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-aztech.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-aztech.c')
-rw-r--r--drivers/media/radio/radio-aztech.c81
1 files changed, 28 insertions, 53 deletions
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 177bcbd7a7c1..705dd6f9162c 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -26,6 +26,7 @@
26#include <media/v4l2-ioctl.h> 26#include <media/v4l2-ioctl.h>
27#include <media/v4l2-ctrls.h> 27#include <media/v4l2-ctrls.h>
28#include "radio-isa.h" 28#include "radio-isa.h"
29#include "lm7000.h"
29 30
30MODULE_AUTHOR("Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath"); 31MODULE_AUTHOR("Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath");
31MODULE_DESCRIPTION("A driver for the Aztech radio card."); 32MODULE_DESCRIPTION("A driver for the Aztech radio card.");
@@ -54,18 +55,29 @@ struct aztech {
54 int curvol; 55 int curvol;
55}; 56};
56 57
57static void send_0_byte(struct aztech *az) 58/* bit definitions for register read */
58{ 59#define AZTECH_BIT_NOT_TUNED (1 << 0)
59 udelay(radio_wait_time); 60#define AZTECH_BIT_MONO (1 << 1)
60 outb_p(2 + az->curvol, az->isa.io); 61/* bit definitions for register write */
61 outb_p(64 + 2 + az->curvol, az->isa.io); 62#define AZTECH_BIT_TUN_CE (1 << 1)
62} 63#define AZTECH_BIT_TUN_CLK (1 << 6)
64#define AZTECH_BIT_TUN_DATA (1 << 7)
65/* bits 0 and 2 are volume control, bits 3..5 are not connected */
63 66
64static void send_1_byte(struct aztech *az) 67static void aztech_set_pins(void *handle, u8 pins)
65{ 68{
66 udelay(radio_wait_time); 69 struct radio_isa_card *isa = handle;
67 outb_p(128 + 2 + az->curvol, az->isa.io); 70 struct aztech *az = container_of(isa, struct aztech, isa);
68 outb_p(128 + 64 + 2 + az->curvol, az->isa.io); 71 u8 bits = az->curvol;
72
73 if (pins & LM7000_DATA)
74 bits |= AZTECH_BIT_TUN_DATA;
75 if (pins & LM7000_CLK)
76 bits |= AZTECH_BIT_TUN_CLK;
77 if (pins & LM7000_CE)
78 bits |= AZTECH_BIT_TUN_CE;
79
80 outb_p(bits, az->isa.io);
69} 81}
70 82
71static struct radio_isa_card *aztech_alloc(void) 83static struct radio_isa_card *aztech_alloc(void)
@@ -77,58 +89,21 @@ static struct radio_isa_card *aztech_alloc(void)
77 89
78static int aztech_s_frequency(struct radio_isa_card *isa, u32 freq) 90static int aztech_s_frequency(struct radio_isa_card *isa, u32 freq)
79{ 91{
80 struct aztech *az = container_of(isa, struct aztech, isa); 92 lm7000_set_freq(freq, isa, aztech_set_pins);
81 int i;
82
83 freq += 171200; /* Add 10.7 MHz IF */
84 freq /= 800; /* Convert to 50 kHz units */
85
86 send_0_byte(az); /* 0: LSB of frequency */
87
88 for (i = 0; i < 13; i++) /* : frequency bits (1-13) */
89 if (freq & (1 << i))
90 send_1_byte(az);
91 else
92 send_0_byte(az);
93
94 send_0_byte(az); /* 14: test bit - always 0 */
95 send_0_byte(az); /* 15: test bit - always 0 */
96 send_0_byte(az); /* 16: band data 0 - always 0 */
97 if (isa->stereo) /* 17: stereo (1 to enable) */
98 send_1_byte(az);
99 else
100 send_0_byte(az);
101
102 send_1_byte(az); /* 18: band data 1 - unknown */
103 send_0_byte(az); /* 19: time base - always 0 */
104 send_0_byte(az); /* 20: spacing (0 = 25 kHz) */
105 send_1_byte(az); /* 21: spacing (1 = 25 kHz) */
106 send_0_byte(az); /* 22: spacing (0 = 25 kHz) */
107 send_1_byte(az); /* 23: AM/FM (FM = 1, always) */
108
109 /* latch frequency */
110
111 udelay(radio_wait_time);
112 outb_p(128 + 64 + az->curvol, az->isa.io);
113 93
114 return 0; 94 return 0;
115} 95}
116 96
117/* thanks to Michael Dwyer for giving me a dose of clues in
118 * the signal strength department..
119 *
120 * This card has a stereo bit - bit 0 set = mono, not set = stereo
121 */
122static u32 aztech_g_rxsubchans(struct radio_isa_card *isa) 97static u32 aztech_g_rxsubchans(struct radio_isa_card *isa)
123{ 98{
124 if (inb(isa->io) & 1) 99 if (inb(isa->io) & AZTECH_BIT_MONO)
125 return V4L2_TUNER_SUB_MONO; 100 return V4L2_TUNER_SUB_MONO;
126 return V4L2_TUNER_SUB_STEREO; 101 return V4L2_TUNER_SUB_STEREO;
127} 102}
128 103
129static int aztech_s_stereo(struct radio_isa_card *isa, bool stereo) 104static u32 aztech_g_signal(struct radio_isa_card *isa)
130{ 105{
131 return aztech_s_frequency(isa, isa->freq); 106 return (inb(isa->io) & AZTECH_BIT_NOT_TUNED) ? 0 : 0xffff;
132} 107}
133 108
134static int aztech_s_mute_volume(struct radio_isa_card *isa, bool mute, int vol) 109static int aztech_s_mute_volume(struct radio_isa_card *isa, bool mute, int vol)
@@ -146,8 +121,8 @@ static const struct radio_isa_ops aztech_ops = {
146 .alloc = aztech_alloc, 121 .alloc = aztech_alloc,
147 .s_mute_volume = aztech_s_mute_volume, 122 .s_mute_volume = aztech_s_mute_volume,
148 .s_frequency = aztech_s_frequency, 123 .s_frequency = aztech_s_frequency,
149 .s_stereo = aztech_s_stereo,
150 .g_rxsubchans = aztech_g_rxsubchans, 124 .g_rxsubchans = aztech_g_rxsubchans,
125 .g_signal = aztech_g_signal,
151}; 126};
152 127
153static const int aztech_ioports[] = { 0x350, 0x358 }; 128static const int aztech_ioports[] = { 0x350, 0x358 };
@@ -165,7 +140,7 @@ static struct radio_isa_driver aztech_driver = {
165 .radio_nr_params = radio_nr, 140 .radio_nr_params = radio_nr,
166 .io_ports = aztech_ioports, 141 .io_ports = aztech_ioports,
167 .num_of_io_ports = ARRAY_SIZE(aztech_ioports), 142 .num_of_io_ports = ARRAY_SIZE(aztech_ioports),
168 .region_size = 2, 143 .region_size = 8,
169 .card = "Aztech Radio", 144 .card = "Aztech Radio",
170 .ops = &aztech_ops, 145 .ops = &aztech_ops,
171 .has_stereo = true, 146 .has_stereo = true,