aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-06-23 06:36:23 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-14 17:43:28 -0400
commit04a33e406a062cd1bb55014ee17a3558109a2d74 (patch)
tree2fd681c3ddeb109bcf0720450ac4a32f1553ad0e /drivers/media
parent547d8bb7ddf7f5d9f53741086a394c8318e15f16 (diff)
cpia2: use request_firmware()
Thanks for Jaswinder Singh for converting the firmware blob itself to ihex. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/cpia2/cpia2_core.c46
-rw-r--r--drivers/media/video/cpia2/cpia2patch.h233
2 files changed, 37 insertions, 242 deletions
diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c
index c8b9fdb700ff..f2e8b1c82c66 100644
--- a/drivers/media/video/cpia2/cpia2_core.c
+++ b/drivers/media/video/cpia2/cpia2_core.c
@@ -33,11 +33,10 @@
33 33
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
36#include <linux/firmware.h>
36 37
37/* #define _CPIA2_DEBUG_ */ 38/* #define _CPIA2_DEBUG_ */
38 39
39#include "cpia2patch.h"
40
41#ifdef _CPIA2_DEBUG_ 40#ifdef _CPIA2_DEBUG_
42 41
43static const char *block_name[] = { 42static const char *block_name[] = {
@@ -893,24 +892,53 @@ int cpia2_set_low_power(struct camera_data *cam)
893 * apply_vp_patch 892 * apply_vp_patch
894 * 893 *
895 *****************************************************************************/ 894 *****************************************************************************/
895static int cpia2_send_onebyte_command(struct camera_data *cam,
896 struct cpia2_command *cmd,
897 u8 start, u8 datum)
898{
899 cmd->buffer.block_data[0] = datum;
900 cmd->start = start;
901 cmd->reg_count = 1;
902 return cpia2_send_command(cam, cmd);
903}
904
896static int apply_vp_patch(struct camera_data *cam) 905static int apply_vp_patch(struct camera_data *cam)
897{ 906{
898 int i, j; 907 const struct firmware *fw;
908 const char fw_name[] = "cpia2/stv0672_vp4.bin";
909 int i, ret;
899 struct cpia2_command cmd; 910 struct cpia2_command cmd;
900 911
912 ret = request_firmware(&fw, fw_name, &cam->dev->dev);
913 if (ret) {
914 printk(KERN_ERR "cpia2: failed to load VP patch \"%s\"\n",
915 fw_name);
916 return ret;
917 }
918
901 cmd.req_mode = CAMERAACCESS_TYPE_REPEAT | CAMERAACCESS_VP; 919 cmd.req_mode = CAMERAACCESS_TYPE_REPEAT | CAMERAACCESS_VP;
902 cmd.direction = TRANSFER_WRITE; 920 cmd.direction = TRANSFER_WRITE;
903 921
904 for (i = 0; i < PATCH_DATA_SIZE; i++) { 922 /* First send the start address... */
905 for (j = 0; j < patch_data[i].count; j++) { 923 cpia2_send_onebyte_command(cam, &cmd, 0x0A, fw->data[0]); /* hi */
906 cmd.buffer.block_data[j] = patch_data[i].data[j]; 924 cpia2_send_onebyte_command(cam, &cmd, 0x0B, fw->data[1]); /* lo */
907 }
908 925
909 cmd.start = patch_data[i].reg; 926 /* ... followed by the data payload */
910 cmd.reg_count = patch_data[i].count; 927 for (i = 2; i < fw->size; i += 64) {
928 cmd.start = 0x0C; /* Data */
929 cmd.reg_count = min_t(int, 64, fw->size - i);
930 memcpy(cmd.buffer.block_data, &fw->data[i], cmd.reg_count);
911 cpia2_send_command(cam, &cmd); 931 cpia2_send_command(cam, &cmd);
912 } 932 }
913 933
934 /* Next send the start address... */
935 cpia2_send_onebyte_command(cam, &cmd, 0x0A, fw->data[0]); /* hi */
936 cpia2_send_onebyte_command(cam, &cmd, 0x0B, fw->data[1]); /* lo */
937
938 /* ... followed by the 'goto' command */
939 cpia2_send_onebyte_command(cam, &cmd, 0x0D, 1);
940
941 release_firmware(fw);
914 return 0; 942 return 0;
915} 943}
916 944
diff --git a/drivers/media/video/cpia2/cpia2patch.h b/drivers/media/video/cpia2/cpia2patch.h
deleted file mode 100644
index 7f085fbe76fb..000000000000
--- a/drivers/media/video/cpia2/cpia2patch.h
+++ /dev/null
@@ -1,233 +0,0 @@
1/****************************************************************************
2 *
3 * Filename: cpia2patch.h
4 *
5 * Copyright 2001, STMicrolectronics, Inc.
6 *
7 * Contact: steve.miller@st.com
8 *
9 * Description:
10 * This file contains patch data for the CPiA2 (stv0672) VP4.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 ****************************************************************************/
27
28#ifndef CPIA2_PATCH_HEADER
29#define CPIA2_PATCH_HEADER
30
31typedef struct {
32 unsigned char reg;
33 unsigned char count;
34 const unsigned char *data;
35} cpia2_patch;
36
37static const unsigned char start_address_hi[1] = {
38 0x01
39};
40
41static const unsigned char start_address_lo[1] = {
42 0xBC
43};
44
45static const unsigned char patch_block0[64] = {
46 0xE3, 0x02, 0xE3, 0x03, 0xE3, 0x04, 0xE3, 0x05,
47 0xE3, 0x06, 0xE3, 0x07, 0x93, 0x44, 0x56, 0xD4,
48 0x93, 0x4E, 0x56, 0x51, 0x93, 0x4E, 0x51, 0xD6,
49 0x93, 0x4E, 0x4F, 0x54, 0x93, 0x4E, 0x92, 0x4F,
50 0x92, 0xA4, 0x93, 0x05, 0x92, 0xF4, 0x93, 0x1B,
51 0x92, 0x92, 0x91, 0xE6, 0x92, 0x36, 0x92, 0x74,
52 0x92, 0x4A, 0x92, 0x8C, 0x92, 0x8E, 0xC8, 0xD0,
53 0x0B, 0x42, 0x02, 0xA0, 0xCA, 0x92, 0x09, 0x02
54};
55
56static const unsigned char patch_block1[64] = {
57 0xC9, 0x10, 0x0A, 0x0A, 0x0A, 0x81, 0xE3, 0xB8,
58 0xE3, 0xB0, 0xE3, 0xA8, 0xE3, 0xA0, 0xE3, 0x98,
59 0xE3, 0x90, 0xE1, 0x00, 0xCF, 0xD7, 0x0A, 0x12,
60 0xCC, 0x95, 0x08, 0xB2, 0x0A, 0x18, 0xE1, 0x00,
61 0x01, 0xEE, 0x0C, 0x08, 0x4A, 0x12, 0xC8, 0x18,
62 0xF0, 0x9A, 0xC0, 0x22, 0xF3, 0x1C, 0x4A, 0x13,
63 0xF3, 0x14, 0xC8, 0xA0, 0xF2, 0x14, 0xF2, 0x1C,
64 0xEB, 0x13, 0xD3, 0xA2, 0x63, 0x16, 0x48, 0x9E
65};
66
67static const unsigned char patch_block2[64] = {
68 0xF0, 0x18, 0xA4, 0x03, 0xF3, 0x93, 0xC0, 0x58,
69 0xF7, 0x13, 0x51, 0x9C, 0xE9, 0x20, 0xCF, 0xEF,
70 0x63, 0xF9, 0x92, 0x2E, 0xD3, 0x5F, 0x63, 0xFA,
71 0x92, 0x2E, 0xD3, 0x67, 0x63, 0xFB, 0x92, 0x2E,
72 0xD3, 0x6F, 0xE9, 0x1A, 0x63, 0x16, 0x48, 0xA7,
73 0xF0, 0x20, 0xA4, 0x06, 0xF3, 0x94, 0xC0, 0x27,
74 0xF7, 0x14, 0xF5, 0x13, 0x51, 0x9D, 0xF6, 0x13,
75 0x63, 0x18, 0xC4, 0x20, 0xCB, 0xEF, 0x63, 0xFC
76};
77
78static const unsigned char patch_block3[64] = {
79 0x92, 0x2E, 0xD3, 0x77, 0x63, 0xFD, 0x92, 0x2E,
80 0xD3, 0x7F, 0x63, 0xFE, 0x92, 0x2E, 0xD3, 0x87,
81 0x63, 0xFF, 0x92, 0x2E, 0xD3, 0x8F, 0x64, 0x38,
82 0x92, 0x2E, 0xD3, 0x97, 0x64, 0x39, 0x92, 0x2E,
83 0xD3, 0x9F, 0xE1, 0x00, 0xF5, 0x3A, 0xF4, 0x3B,
84 0xF7, 0xBF, 0xF2, 0xBC, 0xF2, 0x3D, 0xE1, 0x00,
85 0x80, 0x87, 0x90, 0x80, 0x51, 0xD5, 0x02, 0x22,
86 0x02, 0x32, 0x4B, 0xD3, 0xF7, 0x11, 0x0B, 0xDA
87};
88
89static const unsigned char patch_block4[64] = {
90 0xE1, 0x00, 0x0E, 0x02, 0x02, 0x40, 0x0D, 0xB5,
91 0xE3, 0x02, 0x48, 0x55, 0xE5, 0x12, 0xA4, 0x01,
92 0xE8, 0x1B, 0xE3, 0x90, 0xF0, 0x18, 0xA4, 0x01,
93 0xE8, 0xBF, 0x8D, 0xB8, 0x4B, 0xD1, 0x4B, 0xD8,
94 0x0B, 0xCB, 0x0B, 0xC2, 0xE1, 0x00, 0xE3, 0x02,
95 0xE3, 0x03, 0x52, 0xD3, 0x60, 0x59, 0xE6, 0x93,
96 0x0D, 0x22, 0x52, 0xD4, 0xE6, 0x93, 0x0D, 0x2A,
97 0xE3, 0x98, 0xE3, 0x90, 0xE1, 0x00, 0x02, 0x5D
98};
99
100static const unsigned char patch_block5[64] = {
101 0x02, 0x63, 0xE3, 0x02, 0xC8, 0x12, 0x02, 0xCA,
102 0xC8, 0x52, 0x02, 0xC2, 0x82, 0x68, 0xE3, 0x02,
103 0xC8, 0x14, 0x02, 0xCA, 0xC8, 0x90, 0x02, 0xC2,
104 0x0A, 0xD0, 0xC9, 0x93, 0x0A, 0xDA, 0xCC, 0xD2,
105 0x0A, 0xE2, 0x63, 0x12, 0x02, 0xDA, 0x0A, 0x98,
106 0x0A, 0xA0, 0x0A, 0xA8, 0xE3, 0x90, 0xE1, 0x00,
107 0xE3, 0x02, 0x0A, 0xD0, 0xC9, 0x93, 0x0A, 0xDA,
108 0xCC, 0xD2, 0x0A, 0xE2, 0x63, 0x12, 0x02, 0xDA
109};
110
111static const unsigned char patch_block6[64] = {
112 0x0A, 0x98, 0x0A, 0xA0, 0x0A, 0xA8, 0x49, 0x91,
113 0xE5, 0x6A, 0xA4, 0x04, 0xC8, 0x12, 0x02, 0xCA,
114 0xC8, 0x52, 0x82, 0x89, 0xC8, 0x14, 0x02, 0xCA,
115 0xC8, 0x90, 0x02, 0xC2, 0xE3, 0x90, 0xE1, 0x00,
116 0x08, 0x60, 0xE1, 0x00, 0x48, 0x53, 0xE8, 0x97,
117 0x08, 0x5A, 0xE1, 0x00, 0xE3, 0x02, 0xE3, 0x03,
118 0x54, 0xD3, 0x60, 0x59, 0xE6, 0x93, 0x0D, 0x52,
119 0xE3, 0x98, 0xE3, 0x90, 0xE1, 0x00, 0x02, 0x9C
120};
121
122static const unsigned char patch_block7[64] = {
123 0xE3, 0x02, 0x55, 0x13, 0x93, 0x17, 0x55, 0x13,
124 0x93, 0x17, 0xE3, 0x90, 0xE1, 0x00, 0x75, 0x30,
125 0xE3, 0x02, 0xE3, 0x03, 0x55, 0x55, 0x60, 0x59,
126 0xE6, 0x93, 0x0D, 0xB2, 0xE3, 0x98, 0xE3, 0x90,
127 0xE1, 0x00, 0x02, 0xAE, 0xE7, 0x92, 0xE9, 0x18,
128 0xEA, 0x9A, 0xE8, 0x98, 0xE8, 0x10, 0xE8, 0x11,
129 0xE8, 0x51, 0xD2, 0xDA, 0xD2, 0xF3, 0xE8, 0x13,
130 0xD2, 0xFA, 0xE8, 0x50, 0xD2, 0xEA, 0xE8, 0xD0
131};
132
133static const unsigned char patch_block8[64] = {
134 0xE8, 0xD1, 0xD3, 0x0A, 0x03, 0x09, 0x48, 0x23,
135 0xE5, 0x2C, 0xA0, 0x03, 0x48, 0x24, 0xEA, 0x1C,
136 0x03, 0x08, 0xD2, 0xE3, 0xD3, 0x03, 0xD3, 0x13,
137 0xE1, 0x00, 0x02, 0xCB, 0x05, 0x93, 0x57, 0x93,
138 0xF0, 0x9A, 0xAC, 0x0B, 0xE3, 0x07, 0x92, 0xEA,
139 0xE2, 0x9F, 0xE5, 0x06, 0xE3, 0xB0, 0xA0, 0x02,
140 0xEB, 0x1E, 0x82, 0xD7, 0xEA, 0x1E, 0xE2, 0x3B,
141 0x85, 0x9B, 0xE9, 0x1E, 0xC8, 0x90, 0x85, 0x94
142};
143
144static const unsigned char patch_block9[64] = {
145 0x02, 0xDE, 0x05, 0x80, 0x57, 0x93, 0xF0, 0xBA,
146 0xAC, 0x06, 0x92, 0xEA, 0xE2, 0xBF, 0xE5, 0x06,
147 0xA0, 0x01, 0xEB, 0xBF, 0x85, 0x88, 0xE9, 0x3E,
148 0xC8, 0x90, 0x85, 0x81, 0xE9, 0x3E, 0xF0, 0xBA,
149 0xF3, 0x39, 0xF0, 0x3A, 0x60, 0x17, 0xF0, 0x3A,
150 0xC0, 0x90, 0xF0, 0xBA, 0xE1, 0x00, 0x00, 0x3F,
151 0xE3, 0x02, 0xE3, 0x03, 0x58, 0x10, 0x60, 0x59,
152 0xE6, 0x93, 0x0D, 0xA2, 0x58, 0x12, 0xE6, 0x93
153};
154
155static const unsigned char patch_block10[64] = {
156 0x0D, 0xAA, 0xE3, 0x98, 0xE3, 0x90, 0xE1, 0x00,
157 0x03, 0x01, 0xE1, 0x00, 0x03, 0x03, 0x9B, 0x7D,
158 0x8B, 0x8B, 0xE3, 0x02, 0xE3, 0x03, 0x58, 0x56,
159 0x60, 0x59, 0xE6, 0x93, 0x0D, 0xBA, 0xE3, 0x98,
160 0xE3, 0x90, 0xE1, 0x00, 0x03, 0x0F, 0x93, 0x11,
161 0xE1, 0x00, 0xE3, 0x02, 0x4A, 0x11, 0x0B, 0x42,
162 0x91, 0xAF, 0xE3, 0x90, 0xE1, 0x00, 0xF2, 0x91,
163 0xF0, 0x91, 0xA3, 0xFE, 0xE1, 0x00, 0x60, 0x92
164};
165
166static const unsigned char patch_block11[64] = {
167 0xC0, 0x5F, 0xF0, 0x13, 0xF0, 0x13, 0x59, 0x5B,
168 0xE2, 0x13, 0xF0, 0x11, 0x5A, 0x19, 0xE2, 0x13,
169 0xE1, 0x00, 0x00, 0x00, 0x03, 0x27, 0x68, 0x61,
170 0x76, 0x61, 0x6E, 0x61, 0x00, 0x06, 0x03, 0x2C,
171 0xE3, 0x02, 0xE3, 0x03, 0xE9, 0x38, 0x59, 0x15,
172 0x59, 0x5A, 0xF2, 0x9A, 0xBC, 0x0B, 0xA4, 0x0A,
173 0x59, 0x1E, 0xF3, 0x11, 0xF0, 0x1A, 0xE2, 0xBB,
174 0x59, 0x15, 0xF0, 0x11, 0x19, 0x2A, 0xE5, 0x02
175};
176
177static const unsigned char patch_block12[54] = {
178 0xA4, 0x01, 0xEB, 0xBF, 0xE3, 0x98, 0xE3, 0x90,
179 0xE1, 0x00, 0x03, 0x42, 0x19, 0x28, 0xE1, 0x00,
180 0xE9, 0x30, 0x60, 0x79, 0xE1, 0x00, 0xE3, 0x03,
181 0xE3, 0x07, 0x60, 0x79, 0x93, 0x4E, 0xE3, 0xB8,
182 0xE3, 0x98, 0xE1, 0x00, 0xE9, 0x1A, 0xF0, 0x1F,
183 0xE2, 0x33, 0xF0, 0x91, 0xE2, 0x92, 0xE0, 0x32,
184 0xF0, 0x31, 0xE1, 0x00, 0x00, 0x00
185};
186
187static const unsigned char do_call[1] = {
188 0x01
189};
190
191
192#define PATCH_DATA_SIZE 18
193
194static const cpia2_patch patch_data[PATCH_DATA_SIZE] = {
195 {0x0A, sizeof(start_address_hi), start_address_hi}
196 , // 0
197 {0x0B, sizeof(start_address_lo), start_address_lo}
198 , // 1
199 {0x0C, sizeof(patch_block0), patch_block0}
200 , // 2
201 {0x0C, sizeof(patch_block1), patch_block1}
202 , // 3
203 {0x0C, sizeof(patch_block2), patch_block2}
204 , // 4
205 {0x0C, sizeof(patch_block3), patch_block3}
206 , // 5
207 {0x0C, sizeof(patch_block4), patch_block4}
208 , // 6
209 {0x0C, sizeof(patch_block5), patch_block5}
210 , // 7
211 {0x0C, sizeof(patch_block6), patch_block6}
212 , // 8
213 {0x0C, sizeof(patch_block7), patch_block7}
214 , // 9
215 {0x0C, sizeof(patch_block8), patch_block8}
216 , // 10
217 {0x0C, sizeof(patch_block9), patch_block9}
218 , //11
219 {0x0C, sizeof(patch_block10), patch_block10}
220 , // 12
221 {0x0C, sizeof(patch_block11), patch_block11}
222 , // 13
223 {0x0C, sizeof(patch_block12), patch_block12}
224 , // 14
225 {0x0A, sizeof(start_address_hi), start_address_hi}
226 , // 15
227 {0x0B, sizeof(start_address_lo), start_address_lo}
228 , // 16
229 {0x0D, sizeof(do_call), do_call} //17
230};
231
232
233#endif