xref: /openbmc/qemu/include/hw/display/xlnx_dp.h (revision 58ac482a66de09a7590f705e53fc6a3fb8a055e8)
1*58ac482aSKONRAD Frederic /*
2*58ac482aSKONRAD Frederic  * xlnx_dp.h
3*58ac482aSKONRAD Frederic  *
4*58ac482aSKONRAD Frederic  *  Copyright (C) 2015 : GreenSocs Ltd
5*58ac482aSKONRAD Frederic  *      http://www.greensocs.com/ , email: info@greensocs.com
6*58ac482aSKONRAD Frederic  *
7*58ac482aSKONRAD Frederic  *  Developed by :
8*58ac482aSKONRAD Frederic  *  Frederic Konrad   <fred.konrad@greensocs.com>
9*58ac482aSKONRAD Frederic  *
10*58ac482aSKONRAD Frederic  * This program is free software; you can redistribute it and/or modify
11*58ac482aSKONRAD Frederic  * it under the terms of the GNU General Public License as published by
12*58ac482aSKONRAD Frederic  * the Free Software Foundation, either version 2 of the License, or
13*58ac482aSKONRAD Frederic  * (at your option) any later version.
14*58ac482aSKONRAD Frederic  *
15*58ac482aSKONRAD Frederic  * This program is distributed in the hope that it will be useful,
16*58ac482aSKONRAD Frederic  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*58ac482aSKONRAD Frederic  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*58ac482aSKONRAD Frederic  * GNU General Public License for more details.
19*58ac482aSKONRAD Frederic  *
20*58ac482aSKONRAD Frederic  * You should have received a copy of the GNU General Public License along
21*58ac482aSKONRAD Frederic  * with this program; if not, see <http://www.gnu.org/licenses/>.
22*58ac482aSKONRAD Frederic  *
23*58ac482aSKONRAD Frederic  */
24*58ac482aSKONRAD Frederic 
25*58ac482aSKONRAD Frederic #include "hw/sysbus.h"
26*58ac482aSKONRAD Frederic #include "ui/console.h"
27*58ac482aSKONRAD Frederic #include "hw/misc/aux.h"
28*58ac482aSKONRAD Frederic #include "hw/i2c/i2c.h"
29*58ac482aSKONRAD Frederic #include "hw/display/dpcd.h"
30*58ac482aSKONRAD Frederic #include "hw/i2c/i2c-ddc.h"
31*58ac482aSKONRAD Frederic #include "qemu/fifo8.h"
32*58ac482aSKONRAD Frederic #include "hw/dma/xlnx_dpdma.h"
33*58ac482aSKONRAD Frederic #include "audio/audio.h"
34*58ac482aSKONRAD Frederic 
35*58ac482aSKONRAD Frederic #ifndef XLNX_DP_H
36*58ac482aSKONRAD Frederic #define XLNX_DP_H
37*58ac482aSKONRAD Frederic 
38*58ac482aSKONRAD Frederic #define AUD_CHBUF_MAX_DEPTH                 32768
39*58ac482aSKONRAD Frederic #define MAX_QEMU_BUFFER_SIZE                4096
40*58ac482aSKONRAD Frederic 
41*58ac482aSKONRAD Frederic #define DP_CORE_REG_ARRAY_SIZE              (0x3AF >> 2)
42*58ac482aSKONRAD Frederic #define DP_AVBUF_REG_ARRAY_SIZE             (0x238 >> 2)
43*58ac482aSKONRAD Frederic #define DP_VBLEND_REG_ARRAY_SIZE            (0x1DF >> 2)
44*58ac482aSKONRAD Frederic #define DP_AUDIO_REG_ARRAY_SIZE             (0x50 >> 2)
45*58ac482aSKONRAD Frederic 
46*58ac482aSKONRAD Frederic struct PixmanPlane {
47*58ac482aSKONRAD Frederic     pixman_format_code_t format;
48*58ac482aSKONRAD Frederic     DisplaySurface *surface;
49*58ac482aSKONRAD Frederic };
50*58ac482aSKONRAD Frederic 
51*58ac482aSKONRAD Frederic typedef struct XlnxDPState {
52*58ac482aSKONRAD Frederic     /*< private >*/
53*58ac482aSKONRAD Frederic     SysBusDevice parent_obj;
54*58ac482aSKONRAD Frederic 
55*58ac482aSKONRAD Frederic     /* < public >*/
56*58ac482aSKONRAD Frederic     MemoryRegion container;
57*58ac482aSKONRAD Frederic 
58*58ac482aSKONRAD Frederic     uint32_t core_registers[DP_CORE_REG_ARRAY_SIZE];
59*58ac482aSKONRAD Frederic     MemoryRegion core_iomem;
60*58ac482aSKONRAD Frederic 
61*58ac482aSKONRAD Frederic     uint32_t avbufm_registers[DP_AVBUF_REG_ARRAY_SIZE];
62*58ac482aSKONRAD Frederic     MemoryRegion avbufm_iomem;
63*58ac482aSKONRAD Frederic 
64*58ac482aSKONRAD Frederic     uint32_t vblend_registers[DP_VBLEND_REG_ARRAY_SIZE];
65*58ac482aSKONRAD Frederic     MemoryRegion vblend_iomem;
66*58ac482aSKONRAD Frederic 
67*58ac482aSKONRAD Frederic     uint32_t audio_registers[DP_AUDIO_REG_ARRAY_SIZE];
68*58ac482aSKONRAD Frederic     MemoryRegion audio_iomem;
69*58ac482aSKONRAD Frederic 
70*58ac482aSKONRAD Frederic     QemuConsole *console;
71*58ac482aSKONRAD Frederic 
72*58ac482aSKONRAD Frederic     /*
73*58ac482aSKONRAD Frederic      * This is the planes used to display in console. When the blending is
74*58ac482aSKONRAD Frederic      * enabled bout_plane is displayed in console else it's g_plane.
75*58ac482aSKONRAD Frederic      */
76*58ac482aSKONRAD Frederic     struct PixmanPlane g_plane;
77*58ac482aSKONRAD Frederic     struct PixmanPlane v_plane;
78*58ac482aSKONRAD Frederic     struct PixmanPlane bout_plane;
79*58ac482aSKONRAD Frederic 
80*58ac482aSKONRAD Frederic     QEMUSoundCard aud_card;
81*58ac482aSKONRAD Frederic     SWVoiceOut *amixer_output_stream;
82*58ac482aSKONRAD Frederic     int16_t audio_buffer_0[AUD_CHBUF_MAX_DEPTH];
83*58ac482aSKONRAD Frederic     int16_t audio_buffer_1[AUD_CHBUF_MAX_DEPTH];
84*58ac482aSKONRAD Frederic     size_t audio_data_available[2];
85*58ac482aSKONRAD Frederic     int64_t temp_buffer[AUD_CHBUF_MAX_DEPTH];
86*58ac482aSKONRAD Frederic     int16_t out_buffer[AUD_CHBUF_MAX_DEPTH];
87*58ac482aSKONRAD Frederic     size_t byte_left; /* byte available in out_buffer. */
88*58ac482aSKONRAD Frederic     size_t data_ptr;  /* next byte to be sent to QEMU. */
89*58ac482aSKONRAD Frederic 
90*58ac482aSKONRAD Frederic     /* Associated DPDMA controller. */
91*58ac482aSKONRAD Frederic     XlnxDPDMAState *dpdma;
92*58ac482aSKONRAD Frederic 
93*58ac482aSKONRAD Frederic     qemu_irq irq;
94*58ac482aSKONRAD Frederic 
95*58ac482aSKONRAD Frederic     AUXBus *aux_bus;
96*58ac482aSKONRAD Frederic     Fifo8 rx_fifo;
97*58ac482aSKONRAD Frederic     Fifo8 tx_fifo;
98*58ac482aSKONRAD Frederic 
99*58ac482aSKONRAD Frederic     /*
100*58ac482aSKONRAD Frederic      * XXX: This should be in an other module.
101*58ac482aSKONRAD Frederic      */
102*58ac482aSKONRAD Frederic     DPCDState *dpcd;
103*58ac482aSKONRAD Frederic     I2CDDCState *edid;
104*58ac482aSKONRAD Frederic } XlnxDPState;
105*58ac482aSKONRAD Frederic 
106*58ac482aSKONRAD Frederic #define TYPE_XLNX_DP "xlnx.v-dp"
107*58ac482aSKONRAD Frederic #define XLNX_DP(obj) OBJECT_CHECK(XlnxDPState, (obj), TYPE_XLNX_DP)
108*58ac482aSKONRAD Frederic 
109*58ac482aSKONRAD Frederic #endif /* !XLNX_DP_H */
110