]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/DirectFB-1.7.7-add-missing-davinci-files.patch
Merge branch 'ipsec' into next
[ipfire-2.x.git] / src / patches / DirectFB-1.7.7-add-missing-davinci-files.patch
CommitLineData
5edc6b10
AF
1From: Sebastian Ramacher <sramacher@debian.org>
2Date: Thu, 16 Mar 2017 20:53:09 +0100
3Subject: Add missing files from upstream
4
5Closes: #598976
6---
7 gfxdrivers/davinci/davinci_c64x.h | 935 +++++++++++++++++++++++++++++++++
8 gfxdrivers/davinci/davinci_gfxdriver.h | 169 ++++++
9 gfxdrivers/davinci/davincifb.h | 581 ++++++++++++++++++++
10 3 files changed, 1685 insertions(+)
11 create mode 100644 gfxdrivers/davinci/davinci_c64x.h
12 create mode 100644 gfxdrivers/davinci/davinci_gfxdriver.h
13 create mode 100644 gfxdrivers/davinci/davincifb.h
14
15diff --git a/gfxdrivers/davinci/davinci_c64x.h b/gfxdrivers/davinci/davinci_c64x.h
16new file mode 100644
17index 0000000..682da22
18--- /dev/null
19+++ b/gfxdrivers/davinci/davinci_c64x.h
dff0a948
MT
20@@ -0,0 +1,935 @@
21+/*
22+ TI Davinci driver - C64X+ DSP Library
23+
24+ (c) Copyright 2008 directfb.org
25+ (c) Copyright 2007 Telio AG
26+
27+ Written by Denis Oliver Kropp <dok@directfb.org> and
28+ Olaf Dreesen <olaf@directfb.org>.
29+
30+ All rights reserved.
31+
32+ This library is free software; you can redistribute it and/or
33+ modify it under the terms of the GNU General Public License
34+ version 2 as published by the Free Software Foundation.
35+
36+ This library is distributed in the hope that it will be useful,
37+ but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39+ General Public License for more details.
40+
41+ You should have received a copy of the GNU General Public
42+ License along with this library; if not, write to the
43+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
44+ Boston, MA 02111-1307, USA.
45+*/
46+
47+#ifndef __DAVINCI_C64X_H__
48+#define __DAVINCI_C64X_H__
49+
50+#include <unistd.h>
51+
52+#include <directfb.h>
53+
54+#include <direct/messages.h>
55+#include <direct/trace.h>
56+
57+#include <linux/c64x.h>
58+
59+#define mb() __asm__ __volatile__ ("" : : : "memory")
60+
61+/**********************************************************************************************************************/
62+
63+typedef struct {
64+ int magic;
65+
66+ int fd;
67+ c64xTaskControl *ctl;
68+ void *mem;
69+
70+ c64xTask *QueueL;
71+} DavinciC64x;
72+
73+typedef struct {
74+ int magic;
75+ unsigned int max_tasks;
76+ unsigned int num_tasks;
77+ c64xTask *tasks;
78+} DavinciC64xTasks;
79+
80+typedef enum {
81+ C64X_TEF_NONE = 0x0000,
82+ C64X_TEF_RESET = 0x0001
83+} DavinciC64xEmitFlags;
84+
85+/**********************************************************************************************************************/
86+
87+DFBResult davinci_c64x_open ( DavinciC64x *c64x );
88+
89+DFBResult davinci_c64x_close ( DavinciC64x *c64x );
90+
91+DFBResult davinci_c64x_wait_low( DavinciC64x *c64x );
92+
93+/**********************************************************************************************************************/
94+
95+DFBResult davinci_c64x_tasks_init ( DavinciC64xTasks *tasks,
96+ unsigned int size );
97+
98+DFBResult davinci_c64x_tasks_destroy( DavinciC64xTasks *tasks );
99+
100+/**********************************************************************************************************************/
101+
102+DFBResult davinci_c64x_emit_tasks( DavinciC64x *c64x,
103+ DavinciC64xTasks *tasks,
104+ DavinciC64xEmitFlags flags );
105+
106+/**********************************************************************************************************************/
107+
108+static const char *state_names[] = { "DONE", "ERROR", "TODO", "RUNNING" };
109+
110+static inline c64xTask *
111+c64x_get_task( DavinciC64x *c64x )
112+{
113+ c64xTaskControl *ctl = c64x->ctl;
114+ uint32_t idx = ctl->QL_arm;
115+ uint32_t next = (idx + 1) & C64X_QUEUE_MASK;
116+ c64xTask *task = &c64x->QueueL[idx];
117+ int loops = 0;
118+ uint32_t idle = 0;
119+
120+ /* Wait for the entry (and next) to be processed by the DSP (rare case). */
121+ while (task->c64x_flags & C64X_FLAG_TODO || ctl->QL_dsp == next) {
122+ if (loops > 666 || (idle && ctl->idlecounter - idle > 666)) {
123+ c64xTask *dsp_task = &c64x->QueueL[ctl->QL_dsp];
124+
125+ D_PERROR( "Davinci/C64X+: Blocked! [DSP %d / %d (%s), ARM %d / %d (%s)]\n",
126+ ctl->QL_dsp,
127+ (dsp_task->c64x_function >> 2) & 0x3fff,
128+ state_names[dsp_task->c64x_function & 3],
129+ ctl->QL_arm,
130+ (task->c64x_function >> 2) & 0x3fff,
131+ state_names[task->c64x_function & 3] );
132+
133+ break;
134+ }
135+
136+ idle = ctl->idlecounter;
137+
138+ /* Queue is full, waiting 10-20ms should not be too bad. */
139+ if (loops++ > 10)
140+ usleep( 5000 );
141+ }
142+
143+ return task;
144+}
145+
146+static inline void
147+c64x_submit_task( DavinciC64x *c64x, c64xTask *task )
148+{
149+ c64xTaskControl *ctl = c64x->ctl;
150+ uint32_t idx = ctl->QL_arm;
151+ uint32_t next = (idx + 1) & C64X_QUEUE_MASK;
152+
153+ mb();
154+
155+ ctl->QL_arm = next;
156+
157+ mb();
158+}
159+
160+/**********************************************************************************************************************/
161+
162+static inline void
163+davinci_c64x_wb_inv_range( DavinciC64x *c64x,
164+ unsigned long start,
165+ u32 length,
166+ u32 func )
167+{
168+ c64xTask *task = c64x_get_task( c64x );
169+
170+ task->c64x_arg[0] = start;
171+ task->c64x_arg[1] = length;
172+ task->c64x_arg[2] = func;
173+
174+ task->c64x_function = C64X_WB_INV_RANGE | C64X_FLAG_TODO;
175+
176+ c64x_submit_task( c64x, task );
177+}
178+
179+static inline void
180+davinci_c64x_write_back_all( DavinciC64x *c64x )
181+{
182+ c64xTask *task = c64x_get_task( c64x );
183+
184+ task->c64x_function = C64X_WRITE_BACK_ALL | C64X_FLAG_TODO;
185+
186+ c64x_submit_task( c64x, task );
187+}
188+
189+/**********************************************************************************************************************/
190+
191+static inline void
192+davinci_c64x_load_block__L( DavinciC64xTasks *tasks,
193+ unsigned long words,
194+ u32 num,
195+ u32 flags )
196+{
197+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
198+
199+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
200+
201+ task->c64x_arg[0] = words;
202+ task->c64x_arg[1] = num;
203+ task->c64x_arg[2] = flags;
204+
205+ task->c64x_function = C64X_LOAD_BLOCK | C64X_FLAG_TODO;
206+
207+ tasks->num_tasks++;
208+}
209+
210+static inline void
211+davinci_c64x_load_block( DavinciC64x *c64x,
212+ unsigned long words,
213+ u32 num,
214+ u32 flags )
215+{
216+ c64xTask *task = c64x_get_task( c64x );
217+
218+ task->c64x_arg[0] = words;
219+ task->c64x_arg[1] = num;
220+ task->c64x_arg[2] = flags;
221+
222+ task->c64x_function = C64X_LOAD_BLOCK | C64X_FLAG_TODO;
223+
224+ c64x_submit_task( c64x, task );
225+}
226+
227+static inline void
228+davinci_c64x_fetch_uyvy( DavinciC64x *c64x,
229+ unsigned long dest,
230+ unsigned long source,
231+ u32 pitch,
232+ u32 height,
233+ u32 flags )
234+{
235+ c64xTask *task = c64x_get_task( c64x );
236+
237+ task->c64x_arg[0] = dest;
238+ task->c64x_arg[1] = source;
239+ task->c64x_arg[2] = pitch;
240+ task->c64x_arg[3] = height;
241+ task->c64x_arg[4] = flags;
242+
243+ task->c64x_function = C64X_FETCH_UYVY | C64X_FLAG_TODO;
244+
245+ c64x_submit_task( c64x, task );
246+}
247+
248+static inline void
249+davinci_c64x_mc( DavinciC64x *c64x,
250+ unsigned long dest,
251+ u32 dpitch,
252+ unsigned long source0,
253+ unsigned long source1,
254+ u32 spitch,
255+ u32 height,
256+ int func )
257+{
258+ c64xTask *task = c64x_get_task( c64x );
259+
260+ task->c64x_arg[0] = dest;
261+ task->c64x_arg[1] = dpitch;
262+ task->c64x_arg[2] = source0;
263+ task->c64x_arg[3] = source1;
264+ task->c64x_arg[4] = spitch;
265+ task->c64x_arg[5] = height;
266+
267+ task->c64x_function = func | C64X_FLAG_TODO;
268+
269+ c64x_submit_task( c64x, task );
270+}
271+
272+static inline void
273+davinci_c64x_put_idct_uyvy_16x16__L( DavinciC64xTasks *tasks,
274+ unsigned long dest,
275+ u32 pitch,
276+ u32 flags )
277+{
278+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
279+
280+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
281+
282+ task->c64x_arg[0] = dest;
283+ task->c64x_arg[1] = pitch;
284+ task->c64x_arg[2] = flags;
285+
286+ task->c64x_function = C64X_PUT_IDCT_UYVY_16x16 | C64X_FLAG_TODO;
287+
288+ tasks->num_tasks++;
289+}
290+
291+static inline void
292+davinci_c64x_put_idct_uyvy_16x16( DavinciC64x *c64x,
293+ unsigned long dest,
294+ u32 pitch,
295+ u32 flags )
296+{
297+ c64xTask *task = c64x_get_task( c64x );
298+
299+ task->c64x_arg[0] = dest;
300+ task->c64x_arg[1] = pitch;
301+ task->c64x_arg[2] = flags;
302+
303+ task->c64x_function = C64X_PUT_IDCT_UYVY_16x16 | C64X_FLAG_TODO;
304+
305+ c64x_submit_task( c64x, task );
306+}
307+
308+static inline void
309+davinci_c64x_put_mc_uyvy_16x16__L( DavinciC64xTasks *tasks,
310+ unsigned long dest,
311+ u32 pitch,
312+ u32 flags )
313+{
314+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
315+
316+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
317+
318+ task->c64x_arg[0] = dest;
319+ task->c64x_arg[1] = pitch;
320+ task->c64x_arg[2] = flags;
321+
322+ task->c64x_function = C64X_PUT_MC_UYVY_16x16 | C64X_FLAG_TODO;
323+
324+ tasks->num_tasks++;
325+}
326+
327+static inline void
328+davinci_c64x_put_mc_uyvy_16x16( DavinciC64x *c64x,
329+ unsigned long dest,
330+ u32 pitch,
331+ u32 flags )
332+{
333+ c64xTask *task = c64x_get_task( c64x );
334+
335+ task->c64x_arg[0] = dest;
336+ task->c64x_arg[1] = pitch;
337+ task->c64x_arg[2] = flags;
338+
339+ task->c64x_function = C64X_PUT_MC_UYVY_16x16 | C64X_FLAG_TODO;
340+
341+ c64x_submit_task( c64x, task );
342+}
343+
344+static inline void
345+davinci_c64x_put_sum_uyvy_16x16__L( DavinciC64xTasks *tasks,
346+ unsigned long dest,
347+ u32 pitch,
348+ u32 flags )
349+{
350+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
351+
352+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
353+
354+ task->c64x_arg[0] = dest;
355+ task->c64x_arg[1] = pitch;
356+ task->c64x_arg[2] = flags;
357+
358+ task->c64x_function = C64X_PUT_SUM_UYVY_16x16 | C64X_FLAG_TODO;
359+
360+ tasks->num_tasks++;
361+}
362+
363+static inline void
364+davinci_c64x_put_sum_uyvy_16x16( DavinciC64x *c64x,
365+ unsigned long dest,
366+ u32 pitch,
367+ u32 flags )
368+{
369+ c64xTask *task = c64x_get_task( c64x );
370+
371+ task->c64x_arg[0] = dest;
372+ task->c64x_arg[1] = pitch;
373+ task->c64x_arg[2] = flags;
374+
375+ task->c64x_function = C64X_PUT_SUM_UYVY_16x16 | C64X_FLAG_TODO;
376+
377+ c64x_submit_task( c64x, task );
378+}
379+
380+static inline void
381+davinci_c64x_dva_begin_frame__L( DavinciC64xTasks *tasks,
382+ u32 pitch,
383+ unsigned long current,
384+ unsigned long past,
385+ unsigned long future,
386+ u32 flags )
387+{
388+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
389+
390+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
391+
392+ task->c64x_arg[0] = pitch;
393+ task->c64x_arg[1] = current;
394+ task->c64x_arg[2] = past;
395+ task->c64x_arg[3] = future;
396+ task->c64x_arg[4] = flags;
397+
398+ task->c64x_function = C64X_DVA_BEGIN_FRAME | C64X_FLAG_TODO;
399+
400+ tasks->num_tasks++;
401+}
402+
403+static inline void
404+davinci_c64x_dva_begin_frame( DavinciC64x *c64x,
405+ u32 pitch,
406+ unsigned long current,
407+ unsigned long past,
408+ unsigned long future,
409+ u32 flags )
410+{
411+ c64xTask *task = c64x_get_task( c64x );
412+
413+ task->c64x_arg[0] = pitch;
414+ task->c64x_arg[1] = current;
415+ task->c64x_arg[2] = past;
416+ task->c64x_arg[3] = future;
417+ task->c64x_arg[4] = flags;
418+
419+ task->c64x_function = C64X_DVA_BEGIN_FRAME | C64X_FLAG_TODO;
420+
421+ c64x_submit_task( c64x, task );
422+}
423+
424+static inline void
425+davinci_c64x_dva_motion_block__L( DavinciC64xTasks *tasks,
426+ unsigned long macroblock )
427+{
428+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
429+
430+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
431+
432+ task->c64x_arg[0] = macroblock;
433+
434+ task->c64x_function = C64X_DVA_MOTION_BLOCK | C64X_FLAG_TODO;
435+
436+ tasks->num_tasks++;
437+}
438+
439+static inline void
440+davinci_c64x_dva_motion_block( DavinciC64x *c64x,
441+ unsigned long macroblock )
442+{
443+ c64xTask *task = c64x_get_task( c64x );
444+
445+ task->c64x_arg[0] = macroblock;
446+
447+ task->c64x_function = C64X_DVA_MOTION_BLOCK | C64X_FLAG_TODO;
448+
449+ c64x_submit_task( c64x, task );
450+}
451+
452+/**********************************************************************************************************************/
453+
454+static inline void
455+davinci_c64x_dva_idct( DavinciC64x *c64x,
456+ unsigned long dest,
457+ u32 pitch,
458+ unsigned long source )
459+{
460+ c64xTask *task = c64x_get_task( c64x );
461+
462+ task->c64x_arg[0] = dest;
463+ task->c64x_arg[1] = pitch;
464+ task->c64x_arg[2] = source;
465+
466+ task->c64x_function = C64X_DVA_IDCT | C64X_FLAG_TODO;
467+
468+ c64x_submit_task( c64x, task );
469+}
470+
471+/**********************************************************************************************************************/
472+
473+static inline void
474+davinci_c64x_put_uyvy_16x16( DavinciC64x *c64x,
475+ unsigned long dest,
476+ u32 pitch,
477+ unsigned long source,
478+ u32 flags )
479+{
480+ c64xTask *task = c64x_get_task( c64x );
481+
482+ task->c64x_arg[0] = dest;
483+ task->c64x_arg[1] = pitch;
484+ task->c64x_arg[2] = source;
485+ task->c64x_arg[3] = flags;
486+
487+ task->c64x_function = C64X_PUT_UYVY_16x16 | C64X_FLAG_TODO;
488+
489+ c64x_submit_task( c64x, task );
490+}
491+
492+static inline void
493+davinci_c64x_dither_argb__L( DavinciC64xTasks *tasks,
494+ unsigned long dst_rgb,
495+ unsigned long dst_alpha,
496+ u32 dst_pitch,
497+ unsigned long source,
498+ u32 src_pitch,
499+ u32 width,
500+ u32 height )
501+{
502+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
503+
504+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
505+
506+ task->c64x_arg[0] = dst_rgb;
507+ task->c64x_arg[1] = dst_alpha;
508+ task->c64x_arg[2] = dst_pitch;
509+ task->c64x_arg[3] = source;
510+ task->c64x_arg[4] = src_pitch;
511+ task->c64x_arg[5] = width;
512+ task->c64x_arg[6] = height;
513+
514+ task->c64x_function = C64X_DITHER_ARGB | C64X_FLAG_TODO;
515+
516+ tasks->num_tasks++;
517+}
518+
519+static inline void
520+davinci_c64x_dither_argb( DavinciC64x *c64x,
521+ unsigned long dst_rgb,
522+ unsigned long dst_alpha,
523+ u32 dst_pitch,
524+ unsigned long source,
525+ u32 src_pitch,
526+ u32 width,
527+ u32 height )
528+{
529+ c64xTask *task = c64x_get_task( c64x );
530+
531+ task->c64x_arg[0] = dst_rgb;
532+ task->c64x_arg[1] = dst_alpha;
533+ task->c64x_arg[2] = dst_pitch;
534+ task->c64x_arg[3] = source;
535+ task->c64x_arg[4] = src_pitch;
536+ task->c64x_arg[5] = width;
537+ task->c64x_arg[6] = height;
538+
539+ task->c64x_function = C64X_DITHER_ARGB | C64X_FLAG_TODO;
540+
541+ c64x_submit_task( c64x, task );
542+}
543+
544+static inline void
545+davinci_c64x_fill_16__L( DavinciC64xTasks *tasks,
546+ unsigned long dest,
547+ u32 pitch,
548+ u32 width,
549+ u32 height,
550+ u32 value )
551+{
552+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
553+
554+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
555+
556+ task->c64x_arg[0] = dest;
557+ task->c64x_arg[1] = pitch;
558+ task->c64x_arg[2] = width;
559+ task->c64x_arg[3] = height;
560+ task->c64x_arg[4] = value;
561+
562+ task->c64x_function = C64X_FILL_16 | C64X_FLAG_TODO;
563+
564+ tasks->num_tasks++;
565+}
566+
567+static inline void
568+davinci_c64x_fill_16( DavinciC64x *c64x,
569+ unsigned long dest,
570+ u32 pitch,
571+ u32 width,
572+ u32 height,
573+ u32 value )
574+{
575+ c64xTask *task = c64x_get_task( c64x );
576+
577+ task->c64x_arg[0] = dest;
578+ task->c64x_arg[1] = pitch;
579+ task->c64x_arg[2] = width;
580+ task->c64x_arg[3] = height;
581+ task->c64x_arg[4] = value;
582+
583+ task->c64x_function = C64X_FILL_16 | C64X_FLAG_TODO;
584+
585+ c64x_submit_task( c64x, task );
586+}
587+
588+static inline void
589+davinci_c64x_fill_32__L( DavinciC64xTasks *tasks,
590+ unsigned long dest,
591+ u32 pitch,
592+ u32 width,
593+ u32 height,
594+ u32 value )
595+{
596+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
597+
598+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
599+
600+ task->c64x_arg[0] = dest;
601+ task->c64x_arg[1] = pitch;
602+ task->c64x_arg[2] = width;
603+ task->c64x_arg[3] = height;
604+ task->c64x_arg[4] = value;
605+
606+ task->c64x_function = C64X_FILL_32 | C64X_FLAG_TODO;
607+
608+ tasks->num_tasks++;
609+}
610+
611+static inline void
612+davinci_c64x_fill_32( DavinciC64x *c64x,
613+ unsigned long dest,
614+ u32 pitch,
615+ u32 width,
616+ u32 height,
617+ u32 value )
618+{
619+ c64xTask *task = c64x_get_task( c64x );
620+
621+ task->c64x_arg[0] = dest;
622+ task->c64x_arg[1] = pitch;
623+ task->c64x_arg[2] = width;
624+ task->c64x_arg[3] = height;
625+ task->c64x_arg[4] = value;
626+
627+ task->c64x_function = C64X_FILL_32 | C64X_FLAG_TODO;
628+
629+ c64x_submit_task( c64x, task );
630+}
631+
632+static inline void
633+davinci_c64x_blit_16__L( DavinciC64xTasks *tasks,
634+ unsigned long dest,
635+ u32 dpitch,
636+ unsigned long src,
637+ u32 spitch,
638+ u32 width,
639+ u32 height )
640+{
641+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
642+
643+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
644+
645+ task->c64x_arg[0] = dest;
646+ task->c64x_arg[1] = dpitch;
647+ task->c64x_arg[2] = src;
648+ task->c64x_arg[3] = spitch;
649+ task->c64x_arg[4] = width;
650+ task->c64x_arg[5] = height;
651+
652+ task->c64x_function = C64X_COPY_16 | C64X_FLAG_TODO;
653+
654+ tasks->num_tasks++;
655+}
656+
657+static inline void
658+davinci_c64x_blit_16( DavinciC64x *c64x,
659+ unsigned long dest,
660+ u32 dpitch,
661+ unsigned long src,
662+ u32 spitch,
663+ u32 width,
664+ u32 height )
665+{
666+ c64xTask *task = c64x_get_task( c64x );
667+
668+ task->c64x_arg[0] = dest;
669+ task->c64x_arg[1] = dpitch;
670+ task->c64x_arg[2] = src;
671+ task->c64x_arg[3] = spitch;
672+ task->c64x_arg[4] = width;
673+ task->c64x_arg[5] = height;
674+
675+ task->c64x_function = C64X_COPY_16 | C64X_FLAG_TODO;
676+
677+ c64x_submit_task( c64x, task );
678+}
679+
680+static inline void
681+davinci_c64x_blit_32__L( DavinciC64xTasks *tasks,
682+ unsigned long dest,
683+ u32 dpitch,
684+ unsigned long src,
685+ u32 spitch,
686+ u32 width,
687+ u32 height )
688+{
689+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
690+
691+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
692+
693+ task->c64x_arg[0] = dest;
694+ task->c64x_arg[1] = dpitch;
695+ task->c64x_arg[2] = src;
696+ task->c64x_arg[3] = spitch;
697+ task->c64x_arg[4] = width;
698+ task->c64x_arg[5] = height;
699+
700+ task->c64x_function = C64X_COPY_32 | C64X_FLAG_TODO;
701+
702+ tasks->num_tasks++;
703+}
704+
705+static inline void
706+davinci_c64x_blit_32( DavinciC64x *c64x,
707+ unsigned long dest,
708+ u32 dpitch,
709+ unsigned long src,
710+ u32 spitch,
711+ u32 width,
712+ u32 height )
713+{
714+ c64xTask *task = c64x_get_task( c64x );
715+
716+ task->c64x_arg[0] = dest;
717+ task->c64x_arg[1] = dpitch;
718+ task->c64x_arg[2] = src;
719+ task->c64x_arg[3] = spitch;
720+ task->c64x_arg[4] = width;
721+ task->c64x_arg[5] = height;
722+
723+ task->c64x_function = C64X_COPY_32 | C64X_FLAG_TODO;
724+
725+ c64x_submit_task( c64x, task );
726+}
727+
728+static inline void
729+davinci_c64x_stretch_32__L( DavinciC64xTasks *tasks,
730+ unsigned long dest,
731+ u32 dpitch,
732+ unsigned long src,
733+ u32 spitch,
734+ u32 dw,
735+ u32 dh,
736+ u32 sw,
737+ u32 sh,
738+ const DFBRegion *clip )
739+{
740+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
741+
742+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
743+
744+ task->c64x_arg[0] = dest;
745+ task->c64x_arg[1] = src;
746+ task->c64x_arg[2] = dpitch | (spitch << 16);
747+ task->c64x_arg[3] = dh | (dw << 16);
748+ task->c64x_arg[4] = sh | (sw << 16);
749+ task->c64x_arg[5] = clip->x2 | (clip->y2 << 16);
750+ task->c64x_arg[6] = clip->x1 | (clip->y1 << 16);
751+
752+ if (sw > dw && sh > dh)
753+ task->c64x_function = C64X_STRETCH_32_down | C64X_FLAG_TODO;
754+ else
755+ task->c64x_function = C64X_STRETCH_32_up | C64X_FLAG_TODO;
756+
757+ tasks->num_tasks++;
758+}
759+
760+static inline void
761+davinci_c64x_stretch_32( DavinciC64x *c64x,
762+ unsigned long dest,
763+ u32 dpitch,
764+ unsigned long src,
765+ u32 spitch,
766+ u32 dw,
767+ u32 dh,
768+ u32 sw,
769+ u32 sh,
770+ const DFBRegion *clip )
771+{
772+ c64xTask *task = c64x_get_task( c64x );
773+
774+ task->c64x_arg[0] = dest;
775+ task->c64x_arg[1] = src;
776+ task->c64x_arg[2] = dpitch | (spitch << 16);
777+ task->c64x_arg[3] = dh | (dw << 16);
778+ task->c64x_arg[4] = sh | (sw << 16);
779+ task->c64x_arg[5] = clip->x2 | (clip->y2 << 16);
780+ task->c64x_arg[6] = clip->x1 | (clip->y1 << 16);
781+
782+ if (sw > dw && sh > dh)
783+ task->c64x_function = C64X_STRETCH_32_down | C64X_FLAG_TODO;
784+ else
785+ task->c64x_function = C64X_STRETCH_32_up | C64X_FLAG_TODO;
786+
787+ c64x_submit_task( c64x, task );
788+}
789+
790+static inline void
791+davinci_c64x_blit_blend_32__L( DavinciC64xTasks *tasks,
792+ u32 sub_func,
793+ unsigned long dest,
794+ u32 dpitch,
795+ unsigned long src,
796+ u32 spitch,
797+ u32 width,
798+ u32 height,
799+ u32 argb,
800+ u8 alpha )
801+{
802+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
803+
804+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
805+
806+ task->c64x_arg[0] = dest;
807+ task->c64x_arg[1] = dpitch;
808+ task->c64x_arg[2] = src;
809+ task->c64x_arg[3] = spitch;
810+ task->c64x_arg[4] = width | (height << 16);
811+ task->c64x_arg[5] = argb;
812+ task->c64x_arg[6] = alpha;
813+
814+ task->c64x_function = (sub_func << 16) | C64X_BLEND_32 | C64X_FLAG_TODO;
815+
816+ tasks->num_tasks++;
817+}
818+
819+static inline void
820+davinci_c64x_blit_blend_32( DavinciC64x *c64x,
821+ u32 sub_func,
822+ unsigned long dest,
823+ u32 dpitch,
824+ unsigned long src,
825+ u32 spitch,
826+ u32 width,
827+ u32 height,
828+ u32 argb,
829+ u8 alpha )
830+{
831+ c64xTask *task = c64x_get_task( c64x );
832+
833+ task->c64x_arg[0] = dest;
834+ task->c64x_arg[1] = dpitch;
835+ task->c64x_arg[2] = src;
836+ task->c64x_arg[3] = spitch;
837+ task->c64x_arg[4] = width | (height << 16);
838+ task->c64x_arg[5] = argb;
839+ task->c64x_arg[6] = alpha;
840+
841+ task->c64x_function = (sub_func << 16) | C64X_BLEND_32 | C64X_FLAG_TODO;
842+
843+ c64x_submit_task( c64x, task );
844+}
845+
846+static inline void
847+davinci_c64x_blit_keyed_16__L( DavinciC64xTasks *tasks,
848+ unsigned long dest,
849+ u32 dpitch,
850+ unsigned long src,
851+ u32 spitch,
852+ u32 width,
853+ u32 height,
854+ u32 key,
855+ u32 mask )
856+{
857+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
858+
859+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
860+
861+ task->c64x_arg[0] = dest;
862+ task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff);
863+ task->c64x_arg[2] = src;
864+ task->c64x_arg[3] = width;
865+ task->c64x_arg[4] = height;
866+ task->c64x_arg[5] = key;
867+ task->c64x_arg[6] = mask;
868+
869+ task->c64x_function = C64X_COPY_KEYED_16 | C64X_FLAG_TODO;
870+
871+ tasks->num_tasks++;
872+}
873+
874+static inline void
875+davinci_c64x_blit_keyed_16( DavinciC64x *c64x,
876+ unsigned long dest,
877+ u32 dpitch,
878+ unsigned long src,
879+ u32 spitch,
880+ u32 width,
881+ u32 height,
882+ u32 key,
883+ u32 mask )
884+{
885+ c64xTask *task = c64x_get_task( c64x );
886+
887+ task->c64x_arg[0] = dest;
888+ task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff);
889+ task->c64x_arg[2] = src;
890+ task->c64x_arg[3] = width;
891+ task->c64x_arg[4] = height;
892+ task->c64x_arg[5] = key;
893+ task->c64x_arg[6] = mask;
894+
895+ task->c64x_function = C64X_COPY_KEYED_16 | C64X_FLAG_TODO;
896+
897+ c64x_submit_task( c64x, task );
898+}
899+
900+static inline void
901+davinci_c64x_blit_keyed_32__L( DavinciC64xTasks *tasks,
902+ unsigned long dest,
903+ u32 dpitch,
904+ unsigned long src,
905+ u32 spitch,
906+ u32 width,
907+ u32 height,
908+ u32 key,
909+ u32 mask )
910+{
911+ c64xTask *task = &tasks->tasks[tasks->num_tasks];
912+
913+ D_ASSERT( tasks->num_tasks < tasks->max_tasks );
914+
915+ task->c64x_arg[0] = dest;
916+ task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff);
917+ task->c64x_arg[2] = src;
918+ task->c64x_arg[3] = width;
919+ task->c64x_arg[4] = height;
920+ task->c64x_arg[5] = key;
921+ task->c64x_arg[6] = mask;
922+
923+ task->c64x_function = C64X_COPY_KEYED_32 | C64X_FLAG_TODO;
924+
925+ tasks->num_tasks++;
926+}
927+
928+static inline void
929+davinci_c64x_blit_keyed_32( DavinciC64x *c64x,
930+ unsigned long dest,
931+ u32 dpitch,
932+ unsigned long src,
933+ u32 spitch,
934+ u32 width,
935+ u32 height,
936+ u32 key,
937+ u32 mask )
938+{
939+ c64xTask *task = c64x_get_task( c64x );
940+
941+ task->c64x_arg[0] = dest;
942+ task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff);
943+ task->c64x_arg[2] = src;
944+ task->c64x_arg[3] = width;
945+ task->c64x_arg[4] = height;
946+ task->c64x_arg[5] = key;
947+ task->c64x_arg[6] = mask;
948+
949+ task->c64x_function = C64X_COPY_KEYED_32 | C64X_FLAG_TODO;
950+
951+ c64x_submit_task( c64x, task );
952+}
953+
954+#endif
955+
5edc6b10
AF
956diff --git a/gfxdrivers/davinci/davinci_gfxdriver.h b/gfxdrivers/davinci/davinci_gfxdriver.h
957new file mode 100644
958index 0000000..4ca79b3
959--- /dev/null
960+++ b/gfxdrivers/davinci/davinci_gfxdriver.h
961@@ -0,0 +1,169 @@
962+/*
963+ TI Davinci driver - Graphics Driver
964+
965+ (c) Copyright 2007 Telio AG
966+
967+ Written by Denis Oliver Kropp <dok@directfb.org>
968+
969+ Code is derived from VMWare driver.
970+
971+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
972+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
973+
974+ All rights reserved.
975+
976+ This library is free software; you can redistribute it and/or
977+ modify it under the terms of the GNU Lesser General Public
978+ License as published by the Free Software Foundation; either
979+ version 2 of the License, or (at your option) any later version.
980+
981+ This library is distributed in the hope that it will be useful,
982+ but WITHOUT ANY WARRANTY; without even the implied warranty of
983+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
984+ Lesser General Public License for more details.
985+
986+ You should have received a copy of the GNU Lesser General Public
987+ License along with this library; if not, write to the
988+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
989+ Boston, MA 02111-1307, USA.
990+*/
991+
992+#ifndef __DAVINCI_GFXDRIVER_H__
993+#define __DAVINCI_GFXDRIVER_H__
994+
995+#include <sys/ioctl.h>
996+#include <davincifb.h>
997+
998+#include <core/surface_buffer.h>
999+
1000+#include "davincifb.h"
1001+
1002+#include "davinci_c64x.h"
1003+
1004+
1005+typedef struct {
1006+ /* validation flags */
1007+ int v_flags;
1008+
1009+ /* cached/computed values */
1010+ void *dst_addr;
1011+ unsigned long dst_phys;
1012+ unsigned int dst_size;
1013+ unsigned long dst_pitch;
1014+ DFBSurfacePixelFormat dst_format;
1015+ unsigned long dst_bpp;
1016+
1017+ void *src_addr;
1018+ unsigned long src_phys;
1019+ unsigned long src_pitch;
1020+ DFBSurfacePixelFormat src_format;
1021+ unsigned long src_bpp;
1022+
1023+ unsigned long source_mult;
1024+
1025+ unsigned long fillcolor;
1026+
1027+ int blit_blend_sub_function;
1028+ int draw_blend_sub_function;
1029+
1030+ DFBColor color;
1031+ unsigned long color_argb;
1032+ unsigned long colorkey;
1033+
1034+ DFBSurfaceBlittingFlags blitting_flags;
1035+
1036+ DFBRegion clip;
1037+
1038+ /** Add shared data here... **/
1039+ struct fb_fix_screeninfo fix[4];
1040+
1041+ CoreSurfacePool *osd_pool;
1042+ CoreSurfacePool *video_pool;
1043+
1044+ bool synced;
1045+} DavinciDeviceData;
1046+
1047+
1048+typedef struct {
1049+ int num;
1050+ int fd;
1051+ void *mem;
1052+ int size;
1053+} DavinciFB;
1054+
1055+typedef struct {
1056+ DavinciDeviceData *ddev;
1057+
1058+ CoreDFB *core;
1059+
1060+ CoreScreen *screen;
1061+ CoreLayer *osd;
1062+ CoreLayer *video;
1063+
1064+ DavinciFB fb[4];
1065+
1066+ DavinciC64x c64x;
1067+ bool c64x_present;
1068+
1069+ DavinciC64xTasks tasks;
1070+} DavinciDriverData;
1071+
1072+
1073+static inline DFBResult
1074+davincifb_pan_display( const DavinciFB *fb,
1075+ struct fb_var_screeninfo *var,
1076+ const CoreSurfaceBufferLock *lock,
1077+ DFBSurfaceFlipFlags flags,
1078+ int x,
1079+ int y )
1080+{
1081+ int ret;
1082+
1083+ if (lock) {
1084+#ifdef FBIO_SET_START
1085+ CoreSurfaceBuffer *buffer = lock->buffer;
1086+ struct fb_set_start set_start;
1087+
1088+ /* physical mode */
1089+ set_start.offset = -1;
1090+ set_start.sync = (flags & DSFLIP_ONSYNC) ? 1 : 0;
1091+
1092+ /* life's so easy */
1093+ set_start.physical = lock->phys + DFB_BYTES_PER_LINE( buffer->format, x ) + y * lock->pitch;
1094+
1095+ ret = ioctl( fb->fd, FBIO_SET_START, &set_start );
1096+ if (ret < 0)
1097+ D_DEBUG( "FBIO_SET_START (0x%08lx, sync %llu) failed!\n",
1098+ set_start.physical, set_start.sync );
1099+
1100+ if (ret == 0) {
1101+ if (flags & DSFLIP_WAIT)
1102+ ioctl( fb->fd, FBIO_WAITFORVSYNC );
1103+
1104+ return DFB_OK;
1105+ }
1106+
1107+ /* fallback */
1108+#endif
1109+ var->xoffset = x; /* poor version */
1110+ var->yoffset = y + lock->offset / lock->pitch;
1111+ }
1112+ else {
1113+ var->xoffset = x;
1114+ var->yoffset = y;
1115+ }
1116+
1117+ var->activate = /*(flags & DSFLIP_ONSYNC) ? FB_ACTIVATE_VBL :*/ FB_ACTIVATE_NOW;
1118+
1119+ ret = ioctl( fb->fd, FBIOPAN_DISPLAY, var );
1120+ if (ret)
1121+ D_PERROR( "Davinci/FB: FBIOPAN_DISPLAY (fb%d - %d,%d) failed!\n",
1122+ fb->num, var->xoffset, var->yoffset );
1123+
1124+ if (flags & DSFLIP_WAIT)
1125+ ioctl( fb->fd, FBIO_WAITFORVSYNC );
1126+
1127+ return DFB_OK;
1128+}
1129+
1130+#endif
1131diff --git a/gfxdrivers/davinci/davincifb.h b/gfxdrivers/davinci/davincifb.h
1132new file mode 100644
1133index 0000000..35eb169
1134--- /dev/null
1135+++ b/gfxdrivers/davinci/davincifb.h
dff0a948
MT
1136@@ -0,0 +1,581 @@
1137+/*
1138+ * Copyright (C) 2006 Texas Instruments Inc
1139+ *
1140+ * This program is free software; you can redistribute it and/or modify
1141+ * it under the terms of the GNU General Public License as published by
1142+ * the Free Software Foundation; either version 2 of the License, or
1143+ * (at your option)any later version.
1144+ *
1145+ * This program is distributed in the hope that it will be useful,
1146+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1147+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1148+ * GNU General Public License for more details.
1149+ *
1150+ * You should have received a copy of the GNU General Public License
1151+ * along with this program; if not, write to the Free Software
1152+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1153+ *
1154+ * File: davincifb.h
1155+ */
1156+
1157+#ifndef DAVINVI_VPBE_H
1158+#define DAVINVI_VPBE_H
1159+
1160+/* include Linux files */
1161+#include <linux/fb.h>
1162+
1163+/* define the custom FBIO_WAITFORVSYNC ioctl */
1164+#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
1165+#define FBIO_SETATTRIBUTE _IOW('F', 0x21, struct fb_fillrect)
1166+
1167+/* Backported IOCTLS. */
1168+#define FBIO_SETPOSX _IOW('F', 0x22, u_int32_t)
1169+#define FBIO_SETPOSY _IOW('F', 0x23, u_int32_t)
1170+#define FBIO_SETZOOM _IOW('F', 0x24, struct zoom_params)
1171+#define FBIO_GETSTD _IOR('F', 0x25, u_int32_t)
1172+#define FBIO_RESIZER _IOW('F', 0x26, struct vpfe_resizer_params)
1173+#define FBIO_SYNC _IOW('F', 0x27, u_int32_t)
1174+
1175+typedef struct zoom_params {
1176+ u_int32_t window_id;
1177+ u_int32_t zoom_h;
1178+ u_int32_t zoom_v;
1179+} zoom_params_t;
1180+
1181+typedef struct vpfe_resizer_params
1182+{
1183+ u_int32_t rsz_cnt; //busy-lock
1184+ u_int32_t out_size; //busy-lock
1185+ u_int32_t in_start; //busy-lock
1186+ u_int32_t in_size; //busy-lock
1187+ u_int32_t sdr_inadd; //shadowed
1188+ u_int32_t sdr_inoff; //shadowed
1189+ u_int32_t sdr_outadd; //shadowed
1190+ u_int32_t sdr_outoff; //shadowed
1191+ u_int32_t hfilt[16]; //busy-lock
1192+ u_int32_t vfilt[16]; //busy-lock
1193+ u_int32_t yenh; //busy-lock
1194+} vpfe_resizer_params_t;
1195+
1196+typedef struct fb_set_start {
1197+ int offset; /* offset from smem_start */
1198+ unsigned long physical; /* absolute physical address when offset < 0 */
1199+
1200+ u_int64_t sync; /* input: target sync counter for change or 0 for no sync at all,
1201+ output: sync counter of actual change or 0 if still pending */
1202+} fb_set_start_t;
1203+
1204+
1205+#ifdef _IOC_TYPECHECK
1206+#undef _IOC_TYPECHECK
1207+#define _IOC_TYPECHECK(x) (sizeof(x))
1208+#endif
1209+
1210+#define RAM_CLUT_SIZE 256*3
1211+#define FBIO_ENABLE_DISABLE_WIN \
1212+ _IOW('F', 0x30, unsigned char)
1213+#define FBIO_SET_BITMAP_BLEND_FACTOR \
1214+ _IOW('F', 0x31, vpbe_bitmap_blend_params_t)
1215+#define FBIO_SET_BITMAP_WIN_RAM_CLUT \
1216+ _IOW('F', 0x32, unsigned char)*RAM_CLUT_SIZE)
1217+#define FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN \
1218+ _IOW('F', 0x33, unsigned int)
1219+#define FBIO_GET_BLINK_INTERVAL \
1220+ _IOR('F', 0x34, vpbe_blink_option_t)
1221+#define FBIO_SET_BLINK_INTERVAL \
1222+ _IOW('F', 0x35, vpbe_blink_option_t)
1223+#define FBIO_GET_VIDEO_CONFIG_PARAMS \
1224+ _IOR('F', 0x36, vpbe_video_config_params_t)
1225+#define FBIO_SET_VIDEO_CONFIG_PARAMS \
1226+ _IOW('F', 0x37, vpbe_video_config_params_t)
1227+#define FBIO_GET_BITMAP_CONFIG_PARAMS \
1228+ _IOR('F', 0x38, vpbe_bitmap_config_params_t)
1229+#define FBIO_SET_BITMAP_CONFIG_PARAMS \
1230+ _IOW('F', 0x39, vpbe_bitmap_config_params_t)
1231+#define FBIO_SET_DCLK \
1232+ _IOW('F', 0x40, vpbe_dclk_t)
1233+#define FBIO_SET_INTERFACE \
1234+ _IOW('F', 0x41, unsigned char)
1235+#define FBIO_GET_INTERFACE \
1236+ _IOR('F', 0x42, unsigned char)
1237+#define FBIO_QUERY_TIMING \
1238+ _IOWR('F', 0x43, struct vpbe_mode_info)
1239+#define FBIO_SET_TIMING \
1240+ _IOW('F', 0x44, struct vpbe_fb_videomode)
1241+#define FBIO_GET_TIMING \
1242+ _IOR('F', 0x45, struct vpbe_fb_videomode)
1243+#define FBIO_SET_VENC_CLK_SOURCE \
1244+ _IOW('F', 0x46, unsigned char)
1245+#define FBIO_SET_BACKG_COLOR \
1246+ _IOW('F', 0x47, vpbe_backg_color_t)
1247+#define FBIO_ENABLE_DISPLAY \
1248+ _IOW('F', 0x48, unsigned char)
1249+#define FBIO_SETPOS \
1250+ _IOW('F', 0x49, u_int32_t)
1251+#define FBIO_SET_CURSOR \
1252+ _IOW('F', 0x50, struct fb_cursor)
1253+#define FBIO_SET_START \
1254+ _IOW('F', 0x66, struct fb_set_start)
1255+
1256+/*
1257+ * Defines and Constants
1258+ */
1259+#ifdef __KERNEL__
1260+#define DAVINCIFB_DEVICE "davincifb"
1261+#define DAVINCIFB_DRIVER "davincifb"
1262+
1263+#define MULTIPLE_BUFFERING 1
1264+
1265+#ifdef MULTIPLE_BUFFERING
1266+#define DOUBLE_BUF 2
1267+#define TRIPLE_BUF 3
1268+#else
1269+#define DOUBLE_BUF 1
1270+#define TRIPLE_BUF 1
1271+#endif
1272+
1273+/* usage: if (is_win(info->fix.id, OSD0)) ... */
1274+#define is_win(name, x) ((strcmp(name, x ## _FBNAME) == 0) ? 1 : 0)
1275+
1276+/*
1277+ * display controller register I/O routines
1278+ */
1279+u32 dispc_reg_in(u32 offset);
1280+u32 dispc_reg_out(u32 offset, u32 val);
1281+u32 dispc_reg_merge(u32 offset, u32 val, u32 mask);
1282+
1283+#endif /*__KERNEL__*/
1284+
1285+/* Error return codes */
1286+#define VPBE_INVALID_PARA_VALUE 700
1287+#define VPBE_WRONG_WINDOW_ID 701
1288+#define VPBE_CURRENTLY_IN_REQUIRED_MODE 702
1289+#define VPBE_INSUFFICIENT_CLUT_VALUES 703
1290+#define VPBE_CLUT_WRITE_TIMEOUT 704
1291+#define VPBE_VID0_BUF_ADR_NULL 705
1292+#define VPBE_WINDOW_NOT_DISABLED 706
1293+#define VPBE_WINDOW_NOT_ENABLED 707
1294+
1295+#ifndef __KERNEL__
1296+/* Window ID definations */
1297+#define OSD0 0
1298+#define VID0 1
1299+#define OSD1 2
1300+#define VID1 3
1301+#endif
1302+
1303+/* There are 4 framebuffers, each represented by an fb_info and
1304+ * a dm_win_info structure */
1305+#define OSD0_FBNAME "dm_osd0_fb"
1306+#define OSD1_FBNAME "dm_osd1_fb"
1307+#define VID0_FBNAME "dm_vid0_fb"
1308+#define VID1_FBNAME "dm_vid1_fb"
1309+
1310+/* FIXME: Digital LCD RGB matrix coefficients */
1311+#define DLCD_DGY_VAL 0
1312+#define DLCD_DRV_VAL 0
1313+#define DLCD_DGU_VAL 0
1314+#define DLCD_DBU_VAL 0
1315+
1316+/* Defines for bitmap format */
1317+#define VPBE_BITMAP_BIT_1 1
1318+#define VPBE_BITMAP_BIT_2 2
1319+#define VPBE_BITMAP_BIT_4 4
1320+#define VPBE_BITMAP_BIT_8 8
1321+#define VPBE_BITMAP_RGB565 16
1322+#define VPBE_VIDEO_YUV422 16
1323+#define VPBE_VIDEO_RGB888 24
1324+
1325+/* Defines foe cursor parameter validation*/
1326+#define MAX_CURSOR_WIDTH 0x3FF
1327+#define MAX_CURSOR_HEIGHT 0x1FF
1328+#define MAX_CURSOR_LINEWIDTH 7
1329+
1330+#define BASEX 0x80
1331+#define BASEY 0x12
1332+#define BASEX_DLCD 0x59
1333+#define BASEY_DLCD 0x22
1334+
1335+/*
1336+ * Enumerations
1337+ */
1338+/* Enum for blending factor */
1339+typedef enum vpbe_blend_factor {
1340+ OSD_CONTRIBUTION_ZERO = 0,
1341+ OSD_CONTRIBUTION_1_BY_8 = 1,
1342+ OSD_CONTRIBUTION_2_BY_8 = 2,
1343+ OSD_CONTRIBUTION_3_BY_8 = 3,
1344+ OSD_CONTRIBUTION_4_BY_8 = 4,
1345+ OSD_CONTRIBUTION_5_BY_8 = 5,
1346+ OSD_CONTRIBUTION_6_BY_8 = 6,
1347+ OSD_CONTRIBUTION_ONE = 7
1348+} vpbe_blend_factor_t;
1349+
1350+/* Enum for Boolean variables */
1351+typedef enum {
1352+ SET_0 = 0,
1353+ SET_1 = 1
1354+} CB_CR_ORDER, ATTRIBUTE, ROM_RAM_CLUT;
1355+
1356+/* Defines for Display Interface */
1357+#define PRGB 0
1358+#define COMPOSITE 1
1359+#define SVIDEO 2
1360+#define COMPONENT 3
1361+#define RGB 4
1362+#define YCC16 5
1363+#define YCC8 6
1364+#define SRGB 7
1365+#define EPSON 8
1366+#define CASIO1G 9
1367+#define UDISP 10
1368+#define STN 11
1369+#define VPBE_MAX_INTERFACES 12
1370+
1371+/* Defines for Display Mode */
1372+#define LCD 0
1373+#define NTSC 1
1374+#define PAL 2
1375+#define P525 3
1376+#define P625 4
1377+
1378+#define DEFAULT_MODE 0
1379+#define P480 0
1380+#define P400 1
1381+#define P350 2
1382+#define NON_EXISTING_MODE 255
1383+/* Enable/Disable enum */
1384+typedef enum {
1385+ VPBE_DISABLE = 0,
1386+ VPBE_ENABLE = 1
1387+} ATTENUATION, TRANSPARENCY, EXPANSION, BLINKING;
1388+
1389+typedef enum clk_source {
1390+ CLK_SOURCE_CLK27 = 0,
1391+ CLK_SOURCE_CLK54 = 1,
1392+ CLK_SOURCE_VPBECLK = 2
1393+} CLK_SOURCE;
1394+
1395+/*
1396+ * Structures and Union Definitions
1397+ */
1398+
1399+/* Structure for transparency and the blending factor for the bitmap window */
1400+typedef struct vpbe_bitmap_blend_params {
1401+ unsigned int colorkey; /* color key to be blend */
1402+ unsigned int enable_colorkeying; /* enable color keying */
1403+ unsigned int bf; /* valid range from 0 to 7 only. */
1404+} vpbe_bitmap_blend_params_t;
1405+
1406+/* Structure for window expansion */
1407+typedef struct vpbe_win_expansion {
1408+ EXPANSION horizontal;
1409+ EXPANSION vertical; /* 1: Enable 0:disable */
1410+} vpbe_win_expansion_t;
1411+
1412+/* Structure for OSD window blinking options */
1413+typedef struct vpbe_blink_option {
1414+ BLINKING blinking; /* 1: Enable blinking 0: Disable */
1415+ unsigned int interval; /* Valid only if blinking is 1 */
1416+} vpbe_blink_option_t;
1417+
1418+/* Structure for DCLK parameters */
1419+typedef struct vpbe_dclk {
1420+ unsigned char dclk_pattern_width;
1421+ unsigned int dclk_pattern0;
1422+ unsigned int dclk_pattern1;
1423+ unsigned int dclk_pattern2;
1424+ unsigned int dclk_pattern3;
1425+} vpbe_dclk_t;
1426+
1427+/* Structure for display format */
1428+typedef struct vpbe_display_format {
1429+ unsigned char interface; /* Output interface type */
1430+ unsigned char mode; /* output mode */
1431+} vpbe_display_format_t;
1432+
1433+/* Structure for background color */
1434+typedef struct vpbe_backg_color {
1435+ unsigned char clut_select; /* 2: RAM CLUT 1:ROM1 CLUT 0:ROM0 CLUT */
1436+ unsigned char color_offset; /* index of color */
1437+} vpbe_backg_color_t;
1438+
1439+/* Structure for Video window configurable parameters */
1440+typedef struct vpbe_video_config_params {
1441+ CB_CR_ORDER cb_cr_order; /*Cb/Cr order in input data for a pixel. */
1442+ /* 0: cb cr 1: cr cb */
1443+ vpbe_win_expansion_t exp_info; /* HZ/VT Expansion enable disable */
1444+} vpbe_video_config_params_t;
1445+
1446+/*Union of structures giving the CLUT index for the 1, 2, 4 bit bitmap values.*/
1447+typedef union vpbe_clut_idx {
1448+ struct _for_4bit_bimap {
1449+ unsigned char bitmap_val_0;
1450+ unsigned char bitmap_val_1;
1451+ unsigned char bitmap_val_2;
1452+ unsigned char bitmap_val_3;
1453+ unsigned char bitmap_val_4;
1454+ unsigned char bitmap_val_5;
1455+ unsigned char bitmap_val_6;
1456+ unsigned char bitmap_val_7;
1457+ unsigned char bitmap_val_8;
1458+ unsigned char bitmap_val_9;
1459+ unsigned char bitmap_val_10;
1460+ unsigned char bitmap_val_11;
1461+ unsigned char bitmap_val_12;
1462+ unsigned char bitmap_val_13;
1463+ unsigned char bitmap_val_14;
1464+ unsigned char bitmap_val_15;
1465+ } for_4bit_bimap;
1466+ struct _for_2bit_bimap {
1467+ unsigned char bitmap_val_0;
1468+ unsigned char dummy0[4];
1469+ unsigned char bitmap_val_1;
1470+ unsigned char dummy1[4];
1471+ unsigned char bitmap_val_2;
1472+ unsigned char dummy2[4];
1473+ unsigned char bitmap_val_3;
1474+ } for_2bit_bimap;
1475+ struct _for_1bit_bimap {
1476+ unsigned char bitmap_val_0;
1477+ unsigned char dummy0[14];
1478+ unsigned char bitmap_val_1;
1479+ } for_1bit_bimap;
1480+} vpbe_clut_idx_t;
1481+
1482+/* Structure for bitmap window configurable parameters */
1483+typedef struct vpbe_bitmap_config_params {
1484+ /* Only for bitmap width = 1,2,4 bits */
1485+ vpbe_clut_idx_t clut_idx;
1486+ /* Attenuation value for YUV o/p for bitmap window */
1487+ unsigned char attenuation_enable;
1488+ /* 0: ROM DM270, 1:ROM DM320, 2:RAM CLUT */
1489+ unsigned char clut_select;
1490+} vpbe_bitmap_config_params_t;
1491+
1492+/* Unioun for video/OSD configuration parameters */
1493+typedef union vpbe_conf_params {
1494+
1495+ struct vpbe_video_params {
1496+ CB_CR_ORDER cb_cr_order;
1497+ /* HZ/VT Expansion enable disable */
1498+ vpbe_win_expansion_t exp_info;
1499+ } video_params;
1500+
1501+ struct vpbe_bitmap_params {
1502+ /* Attenuation value for YUV o/p */
1503+ ATTENUATION attenuation_enable;
1504+ /* 0: ROM DM270, 1: ROM DM320, 2:RAM CLUT */
1505+ unsigned char clut_select;
1506+ /* Only for bitmap width = 1,2,4 bits */
1507+ vpbe_clut_idx_t clut_idx;
1508+ /* 0: OSD window is bitmap window */
1509+ /* 1: OSD window is attribute window */
1510+ ATTRIBUTE enable_attribute;
1511+ /* To hold bps value.
1512+ Used to switch back from attribute to bitmap. */
1513+ unsigned int stored_bits_per_pixel;
1514+ /* Blending information */
1515+ vpbe_bitmap_blend_params_t blend_info;
1516+ /* OSD Blinking information */
1517+ vpbe_blink_option_t blink_info;
1518+ } bitmap_params;
1519+
1520+} vpbe_conf_params_t;
1521+
1522+typedef struct vpbe_video_params vpbe_video_params_t;
1523+typedef struct vpbe_bitmap_params vpbe_bitmap_params_t;
1524+
1525+/* Structure to hold window position */
1526+typedef struct vpbe_window_position {
1527+ unsigned int xpos; /* X position of the window */
1528+ unsigned int ypos; /* Y position of the window */
1529+} vpbe_window_position_t;
1530+
1531+#ifdef __KERNEL__
1532+/* Structure for each window */
1533+typedef struct vpbe_dm_win_info {
1534+ struct fb_info info;
1535+ vpbe_window_position_t win_pos; /* X,Y position of window */
1536+ /* Size of window is already there in var_info structure. */
1537+
1538+ dma_addr_t fb_base_phys; /*framebuffer area */
1539+ unsigned int fb_base; /*window memory pointer */
1540+ unsigned int fb_size; /*memory size */
1541+ unsigned int pseudo_palette[17];
1542+ int alloc_fb_mem;
1543+ /*flag to identify if framebuffer area is fixed or not */
1544+ unsigned long sdram_address;
1545+ struct vpbe_dm_info *dm;
1546+ unsigned char window_enable; /*Additions for all windows */
1547+ zoom_params_t zoom; /*Zooming parameters */
1548+ unsigned char field_frame_select; /*To select Field or frame */
1549+ unsigned char numbufs; /*Number of buffers valid 2 or 3 */
1550+ vpbe_conf_params_t conf_params;
1551+ /*window configuration parameter union pointer */
1552+} vpbe_dm_win_info_t;
1553+#endif /*__KERNEL__*/
1554+
1555+/*
1556+ * Videmode structure for display interface and mode settings
1557+ */
1558+typedef struct vpbe_fb_videomode {
1559+ unsigned char name[10]; /* Mode name ( NTSC , PAL) */
1560+ unsigned int vmode; /* FB_MODE_INTERLACED or FB_MODE_NON_INTERLACED */
1561+ unsigned int xres; /* X Resolution of the display */
1562+ unsigned int yres; /* Y Resolution of the display */
1563+ unsigned int fps; /* frames per second */
1564+ /* Timing Parameters applicable for std = 0 only */
1565+ unsigned int left_margin;
1566+ unsigned int right_margin;
1567+ unsigned int upper_margin;
1568+ unsigned int lower_margin;
1569+ unsigned int hsync_len;
1570+ unsigned int vsync_len;
1571+ unsigned int sync; /* 0: hsync -ve/vsync -ve */
1572+ /*1: hsync -ve/vsync +ve */
1573+ /*2: hsync +ve/vsync -ve */
1574+ /*3: hsync +ve/vsync +ve */
1575+ unsigned int basepx; /* Display x,y start position */
1576+ unsigned int basepy;
1577+/* 1= Mode s available in modelist 0=Mode is not available in modelist */
1578+ unsigned int std;
1579+} vpbe_fb_videomode_t;
1580+
1581+/* Structure to interface videomode to application*/
1582+typedef struct vpbe_mode_info {
1583+ vpbe_fb_videomode_t vid_mode;
1584+ unsigned char interface;
1585+ unsigned char mode_idx;
1586+} vpbe_mode_info_t;
1587+
1588+#ifdef __KERNEL__
1589+/*
1590+ * Structure for the driver holding information of windows,
1591+ * memory base addresses etc.
1592+ */
1593+typedef struct vpbe_dm_info {
1594+ vpbe_dm_win_info_t *osd0;
1595+ vpbe_dm_win_info_t *osd1;
1596+ vpbe_dm_win_info_t *vid0;
1597+ vpbe_dm_win_info_t *vid1;
1598+
1599+/* to map the registers */
1600+ dma_addr_t mmio_base_phys;
1601+ unsigned int mmio_base;
1602+ unsigned int mmio_size;
1603+
1604+ wait_queue_head_t vsync_wait;
1605+ unsigned int vsync_cnt;
1606+ int timeout;
1607+
1608+ /* this is the function that configures the output device (NTSC/PAL/LCD)
1609+ * for the required output format (composite/s-video/component/rgb)
1610+ */
1611+ void (*output_device_config) (void);
1612+
1613+ struct device *dev;
1614+
1615+ vpbe_backg_color_t backg; /* background color */
1616+ vpbe_dclk_t dclk; /*DCLK parameters */
1617+ vpbe_display_format_t display; /*Display interface and mode */
1618+ vpbe_fb_videomode_t videomode; /*Cuurent videomode */
1619+ char ram_clut[256][3]; /*RAM CLUT array */
1620+ struct fb_cursor cursor; /* cursor config params from fb.h */
1621+/*Flag that indicates whether any of the display is enabled or not*/
1622+ int display_enable;
1623+} vpbe_dm_info_t;
1624+
1625+/*
1626+ * Functions Definitions for 'davincifb' module
1627+ */
1628+int vpbe_mem_alloc_window_buf(vpbe_dm_win_info_t *);
1629+int vpbe_mem_release_window_buf(vpbe_dm_win_info_t *);
1630+void init_display_function(vpbe_display_format_t *);
1631+int vpbe_mem_alloc_struct(vpbe_dm_win_info_t **);
1632+void set_vid0_default_conf(void);
1633+void set_vid1_default_conf(void);
1634+void set_osd0_default_conf(void);
1635+void set_osd1_default_conf(void);
1636+void set_cursor_default_conf(void);
1637+void set_dm_default_conf(void);
1638+void set_win_enable(char *, unsigned int);
1639+int within_vid0_limits(u32, u32, u32, u32);
1640+void vpbe_set_display_default(void);
1641+#ifdef __KERNEL__
1642+void set_win_position(char *, u32, u32, u32, u32);
1643+void change_win_param(int);
1644+void set_interlaced(char *, unsigned int);
1645+#endif /* __KERNEL__ */
1646+
1647+/*
1648+ * Function definations for 'osd' module
1649+ */
1650+
1651+int vpbe_enable_window(vpbe_dm_win_info_t *);
1652+int vpbe_disable_window(vpbe_dm_win_info_t *);
1653+int vpbe_vid_osd_select_field_frame(u8 *, u8);
1654+int vpbe_bitmap_set_blend_factor(u8 *, vpbe_bitmap_blend_params_t *);
1655+int vpbe_bitmap_set_ram_clut(void);
1656+int vpbe_enable_disable_attribute_window(u32);
1657+int vpbe_get_blinking(u8 *, vpbe_blink_option_t *);
1658+int vpbe_set_blinking(u8 *, vpbe_blink_option_t *);
1659+int vpbe_set_vid_params(u8 *, vpbe_video_config_params_t *);
1660+int vpbe_get_vid_params(u8 *, vpbe_video_config_params_t *);
1661+int vpbe_bitmap_get_params(u8 *, vpbe_bitmap_config_params_t *);
1662+int vpbe_bitmap_set_params(u8 *, vpbe_bitmap_config_params_t *);
1663+int vpbe_set_cursor_params(struct fb_cursor *);
1664+int vpbe_set_vid_expansion(vpbe_win_expansion_t *);
1665+int vpbe_set_dclk(vpbe_dclk_t *);
1666+int vpbe_set_display_format(vpbe_display_format_t *);
1667+int vpbe_set_backg_color(vpbe_backg_color_t *);
1668+int vpbe_set_interface(u8);
1669+int vpbe_query_mode(vpbe_mode_info_t *);
1670+int vpbe_set_mode(struct vpbe_fb_videomode *);
1671+int vpbe_set_venc_clk_source(u8);
1672+void set_vid0_default_conf(void);
1673+void set_osd0_default_conf(void);
1674+void set_vid1_default_conf(void);
1675+void set_osd1_default_conf(void);
1676+void set_cursor_default_conf(void);
1677+void set_dm_default_conf(void);
1678+/*
1679+ * Function definations for 'venc' module
1680+ */
1681+
1682+void davincifb_ntsc_composite_config(void);
1683+void davincifb_ntsc_svideo_config(void);
1684+void davincifb_ntsc_component_config(void);
1685+void davincifb_pal_composite_config(void);
1686+void davincifb_pal_svideo_config(void);
1687+void davincifb_pal_component_config(void);
1688+
1689+void vpbe_davincifb_ntsc_rgb_config(void);
1690+void vpbe_davincifb_pal_rgb_config(void);
1691+void vpbe_davincifb_525p_component_config(void);
1692+void vpbe_davincifb_625p_component_config(void);
1693+
1694+void vpbe_enable_venc(int);
1695+void vpbe_enable_dacs(int);
1696+/*
1697+ * Function definations for 'dlcd' module
1698+ */
1699+void vpbe_davincifb_480p_prgb_config(void);
1700+void vpbe_davincifb_400p_prgb_config(void);
1701+void vpbe_davincifb_350p_prgb_config(void);
1702+void vpbe_set_display_timing(struct vpbe_fb_videomode *);
1703+
1704+void vpbe_enable_lcd(int);
1705+/*
1706+ * Following functions are not implemented
1707+ */
1708+void vpbe_davincifb_default_ycc16_config(void);
1709+void vpbe_davincifb_default_ycc8_config(void);
1710+void vpbe_davincifb_default_srgb_config(void);
1711+void vpbe_davincifb_default_epson_config(void);
1712+void vpbe_davincifb_default_casio_config(void);
1713+void vpbe_davincifb_default_UDISP_config(void);
1714+void vpbe_davincifb_default_STN_config(void);
1715+#endif /*__KERNEL__*/
1716+
1717+#endif /* End of #ifndef DAVINCI_VPBE_H */