summaryrefslogtreecommitdiff
path: root/firmware/drivers/tuner/tea5760uk.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/tuner/tea5760uk.c')
-rw-r--r--firmware/drivers/tuner/tea5760uk.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/firmware/drivers/tuner/tea5760uk.c b/firmware/drivers/tuner/tea5760uk.c
deleted file mode 100644
index 8ac6cb2dbc..0000000000
--- a/firmware/drivers/tuner/tea5760uk.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 * Tuner "middleware" for Philips TEA5760 chip
10 *
11 * Copyright (C) 2004 Jörg Hohensohn
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include "config.h"
21#include <stdbool.h>
22#include <string.h>
23#include <stdlib.h>
24#include "kernel.h"
25#include "tuner.h" /* tuner abstraction interface */
26#include "fmradio.h"
27#include "fmradio_i2c.h" /* physical interface driver */
28
29#define I2C_ADR 0xC0
30static unsigned char write_bytes[7] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
31
32static void tea5760uk_set_clear(int byte, unsigned char bits, int set)
33{
34 write_bytes[byte] &= ~bits;
35 if (set)
36 write_bytes[byte] |= bits;
37}
38
39/* tuner abstraction layer: set something to the tuner */
40int tea5760uk_set(int setting, int value)
41{
42 switch(setting)
43 {
44 case RADIO_SLEEP:
45 /* init values */
46 write_bytes[0] |= (1<<7); /* mute */
47#if CONFIG_TUNER_XTAL == 32768
48 /* 32.768kHz, soft mute, stereo noise cancelling */
49 write_bytes[3] |= (1<<4) | (1<<3) | (1<<1);
50#else
51 /* soft mute, stereo noise cancelling */
52 write_bytes[3] |= (1<<3) | (1<<1);
53#endif
54 /* sleep / standby mode */
55 tea5760uk_set_clear(3, (1<<6), value);
56 break;
57
58 case RADIO_FREQUENCY:
59 {
60 int n;
61#if CONFIG_TUNER_XTAL == 32768
62 n = (4 * (value - 225000) + 16384) / 32768;
63#else
64 n = (4 * (value - 225000)) / 50000;
65#endif
66 write_bytes[6] = (write_bytes[6] & 0xC0) | (n >> 8);
67 write_bytes[7] = n;
68 }
69 break;
70
71 case RADIO_SCAN_FREQUENCY:
72 tea5760uk_set(RADIO_FREQUENCY, value);
73 sleep(HZ/30);
74 return tea5760uk_get(RADIO_TUNED);
75
76 case RADIO_MUTE:
77 tea5760uk_set_clear(3, (1<<2), value);
78 break;
79
80 case RADIO_REGION:
81 {
82 const struct tea5760uk_region_data *rd =
83 &tea5760uk_region_data[value];
84
85 tea5760uk_set_clear(4, (1<<1), rd->deemphasis);
86 tea5760uk_set_clear(3, (1<<5), rd->band);
87 break;
88 }
89 case RADIO_FORCE_MONO:
90 tea5760uk_set_clear(4, (1<<3), value);
91 break;
92 default:
93 return -1;
94 }
95
96 fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
97 return 1;
98}
99
100/* tuner abstraction layer: read something from the tuner */
101int tea5760uk_get(int setting)
102{
103 unsigned char read_bytes[16];
104 int val = -1; /* default for unsupported query */
105
106 fmradio_i2c_read(I2C_ADR, read_bytes, sizeof(read_bytes));
107
108 switch(setting)
109 {
110 case RADIO_PRESENT:
111 val = 1; /* true */
112 break;
113
114 case RADIO_TUNED:
115 val = 0;
116 if (read_bytes[0] & (1<<4)) /* IF count correct */
117 {
118 val = read_bytes[8] >> 1; /* IF counter */
119 val = (abs(val - 0x36) < 2); /* close match */
120 }
121 break;
122
123 case RADIO_STEREO:
124 val = read_bytes[9] >> 2;
125 break;
126 }
127
128 return val;
129}
130
131void tea5760uk_dbg_info(struct tea5760uk_dbg_info *info)
132{
133 fmradio_i2c_read(I2C_ADR, info->read_regs, 5);
134 memcpy(info->write_regs, write_bytes, 5);
135}