4 * Copyright (C) 2015 : GreenSocs Ltd
5 * http://www.greensocs.com/ , email: info@greensocs.com
8 * Frederic Konrad <fred.konrad@greensocs.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, see <http://www.gnu.org/licenses/>.
27 #include "hw/sysbus.h"
28 #include "ui/console.h"
29 #include "hw/misc/auxbus.h"
30 #include "hw/i2c/i2c.h"
31 #include "hw/display/dpcd.h"
32 #include "hw/display/i2c-ddc.h"
33 #include "qemu/fifo8.h"
34 #include "qemu/units.h"
35 #include "hw/dma/xlnx_dpdma.h"
36 #include "audio/audio.h"
38 #define AUD_CHBUF_MAX_DEPTH (32 * KiB)
39 #define MAX_QEMU_BUFFER_SIZE (4 * KiB)
41 #define DP_CORE_REG_ARRAY_SIZE (0x3AF >> 2)
42 #define DP_AVBUF_REG_ARRAY_SIZE (0x238 >> 2)
43 #define DP_VBLEND_REG_ARRAY_SIZE (0x1DF >> 2)
44 #define DP_AUDIO_REG_ARRAY_SIZE (0x50 >> 2)
47 pixman_format_code_t format
;
48 DisplaySurface
*surface
;
51 typedef struct XlnxDPState
{
53 SysBusDevice parent_obj
;
56 MemoryRegion container
;
58 uint32_t core_registers
[DP_CORE_REG_ARRAY_SIZE
];
59 MemoryRegion core_iomem
;
61 uint32_t avbufm_registers
[DP_AVBUF_REG_ARRAY_SIZE
];
62 MemoryRegion avbufm_iomem
;
64 uint32_t vblend_registers
[DP_VBLEND_REG_ARRAY_SIZE
];
65 MemoryRegion vblend_iomem
;
67 uint32_t audio_registers
[DP_AUDIO_REG_ARRAY_SIZE
];
68 MemoryRegion audio_iomem
;
73 * This is the planes used to display in console. When the blending is
74 * enabled bout_plane is displayed in console else it's g_plane.
76 struct PixmanPlane g_plane
;
77 struct PixmanPlane v_plane
;
78 struct PixmanPlane bout_plane
;
80 QEMUSoundCard aud_card
;
81 SWVoiceOut
*amixer_output_stream
;
82 int16_t audio_buffer_0
[AUD_CHBUF_MAX_DEPTH
];
83 int16_t audio_buffer_1
[AUD_CHBUF_MAX_DEPTH
];
84 size_t audio_data_available
[2];
85 int64_t temp_buffer
[AUD_CHBUF_MAX_DEPTH
];
86 int16_t out_buffer
[AUD_CHBUF_MAX_DEPTH
];
87 size_t byte_left
; /* byte available in out_buffer. */
88 size_t data_ptr
; /* next byte to be sent to QEMU. */
90 /* Associated DPDMA controller. */
91 XlnxDPDMAState
*dpdma
;
100 * XXX: This should be in an other module.
106 #define TYPE_XLNX_DP "xlnx.v-dp"
107 #define XLNX_DP(obj) OBJECT_CHECK(XlnxDPState, (obj), TYPE_XLNX_DP)