summaryrefslogtreecommitdiff
path: root/Source/DirectFB/gfxdrivers/davinci/kernel-module/include/linux/c64x.h
blob: 6117404d22bbee1153e5dc594fd11cc21f673d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
   TI Davinci driver - C64X+ DSP Firmware Interface

   (c) Copyright 2008  directfb.org
   (c) Copyright 2007  Telio AG

   Written by Olaf Dreesen <olaf@directfb.org> and
              Denis Oliver Kropp <dok@directfb.org>.

   All rights reserved.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#ifndef __C64X_H__
#define __C64X_H__

#ifndef __KERNEL__
#include <stdint.h>
#endif


#ifndef DAVINCI_C64X_MEM
#define DAVINCI_C64X_MEM 0x8e000000
#endif


typedef volatile struct {
     uint32_t  c64x_function;
     uint32_t  c64x_arg[7];
} c64xTask;


#define c64x_return	c64x_arg[0]
#define c64x_errno	c64x_arg[1]

#define c64x_flags	c64x_function

typedef enum {
     C64X_STATE_DONE     = 0,
     C64X_STATE_ERROR    = 1,
     C64X_STATE_TODO     = 2,
     C64X_STATE_RUNNING  = 3
} C64XTaskState;

typedef enum {
     C64X_FLAG_RUN       = 1,
     C64X_FLAG_TODO      = 2,
     C64X_FLAG_INTERRUPT = 0x80000000
} C64XTaskFlags;

#define C64X_TASK_STATE(task) ((task)->c64x_flags & 3)

typedef volatile struct {
     uint32_t  QH_dsp;
     uint32_t  QH_arm;
     uint32_t  QL_dsp;
     uint32_t  QL_arm;
     uint32_t  idlecounter;
} c64xTaskControl;

#define C64X_QUEUE_LENGTH     0x4000
#define C64X_QUEUE_MASK       0x3fff


typedef enum {
     C64X_BLEND_SRC_INVSRC               = 2,  /* old school fader on all channels including alpha on itself */
     C64X_BLEND_ONE_INVSRC               = 1,  /* SrcOver using premultiplied alpha channel */
     C64X_BLEND_ONE_INVSRC_PREMULT_SRC   = 0,  /* SrcOver doing premultiplication of source S[rgb] with S[a] */
     C64X_BLEND_ONE_INVSRC_PREMULT_ALPHA = 3,  /* SrcOver with Alpha using premultiplied alpha channel,
                                                  but doing premultiplication of S[rgb] with Alpha */
} C64XBlendSubFunction;

typedef enum {
     C64X_FLUSH_WRITE_BACK,
     C64X_FLUSH_WB_INVALIDATE,
     C64X_FLUSH_INVALIDATE
} C64XFlushFunction;

#define C64X_IOCTL_RESET      _IO( 'c', 0 )
#define C64X_IOCTL_WAIT_LOW   _IO( 'c', 1 )


/* function macro */
#define _C64XFUNC(val)             (((val)&0x3fff)<<2)


#define C64X_NOP	                _C64XFUNC(0)

/*
void c64x_dither_argb(u32*dst_rgb, u8*dst_alpha, u32 dst_pitch, u32*src, u32 src_pitch, u32 width, u32 height);
*/
#define C64X_DITHER_ARGB	        _C64XFUNC(1)

/*
void c64x_fill_16(u16*dst, u32 pitch, u32 width, u32 height, u16 val);
void c64x_fill_32(u32*dst, u32 pitch, u32 width, u32 height, u32 val);
*/
#define C64X_FILL_16	                _C64XFUNC(2)
#define C64X_FILL_32	                _C64XFUNC(3)

/*
void c64x_copy_16(u16*dst, u32 dst_pitch, u16*src, u32 src_pitch, u32 width, u32 height);
void c64x_copy_32(u32*dst, u32 dst_pitch, u32*src, u32 src_pitch, u32 width, u32 height);
*/
#define C64X_COPY_16	                _C64XFUNC(4)
#define C64X_COPY_32	                _C64XFUNC(5)

/*
void c64x_blend_32(u32*dst, u32 dst_pitch, u32*src, u32 src_pitch, u32 width, u32 height, u8 alpha);
*/
//#define C64X_BLEND_16	                  _C64XFUNC(6)
#define C64X_BLEND_32	                _C64XFUNC(7)

/*
void c64x_copy_keyed_16(u16*dst, u32 pitches, u16*src, u32 width, u32 height, u16 key, u16 mask);
void c64x_copy_keyed_32(u32*dst, u32 pitches, u32*src, u32 width, u32 height, u32 key, u32 mask);
*/
#define C64X_COPY_KEYED_16	        _C64XFUNC(8)
#define C64X_COPY_KEYED_32	        _C64XFUNC(9)

/*
void c64x_stretch_32(u32 *dst, u32 *src, u32 pitches, u32 dsize, u32 ssize, u32 clip2, u32 clip1);
*/
#define C64X_STRETCH_32_up              _C64XFUNC(10)
#define C64X_STRETCH_32_down            _C64XFUNC(11)


/*
void c64x_wb_inv_range(u32 *start, u32 len, C64XFlushFunction func);
*/
#define C64X_WB_INV_RANGE	        _C64XFUNC(14)


/*
void c64x_write_back_all(void);
*/
#define C64X_WRITE_BACK_ALL	        _C64XFUNC(15)



/*
void c64x_load_block(s32*blockwords, u32 num_words, u32 cbp);
*/
#define C64X_LOAD_BLOCK                 _C64XFUNC(48)

