Commit f234081b authored by Steven Toth's avatar Steven Toth Committed by Mauro Carvalho Chehab

V4L/DVB (7002): cx25840: Add basic CX23885 AVCore support

The cx23885/7/8 PCIe bridge has an internal AVCore modelled on
the cx2584x family. Many of the registers positions are identical
but some moved. The register values are also different because
the different bridges run at different clock rates.
Signed-off-by: default avatarSteven Toth <stoth@hauppauge.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent d05051c8
......@@ -32,11 +32,17 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
/* common for all inputs and rates */
/* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
cx25840_write(client, 0x127, 0x50);
if (!state->is_cx23885)
cx25840_write(client, 0x127, 0x50);
if (state->aud_input != CX25840_AUDIO_SERIAL) {
switch (freq) {
case 32000:
if (state->is_cx23885) {
/* We don't have register values
* so avoid destroying registers. */
break;
}
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1006040f);
......@@ -53,6 +59,11 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;
case 44100:
if (state->is_cx23885) {
/* We don't have register values
* so avoid destroying registers. */
break;
}
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1009040f);
......@@ -69,6 +80,11 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;
case 48000:
if (state->is_cx23885) {
/* We don't have register values
* so avoid destroying registers. */
break;
}
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x100a040f);
......@@ -87,6 +103,11 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
} else {
switch (freq) {
case 32000:
if (state->is_cx23885) {
/* We don't have register values
* so avoid destroying registers. */
break;
}
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1e08040f);
......@@ -109,6 +130,12 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;
case 44100:
if (state->is_cx23885) {
/* We don't have register values
* so avoid destroying registers. */
break;
}
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x1809040f);
......@@ -128,22 +155,33 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
break;
case 48000:
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x180a040f);
if (!state->is_cx23885) {
/* VID_PLL and AUX_PLL */
cx25840_write4(client, 0x108, 0x180a040f);
/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x0098d6e5);
/* AUX_PLL_FRAC */
cx25840_write4(client, 0x110, 0x0098d6e5);
}
if (state->is_cx25836)
break;
/* src1_ctl = 0x08010000 */
cx25840_write4(client, 0x8f8, 0x08018000);
if (!state->is_cx23885) {
/* src1_ctl */
cx25840_write4(client, 0x8f8, 0x08018000);
/* src3/4/6_ctl = 0x08020000 */
cx25840_write4(client, 0x900, 0x08015555);
cx25840_write4(client, 0x904, 0x08015555);
cx25840_write4(client, 0x90c, 0x08015555);
/* src3/4/6_ctl */
cx25840_write4(client, 0x900, 0x08015555);
cx25840_write4(client, 0x904, 0x08015555);
cx25840_write4(client, 0x90c, 0x08015555);
} else {
cx25840_write4(client, 0x8f8, 0x0801867c);
cx25840_write4(client, 0x900, 0x08014faa);
cx25840_write4(client, 0x904, 0x08014faa);
cx25840_write4(client, 0x90c, 0x08014faa);
}
break;
}
}
......@@ -188,6 +226,11 @@ void cx25840_audio_set_path(struct i2c_client *client)
/* deassert soft reset */
cx25840_and_or(client, 0x810, ~0x1, 0x00);
if (state->is_cx23885) {
/* Ensure the controller is running when we exit */
cx25840_and_or(client, 0x803, ~0x10, 0x10);
}
}
static int get_volume(struct i2c_client *client)
......
This diff is collapsed.
......@@ -47,6 +47,7 @@ struct cx25840_state {
u32 id;
u32 rev;
int is_cx25836;
int is_cx23885;
int is_initialized;
wait_queue_head_t fw_wait; /* wake up when the fw load is finished */
struct work_struct fw_work; /* work entry for fw load */
......
......@@ -24,6 +24,7 @@
#include "cx25840-core.h"
#define FWFILE "v4l-cx25840.fw"
#define FWFILE_CX23885 "v4l-cx23885-avcore-01.fw"
/*
* Mike Isely <isely@pobox.com> - The FWSEND parameter controls the
......@@ -92,10 +93,14 @@ static int fw_write(struct i2c_client *client, u8 * data, int size)
int cx25840_loadfw(struct i2c_client *client)
{
struct cx25840_state *state = i2c_get_clientdata(client);
const struct firmware *fw = NULL;
u8 buffer[4], *ptr;
int size, send, retval;
if (state->is_cx23885)
firmware = FWFILE_CX23885;
if (request_firmware(&fw, firmware, FWDEV(client)) != 0) {
v4l_err(client, "unable to open firmware %s\n", firmware);
return -EINVAL;
......
......@@ -49,6 +49,25 @@ enum cx25840_video_input {
CX25840_SVIDEO2 = 0x620,
CX25840_SVIDEO3 = 0x730,
CX25840_SVIDEO4 = 0x840,
/* Allow frames to specify specific input configurations */
CX25840_VIN1_CH1 = 0x80000000,
CX25840_VIN2_CH1 = 0x80000001,
CX25840_VIN3_CH1 = 0x80000002,
CX25840_VIN4_CH1 = 0x80000003,
CX25840_VIN5_CH1 = 0x80000004,
CX25840_VIN6_CH1 = 0x80000005,
CX25840_VIN7_CH1 = 0x80000006,
CX25840_VIN8_CH1 = 0x80000007,
CX25840_VIN4_CH2 = 0x80000000,
CX25840_VIN5_CH2 = 0x80000010,
CX25840_VIN6_CH2 = 0x80000020,
CX25840_NONE_CH2 = 0x80000030,
CX25840_VIN7_CH3 = 0x80000000,
CX25840_VIN8_CH3 = 0x80000040,
CX25840_NONE0_CH3 = 0x80000080,
CX25840_NONE1_CH3 = 0x800000c0,
CX25840_SVIDEO_ON = 0x80000100,
};
enum cx25840_audio_input {
......
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