Skip to content

Commit

Permalink
cpia2: use request_firmware()
Browse files Browse the repository at this point in the history
Thanks for Jaswinder Singh for converting the firmware blob itself to ihex.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
dwmw2 authored and David Woodhouse committed Jul 14, 2008
1 parent 547d8bb commit 04a33e4
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 242 deletions.
46 changes: 37 additions & 9 deletions drivers/media/video/cpia2/cpia2_core.c
Expand Up @@ -33,11 +33,10 @@

#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/firmware.h>

/* #define _CPIA2_DEBUG_ */

#include "cpia2patch.h"

#ifdef _CPIA2_DEBUG_

static const char *block_name[] = {
Expand Down Expand Up @@ -893,24 +892,53 @@ int cpia2_set_low_power(struct camera_data *cam)
* apply_vp_patch
*
*****************************************************************************/
static int cpia2_send_onebyte_command(struct camera_data *cam,
struct cpia2_command *cmd,
u8 start, u8 datum)
{
cmd->buffer.block_data[0] = datum;
cmd->start = start;
cmd->reg_count = 1;
return cpia2_send_command(cam, cmd);
}

static int apply_vp_patch(struct camera_data *cam)
{
int i, j;
const struct firmware *fw;
const char fw_name[] = "cpia2/stv0672_vp4.bin";
int i, ret;
struct cpia2_command cmd;

ret = request_firmware(&fw, fw_name, &cam->dev->dev);
if (ret) {
printk(KERN_ERR "cpia2: failed to load VP patch \"%s\"\n",
fw_name);
return ret;
}

cmd.req_mode = CAMERAACCESS_TYPE_REPEAT | CAMERAACCESS_VP;
cmd.direction = TRANSFER_WRITE;

for (i = 0; i < PATCH_DATA_SIZE; i++) {
for (j = 0; j < patch_data[i].count; j++) {
cmd.buffer.block_data[j] = patch_data[i].data[j];
}
/* First send the start address... */
cpia2_send_onebyte_command(cam, &cmd, 0x0A, fw->data[0]); /* hi */
cpia2_send_onebyte_command(cam, &cmd, 0x0B, fw->data[1]); /* lo */

cmd.start = patch_data[i].reg;
cmd.reg_count = patch_data[i].count;
/* ... followed by the data payload */
for (i = 2; i < fw->size; i += 64) {
cmd.start = 0x0C; /* Data */
cmd.reg_count = min_t(int, 64, fw->size - i);
memcpy(cmd.buffer.block_data, &fw->data[i], cmd.reg_count);
cpia2_send_command(cam, &cmd);
}

/* Next send the start address... */
cpia2_send_onebyte_command(cam, &cmd, 0x0A, fw->data[0]); /* hi */
cpia2_send_onebyte_command(cam, &cmd, 0x0B, fw->data[1]); /* lo */

/* ... followed by the 'goto' command */
cpia2_send_onebyte_command(cam, &cmd, 0x0D, 1);

release_firmware(fw);
return 0;
}

Expand Down
233 changes: 0 additions & 233 deletions drivers/media/video/cpia2/cpia2patch.h

This file was deleted.

1 change: 1 addition & 0 deletions firmware/Makefile
Expand Up @@ -60,6 +60,7 @@ fw-shipped-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat_loader.fw whiteheat.fw \
# whiteheat_loader_debug.fw
fw-shipped-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda/keyspan_pda.fw
fw-shipped-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda/xircom_pgs.fw
fw-shipped-$(CONFIG_VIDEO_CPIA2) += cpia2/stv0672_vp4.bin

fw-shipped-all := $(fw-shipped-y) $(fw-shipped-m) $(fw-shipped-)

Expand Down
13 changes: 13 additions & 0 deletions firmware/WHENCE
Expand Up @@ -236,3 +236,16 @@ Licence: Unknown
Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: CPiA2 -- cameras based on Vision's CPiA2

File: cpia2/stv0672_vp4.bin

Licence: Allegedly GPLv2+, but no source visible. Marked:
Copyright (C) 2001 STMicroelectronics, Inc.
Contact: steve.miller@st.com
Description: This file contains patch data for the CPiA2 (stv0672) VP4.

Found in hex form in kernel source.

--------------------------------------------------------------------------

0 comments on commit 04a33e4

Please sign in to comment.