4
* Copyright (C) 2008-2010 Nokia Corporation
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation; either version 2 or
9
* (at your option) any later version of the License.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
#include "hw/display/framebuffer.h"
25
#define DSI_MAKERETURNBYTE(b) ((((b) & 0xff) << 8) | 0x21)
26
#define DSI_MAKERETURNWORD(w) ((((w) & 0xffff) << 8) | 0x22)
27
#define DSI_MAKERETURNERROR(e) ((((e) & 0xffff) << 8) | 0x02)
29
typedef struct DSIDevice DSIDevice;
30
typedef struct DSICommonDevice DSICommonDevice;
31
typedef struct DSIHost DSIHost;
33
#define TYPE_DSI_DEVICE "dsi-device"
34
#define DSI_DEVICE(obj) \
35
OBJECT_CHECK(DSIDevice, (obj), TYPE_DSI_DEVICE)
36
#define DSI_DEVICE_CLASS(klass) \
37
OBJECT_CLASS_CHECK(DSIDeviceClass, (klass), TYPE_DSI_DEVICE)
38
#define DSI_DEVICE_GET_CLASS(obj) \
39
OBJECT_GET_CLASS(DSIDeviceClass, (obj), TYPE_DSI_DEVICE)
41
#define TYPE_DSI_COMMON_DEVICE "dsi-common-device"
42
#define DSI_COMMON_DEVICE(obj) \
43
OBJECT_CHECK(DSICommonDevice, (obj), TYPE_DSI_COMMON_DEVICE)
44
#define DSI_COMMON_DEVICE_CLASS(klass) \
45
OBJECT_CLASS_CHECK(DSICommonDeviceClass, (klass), TYPE_DSI_COMMON_DEVICE)
46
#define DSI_COMMON_DEVICE_GET_CLASS(obj) \
47
OBJECT_GET_CLASS(DSICommonDeviceClass, (obj), TYPE_DSI_COMMON_DEVICE)
51
/* device callbacks */
52
typedef int (*dsi_device_initfn)(DSIDevice *dev);
53
typedef void (*dsi_write_cb)(DSIDevice *dev, uint32_t data, int len);
54
typedef uint32_t (*dsi_read_cb)(DSIDevice *dev, uint32_t data, int len);
55
typedef int (*dsi_blt_cb)(DSIDevice *dev, void *data, int width, int height,
56
int col_pitch, int row_pitch, int format);
58
/* common device callbacks */
59
typedef void (*dsi_common_write_cb)(DSICommonDevice *dev, uint32_t data,
61
typedef uint32_t (*dsi_common_read_cb)(DSICommonDevice *dev, uint32_t data,
63
typedef void (*dsi_common_device_resetfn)(DSICommonDevice *dev);
64
typedef void (*dsi_powermode_changed_cb)(DSICommonDevice *dev);
65
typedef void (*dsi_temode_changed_cb)(DSICommonDevice *dev);
68
typedef void (*dsi_te_trigger_cb)(DeviceState *dev, int vc);
69
typedef drawfn (*dsi_get_drawfn_cb)(const DeviceState *dev, int format,
73
DeviceClass parent_class;
74
dsi_device_initfn init;
81
DSIDeviceClass parent_class;
82
dsi_common_write_cb write;
83
dsi_common_read_cb read;
84
dsi_common_device_resetfn reset;
85
dsi_powermode_changed_cb powermode_changed;
86
dsi_temode_changed_cb temode_changed;
87
} DSICommonDeviceClass;
92
/* internal fields used by DSI code */
95
uint16_t max_return_size;
98
struct DSICommonDevice {
100
enum { bs_cmd, bs_data } bs;
121
DSIHost *dsi_init_host(DeviceState *parent, const char *name,
122
dsi_te_trigger_cb te_trigger_cb,
123
dsi_get_drawfn_cb get_drawfn_cb);
124
uint32_t dsi_short_write(DSIHost *host, uint32_t data);
125
void dsi_long_write(DSIHost *host, uint32_t header, uint32_t payload,
127
int dsi_blt(DSIHost *host, int vc, void *data, int width, int height,
128
int col_pitch, int row_pitch, int format);
130
/* device -> host functions */
131
void dsi_te_trigger(const DSIDevice *dev);
132
drawfn dsi_get_drawfn(const DSIDevice *dev, int format, int bpp);
134
#define DSI_DEVICE_FROM_QDEV(dev) DO_UPCAST(DSIDevice, qdev, dev)
135
#define DSI_COMMON_DEVICE_FROM_QDEV(dev) DO_UPCAST(DSICommonDevice, dsi, \
136
DSI_DEVICE_FROM_QDEV(dev))
137
#define FROM_DSI_DEVICE(type, dev) DO_UPCAST(type, dsi, dev)
139
DeviceState *dsi_create_device(DSIHost *host, const char *name, int vc);
140
DeviceState *dsi_create_device_noinit(DSIHost *host, const char *name, int vc);
141
DeviceState *dsi_create_common_device(DSIHost *host, const char *name, int vc);
142
DeviceState *dsi_create_common_device_noinit(DSIHost *host, const char *name,