Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 161589
b: refs/heads/master
c: 8d81ae2
h: refs/heads/master
i:
  161587: 813a56a
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Sep 12, 2009
1 parent 4140e2a commit a35a7de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a65f3159244f27ce6ff84dd1bb641079acdbd396
refs/heads/master: 8d81ae243158b0ac8b2c1646d5adcbdf26a260bc
35 changes: 22 additions & 13 deletions trunk/drivers/media/video/cx25840/cx25840-firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@

#include "cx25840-core.h"

#define FWFILE "v4l-cx25840.fw"
#define FWFILE_CX23885 "v4l-cx23885-avcore-01.fw"
#define FWFILE_CX231XX "v4l-cx231xx-avcore-01.fw"

/*
* Mike Isely <isely@pobox.com> - The FWSEND parameter controls the
* size of the firmware chunks sent down the I2C bus to the chip.
Expand All @@ -40,11 +36,11 @@

#define FWDEV(x) &((x)->dev)

static char *firmware = FWFILE;
static char *firmware = "";

module_param(firmware, charp, 0444);

MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]");
MODULE_PARM_DESC(firmware, "Firmware image to load");

static void start_fw_load(struct i2c_client *client)
{
Expand All @@ -65,18 +61,33 @@ static void end_fw_load(struct i2c_client *client)
cx25840_write(client, 0x803, 0x03);
}

static const char *get_fw_name(struct i2c_client *client)
{
struct cx25840_state *state = to_state(i2c_get_clientdata(client));

if (firmware[0])
return firmware;
if (state->is_cx23885)
return "v4l-cx23885-avcore-01.fw";
if (state->is_cx231xx)
return "v4l-cx231xx-avcore-01.fw";
return "v4l-cx25840.fw";
}

static int check_fw_load(struct i2c_client *client, int size)
{
/* DL_ADDR_HB DL_ADDR_LB */
int s = cx25840_read(client, 0x801) << 8;
s |= cx25840_read(client, 0x800);

if (size != s) {
v4l_err(client, "firmware %s load failed\n", firmware);
v4l_err(client, "firmware %s load failed\n",
get_fw_name(client));
return -EINVAL;
}

v4l_info(client, "loaded %s firmware (%d bytes)\n", firmware, size);
v4l_info(client, "loaded %s firmware (%d bytes)\n",
get_fw_name(client), size);
return 0;
}

Expand All @@ -96,26 +107,24 @@ int cx25840_loadfw(struct i2c_client *client)
const struct firmware *fw = NULL;
u8 buffer[FWSEND];
const u8 *ptr;
const char *fwname = get_fw_name(client);
int size, retval;
int MAX_BUF_SIZE = FWSEND;
u32 gpio_oe = 0, gpio_da = 0;

if (state->is_cx23885) {
firmware = FWFILE_CX23885;
/* Preserve the GPIO OE and output bits */
gpio_oe = cx25840_read(client, 0x160);
gpio_da = cx25840_read(client, 0x164);
}
else if (state->is_cx231xx)
firmware = FWFILE_CX231XX;

if ((state->is_cx231xx) && MAX_BUF_SIZE > 16) {
v4l_err(client, " Firmware download size changed to 16 bytes max length\n");
MAX_BUF_SIZE = 16; /* cx231xx cannot accept more than 16 bytes at a time */
}

if (request_firmware(&fw, firmware, FWDEV(client)) != 0) {
v4l_err(client, "unable to open firmware %s\n", firmware);
if (request_firmware(&fw, fwname, FWDEV(client)) != 0) {
v4l_err(client, "unable to open firmware %s\n", fwname);
return -EINVAL;
}

Expand Down

0 comments on commit a35a7de

Please sign in to comment.