summaryrefslogtreecommitdiff
path: root/Source/DirectFB/gfxdrivers/sh772x/sh7722.h
blob: 0a80512c6bb9929d6db026a7460515cf6c6552fc (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
#ifndef __SH7722__SH7722_H__
#define __SH7722__SH7722_H__

#include <sys/ioctl.h>

#include <sh772x_gfx.h>

#include "sh7722_regs.h"
#include "sh7722_types.h"


#define SH772X_FBDEV_SUPPORT
// #define JPU_SUPPORT

/******************************************************************************
 * Platform specific values (FIXME: add runtime config)
 */

#define ALGO_AP325
#undef  SH7722_ALGO_PANEL

/* LCD Panel Configuration */
#if defined(SH7722_ALGO_PANEL)
#  define	SH7722_LCD_WIDTH	640
#  define	SH7722_LCD_HEIGHT	480
#elif defined(ALGO_AP325)
#  define	SH7722_LCD_WIDTH	800
#  define	SH7722_LCD_HEIGHT	480
#else
#  define	SH7722_LCD_WIDTH	800
#  define	SH7722_LCD_HEIGHT	480
#endif


/******************************************************************************
 * Register access
 */

//#define SH7722_TDG_REG_USE_IOCTLS

#ifdef SH7722_TDG_REG_USE_IOCTLS
static inline u32
SH7722_TDG_GETREG32( SH7722DriverData *sdrv,
                     u32               address )
{
     SH772xRegister reg = { address, 0 };

     if (ioctl( sdrv->gfx_fd, SH772xGFX_IOCTL_GETREG32, &reg ) < 0)
          D_PERROR( "SH772xGFX_IOCTL_GETREG32( 0x%08x )\n", reg.address );

     return reg.value;
}

static inline void
SH7722_TDG_SETREG32( SH7722DriverData *sdrv,
                     u32               address,
                     u32               value )
{
     SH772xRegister reg = { address, value };

     if (ioctl( sdrv->gfx_fd, SH772xGFX_IOCTL_SETREG32, &reg ) < 0)
          D_PERROR( "SH772xGFX_IOCTL_SETREG32( 0x%08x, 0x%08x )\n", reg.address, reg.value );
}
#else
static inline u32
SH7722_TDG_GETREG32( SH7722DriverData *sdrv,
                     u32               address )
{
     D_ASSERT( address >= dfb_config->mmio_phys );
     D_ASSERT( address < (dfb_config->mmio_phys + dfb_config->mmio_length) );

     return *(volatile u32*)(sdrv->mmio_base + (address - dfb_config->mmio_phys));
}

static inline void
SH7722_TDG_SETREG32( SH7722DriverData *sdrv,
                     u32               address,
                     u32               value )
{
     D_ASSERT( address >= dfb_config->mmio_phys );
     D_ASSERT( address < (dfb_config->mmio_phys + dfb_config->mmio_length) );

     *(volatile u32*)(sdrv->mmio_base + (address - dfb_config->mmio_phys)) = value;
}
#endif


static inline u32
SH7722_GETREG32( SH7722DriverData *sdrv,
                 u32               address )
{
     SH772xRegister reg = { address, 0 };

     if (ioctl( sdrv->gfx_fd, SH772xGFX_IOCTL_GETREG32, &reg ) < 0)
          D_PERROR( "SH772xGFX_IOCTL_GETREG32( 0x%08x )\n", reg.address );

     return reg.value;
}

static inline void
SH7722_SETREG32( SH7722DriverData *sdrv,
                 u32               address,
                 u32               value )
{
     SH772xRegister reg = { address, value };

     if (ioctl( sdrv->gfx_fd, SH772xGFX_IOCTL_SETREG32, &reg ) < 0)
          D_PERROR( "SH772xGFX_IOCTL_SETREG32( 0x%08x, 0x%08x )\n", reg.address, reg.value );
}


static inline void
BEU_Start( SH7722DriverData *sdrv,
           SH7722DeviceData *sdev )
{
     /* Wait for idle BEU. */
     while (SH7722_GETREG32( sdrv, BSTAR ) & 1);

     /* Start operation! */
     SH7722_SETREG32( sdrv, BESTR, (sdev->input_mask << 8) | 1 );
}

static inline void
BEU_Wait( SH7722DriverData *sdrv,
          SH7722DeviceData *sdev )
{
     /* Wait for idle BEU. */
     while (SH7722_GETREG32( sdrv, BSTAR ) & 1);
}

#endif