/*
void c64x_put_idct_uyvy_16x16(u16*dst, u32 pitch, u32 flags);
*/
#define C64X_PUT_IDCT_UYVY_16x16        _C64XFUNC(49)

/*
void c64x_put_mc_uyvy_16x16(u16*dst, u32 pitch, u32 flags);
*/
#define C64X_PUT_MC_UYVY_16x16          _C64XFUNC(50)

/*
void c64x_put_sum_uyvy_16x16(u16*dst, u32 pitch, u32 flags);
*/
#define C64X_PUT_SUM_UYVY_16x16         _C64XFUNC(51)

/*
void c64x_dva_begin_frame(u32 pitch, u16 *current, u16 *past, u16 *future, u32 flags);
*/
#define C64X_DVA_BEGIN_FRAME            _C64XFUNC(52)

/*
void c64x_dva_motion(DVAMacroBlock *macroblock);
*/
#define C64X_DVA_MOTION_BLOCK           _C64XFUNC(53)

/*
void c64x_dva_idct(u16* dst, u32 pitch, u16* src);
*/
#define C64X_DVA_IDCT                   _C64XFUNC(59)



/*
 * INTERNAL - for testing
 */
#define C64X_FETCH_BUFFER_PITCH    32
#define C64X_TEMP_BUFFER_PITCH     32
#define C64X_MC_BUFFER_PITCH       16
#define C64X_IDCT_BUFFER_PITCH     32

#define C64X_FETCH_BUFFER_Y(n)     (0xf05840 + ((n) << 10))
#define C64X_FETCH_BUFFER_U(n)     (C64X_FETCH_BUFFER_Y(n) + 18*C64X_FETCH_BUFFER_PITCH)
#define C64X_FETCH_BUFFER_V(n)     (C64X_FETCH_BUFFER_U(n) + 16)

#define C64X_FETCH_BUFFER0_Y       C64X_FETCH_BUFFER_Y(0)
#define C64X_FETCH_BUFFER0_U       C64X_FETCH_BUFFER_U(0)
#define C64X_FETCH_BUFFER0_V       C64X_FETCH_BUFFER_V(0)

#define C64X_FETCH_BUFFER1_Y       C64X_FETCH_BUFFER_Y(1)
#define C64X_FETCH_BUFFER1_U       C64X_FETCH_BUFFER_U(1)
#define C64X_FETCH_BUFFER1_V       C64X_FETCH_BUFFER_V(1)

#define C64X_TEMP_BUFFER_Y         0xf06040
#define C64X_TEMP_BUFFER_U         (C64X_TEMP_BUFFER_Y + 16*C64X_TEMP_BUFFER_PITCH)
#define C64X_TEMP_BUFFER_V         (C64X_TEMP_BUFFER_U + 8)

#define C64X_MC_BUFFER_Y           0xf06440
#define C64X_MC_BUFFER_U           (C64X_MC_BUFFER_Y + 16*C64X_MC_BUFFER_PITCH)
#define C64X_MC_BUFFER_V           (C64X_MC_BUFFER_U + 8)

#define C64X_MC_BUFFER_Y_          (C64X_MC_BUFFER_Y + C64X_MC_BUFFER_PITCH)
#define C64X_MC_BUFFER_U_          (C64X_MC_BUFFER_U + C64X_MC_BUFFER_PITCH)
#define C64X_MC_BUFFER_V_          (C64X_MC_BUFFER_V + C64X_MC_BUFFER_PITCH)

#define C64X_IDCT_BUFFER_Y         0xf06a40
#define C64X_IDCT_BUFFER_U         (C64X_IDCT_BUFFER_Y + 16*C64X_IDCT_BUFFER_PITCH)
#define C64X_IDCT_BUFFER_V         (C64X_IDCT_BUFFER_U + 8)


/*  OBSOLETE
void c64x_dezigzag(u16*dst, u16*src);
*/
#define C64X_DEZIGZAG              _C64XFUNC(16)

/*  OBSOLETE
void c64x_dealternate(u16*dst, u16*src);
*/
#define C64X_DEALTERNATE           _C64XFUNC(17)

/*
void c64x_put_uyvy_16x16(u16*dst, u32 pitch, u8*src, u32 flags);
*/
#define C64X_PUT_UYVY_16x16        _C64XFUNC(18)

/*
void c64x_fetch_uyvy(u8 *dst, u8 *src, u32 spitch, u32 height);
*/
#define C64X_FETCH_UYVY            _C64XFUNC(19)

/*
void mc_put_o_8  (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
void mc_put_x_8  (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
void mc_put_y_8  (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
void mc_put_xy_8 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
*/
#define C64X_MC_PUT_8(avgX,avgY)   _C64XFUNC(32+(avgX)+(avgY)+(avgY))

/*
void mc_put_o_16 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
void mc_put_x_16 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
void mc_put_y_16 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
void mc_put_xy_16(u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height);
*/
#define C64X_MC_PUT_16(avgX,avgY)  _C64XFUNC(36+(avgX)+(avgY)+(avgY))

/*
void mc_avg_o_8  (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
void mc_avg_x_8  (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
void mc_avg_y_8  (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
void mc_avg_xy_8 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
*/
#define C64X_MC_AVG_8(avgX,avgY)   _C64XFUNC(40+(avgX)+(avgY)+(avgY))

/*
void mc_avg_o_16 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
void mc_avg_x_16 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
void mc_avg_y_16 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
void mc_avg_xy_16(u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height);
*/
#define C64X_MC_AVG_16(avgX,avgY)  _C64XFUNC(44+(avgX)+(avgY)+(avgY))


#endif