aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx25840
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2006-01-09 12:25:41 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 12:25:41 -0500
commit3578d3dd0b1e468a44a76a83efe90476a854625d (patch)
tree2cd544f2aae9844821afdf90308048a800e961a1 /drivers/media/video/cx25840
parent21fa715e67fe57e404d7f5f39b7f18016db9e4b6 (diff)
V4L/DVB (3214): Calculate the saa7115 AMCLK regs instead of using fixed values
- Calculate the audio master clock registers from the actual frequencies. This simplifies the code and it also prepares for adding CGC2 support. - VIDIOC_INT_AUDIO_CLOCK_FREQ now receives an u32 instead of an enum. It is more generic and actually easier to implement. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/video/cx25840')
-rw-r--r--drivers/media/video/cx25840/cx25840-audio.c20
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c10
-rw-r--r--drivers/media/video/cx25840/cx25840.h2
3 files changed, 14 insertions, 18 deletions
diff --git a/drivers/media/video/cx25840/cx25840-audio.c b/drivers/media/video/cx25840/cx25840-audio.c
index 740908f8027d..6c44bd9c1704 100644
--- a/drivers/media/video/cx25840/cx25840-audio.c
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -23,11 +23,13 @@
23 23
24#include "cx25840.h" 24#include "cx25840.h"
25 25
26inline static int set_audclk_freq(struct i2c_client *client, 26static int set_audclk_freq(struct i2c_client *client, u32 freq)
27 enum v4l2_audio_clock_freq freq)
28{ 27{
29 struct cx25840_state *state = i2c_get_clientdata(client); 28 struct cx25840_state *state = i2c_get_clientdata(client);
30 29
30 if (freq != 32000 && freq != 44100 && freq != 48000)
31 return -EINVAL;
32
31 /* assert soft reset */ 33 /* assert soft reset */
32 cx25840_and_or(client, 0x810, ~0x1, 0x01); 34 cx25840_and_or(client, 0x810, ~0x1, 0x01);
33 35
@@ -38,7 +40,7 @@ inline static int set_audclk_freq(struct i2c_client *client,
38 switch (state->audio_input) { 40 switch (state->audio_input) {
39 case AUDIO_TUNER: 41 case AUDIO_TUNER:
40 switch (freq) { 42 switch (freq) {
41 case V4L2_AUDCLK_32_KHZ: 43 case 32000:
42 /* VID_PLL and AUX_PLL */ 44 /* VID_PLL and AUX_PLL */
43 cx25840_write4(client, 0x108, 0x0f040610); 45 cx25840_write4(client, 0x108, 0x0f040610);
44 46
@@ -51,7 +53,7 @@ inline static int set_audclk_freq(struct i2c_client *client,
51 cx25840_write4(client, 0x90c, 0x7ff70108); 53 cx25840_write4(client, 0x90c, 0x7ff70108);
52 break; 54 break;
53 55
54 case V4L2_AUDCLK_441_KHZ: 56 case 44100:
55 /* VID_PLL and AUX_PLL */ 57 /* VID_PLL and AUX_PLL */
56 cx25840_write4(client, 0x108, 0x0f040910); 58 cx25840_write4(client, 0x108, 0x0f040910);
57 59
@@ -64,7 +66,7 @@ inline static int set_audclk_freq(struct i2c_client *client,
64 cx25840_write4(client, 0x90c, 0x596d0108); 66 cx25840_write4(client, 0x90c, 0x596d0108);
65 break; 67 break;
66 68
67 case V4L2_AUDCLK_48_KHZ: 69 case 48000:
68 /* VID_PLL and AUX_PLL */ 70 /* VID_PLL and AUX_PLL */
69 cx25840_write4(client, 0x108, 0x0f040a10); 71 cx25840_write4(client, 0x108, 0x0f040a10);
70 72
@@ -84,7 +86,7 @@ inline static int set_audclk_freq(struct i2c_client *client,
84 case AUDIO_INTERN: 86 case AUDIO_INTERN:
85 case AUDIO_RADIO: 87 case AUDIO_RADIO:
86 switch (freq) { 88 switch (freq) {
87 case V4L2_AUDCLK_32_KHZ: 89 case 32000:
88 /* VID_PLL and AUX_PLL */ 90 /* VID_PLL and AUX_PLL */
89 cx25840_write4(client, 0x108, 0x0f04081e); 91 cx25840_write4(client, 0x108, 0x0f04081e);
90 92
@@ -103,7 +105,7 @@ inline static int set_audclk_freq(struct i2c_client *client,
103 cx25840_write(client, 0x127, 0x54); 105 cx25840_write(client, 0x127, 0x54);
104 break; 106 break;
105 107
106 case V4L2_AUDCLK_441_KHZ: 108 case 44100:
107 /* VID_PLL and AUX_PLL */ 109 /* VID_PLL and AUX_PLL */
108 cx25840_write4(client, 0x108, 0x0f040918); 110 cx25840_write4(client, 0x108, 0x0f040918);
109 111
@@ -119,7 +121,7 @@ inline static int set_audclk_freq(struct i2c_client *client,
119 cx25840_write4(client, 0x90c, 0x85730108); 121 cx25840_write4(client, 0x90c, 0x85730108);
120 break; 122 break;
121 123
122 case V4L2_AUDCLK_48_KHZ: 124 case 48000:
123 /* VID_PLL and AUX_PLL */ 125 /* VID_PLL and AUX_PLL */
124 cx25840_write4(client, 0x108, 0x0f040a18); 126 cx25840_write4(client, 0x108, 0x0f040a18);
125 127
@@ -317,7 +319,7 @@ int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
317 case AUDC_SET_INPUT: 319 case AUDC_SET_INPUT:
318 return set_input(client, *(int *)arg); 320 return set_input(client, *(int *)arg);
319 case VIDIOC_INT_AUDIO_CLOCK_FREQ: 321 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
320 return set_audclk_freq(client, *(enum v4l2_audio_clock_freq *)arg); 322 return set_audclk_freq(client, *(u32 *)arg);
321 case VIDIOC_G_CTRL: 323 case VIDIOC_G_CTRL:
322 switch (ctrl->id) { 324 switch (ctrl->id) {
323 case V4L2_CID_AUDIO_VOLUME: 325 case V4L2_CID_AUDIO_VOLUME:
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 54ffae686dc9..c2c1e856aa60 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -802,7 +802,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
802 i2c_set_clientdata(client, state); 802 i2c_set_clientdata(client, state);
803 memset(state, 0, sizeof(struct cx25840_state)); 803 memset(state, 0, sizeof(struct cx25840_state));
804 state->input = CX25840_TUNER; 804 state->input = CX25840_TUNER;
805 state->audclk_freq = V4L2_AUDCLK_48_KHZ; 805 state->audclk_freq = 48000;
806 state->audio_input = AUDIO_TUNER; 806 state->audio_input = AUDIO_TUNER;
807 state->cardtype = CARDTYPE_PVR150; 807 state->cardtype = CARDTYPE_PVR150;
808 808
@@ -1008,13 +1008,7 @@ static void log_status(struct i2c_client *client)
1008 cx25840_info("Specified audio input: %s\n", 1008 cx25840_info("Specified audio input: %s\n",
1009 state->audio_input == 0 ? "Tuner" : "External"); 1009 state->audio_input == 0 ? "Tuner" : "External");
1010 1010
1011 switch (state->audclk_freq) { 1011 cx25840_info("Specified audioclock freq: %d Hz\n", state->audclk_freq);
1012 case V4L2_AUDCLK_441_KHZ: p = "44.1 kHz"; break;
1013 case V4L2_AUDCLK_48_KHZ: p = "48 kHz"; break;
1014 case V4L2_AUDCLK_32_KHZ: p = "32 kHz"; break;
1015 default: p = "undefined";
1016 }
1017 cx25840_info("Specified audioclock freq: %s\n", p);
1018 1012
1019 switch (pref_mode & 0xf) { 1013 switch (pref_mode & 0xf) {
1020 case 0: p = "mono/language A"; break; 1014 case 0: p = "mono/language A"; break;
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h
index 40aa59f9c525..4731a19092a6 100644
--- a/drivers/media/video/cx25840/cx25840.h
+++ b/drivers/media/video/cx25840/cx25840.h
@@ -65,7 +65,7 @@ struct cx25840_state {
65 enum cx25840_cardtype cardtype; 65 enum cx25840_cardtype cardtype;
66 enum cx25840_input input; 66 enum cx25840_input input;
67 int audio_input; 67 int audio_input;
68 enum v4l2_audio_clock_freq audclk_freq; 68 u32 audclk_freq;
69}; 69};
70 70
71/* ----------------------------------------------------------------------- */ 71/* ----------------------------------------------------------------------- */