xref: /openbmc/qemu/include/hw/display/xlnx_dp.h (revision 759ae1b4)
158ac482aSKONRAD Frederic /*
258ac482aSKONRAD Frederic  * xlnx_dp.h
358ac482aSKONRAD Frederic  *
458ac482aSKONRAD Frederic  *  Copyright (C) 2015 : GreenSocs Ltd
558ac482aSKONRAD Frederic  *      http://www.greensocs.com/ , email: info@greensocs.com
658ac482aSKONRAD Frederic  *
758ac482aSKONRAD Frederic  *  Developed by :
858ac482aSKONRAD Frederic  *  Frederic Konrad   <fred.konrad@greensocs.com>
958ac482aSKONRAD Frederic  *
1058ac482aSKONRAD Frederic  * This program is free software; you can redistribute it and/or modify
1158ac482aSKONRAD Frederic  * it under the terms of the GNU General Public License as published by
1258ac482aSKONRAD Frederic  * the Free Software Foundation, either version 2 of the License, or
1358ac482aSKONRAD Frederic  * (at your option) any later version.
1458ac482aSKONRAD Frederic  *
1558ac482aSKONRAD Frederic  * This program is distributed in the hope that it will be useful,
1658ac482aSKONRAD Frederic  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1758ac482aSKONRAD Frederic  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1858ac482aSKONRAD Frederic  * GNU General Public License for more details.
1958ac482aSKONRAD Frederic  *
2058ac482aSKONRAD Frederic  * You should have received a copy of the GNU General Public License along
2158ac482aSKONRAD Frederic  * with this program; if not, see <http://www.gnu.org/licenses/>.
2258ac482aSKONRAD Frederic  */
2358ac482aSKONRAD Frederic 
240553d895SMarkus Armbruster #ifndef XLNX_DP_H
250553d895SMarkus Armbruster #define XLNX_DP_H
260553d895SMarkus Armbruster 
2758ac482aSKONRAD Frederic #include "hw/sysbus.h"
2858ac482aSKONRAD Frederic #include "ui/console.h"
29e0dadc1eSPeter Maydell #include "hw/misc/auxbus.h"
3058ac482aSKONRAD Frederic #include "hw/i2c/i2c.h"
3158ac482aSKONRAD Frederic #include "hw/display/dpcd.h"
326306cae2SPaolo Bonzini #include "hw/display/i2c-ddc.h"
3358ac482aSKONRAD Frederic #include "qemu/fifo8.h"
34f0353b0dSPhilippe Mathieu-Daudé #include "qemu/units.h"
3558ac482aSKONRAD Frederic #include "hw/dma/xlnx_dpdma.h"
3658ac482aSKONRAD Frederic #include "audio/audio.h"
37db1015e9SEduardo Habkost #include "qom/object.h"
38*759ae1b4SSai Pavan Boddu #include "hw/ptimer.h"
3958ac482aSKONRAD Frederic 
40f0353b0dSPhilippe Mathieu-Daudé #define AUD_CHBUF_MAX_DEPTH                 (32 * KiB)
41f0353b0dSPhilippe Mathieu-Daudé #define MAX_QEMU_BUFFER_SIZE                (4 * KiB)
4258ac482aSKONRAD Frederic 
43d2008b33SFrederic Konrad #define DP_CORE_REG_OFFSET                  (0x0000)
44d2008b33SFrederic Konrad #define DP_CORE_REG_ARRAY_SIZE              (0x3B0 >> 2)
45d2008b33SFrederic Konrad #define DP_AVBUF_REG_OFFSET                 (0xB000)
4658ac482aSKONRAD Frederic #define DP_AVBUF_REG_ARRAY_SIZE             (0x238 >> 2)
47d2008b33SFrederic Konrad #define DP_VBLEND_REG_OFFSET                (0xA000)
48d2008b33SFrederic Konrad #define DP_VBLEND_REG_ARRAY_SIZE            (0x1E0 >> 2)
49d2008b33SFrederic Konrad #define DP_AUDIO_REG_OFFSET                 (0xC000)
5058ac482aSKONRAD Frederic #define DP_AUDIO_REG_ARRAY_SIZE             (0x50 >> 2)
51d2008b33SFrederic Konrad #define DP_CONTAINER_SIZE                   (0xC050)
5258ac482aSKONRAD Frederic 
5358ac482aSKONRAD Frederic struct PixmanPlane {
5458ac482aSKONRAD Frederic     pixman_format_code_t format;
5558ac482aSKONRAD Frederic     DisplaySurface *surface;
5658ac482aSKONRAD Frederic };
5758ac482aSKONRAD Frederic 
58db1015e9SEduardo Habkost struct XlnxDPState {
5958ac482aSKONRAD Frederic     /*< private >*/
6058ac482aSKONRAD Frederic     SysBusDevice parent_obj;
6158ac482aSKONRAD Frederic 
6258ac482aSKONRAD Frederic     /* < public >*/
6358ac482aSKONRAD Frederic     MemoryRegion container;
6458ac482aSKONRAD Frederic 
6558ac482aSKONRAD Frederic     uint32_t core_registers[DP_CORE_REG_ARRAY_SIZE];
6658ac482aSKONRAD Frederic     MemoryRegion core_iomem;
6758ac482aSKONRAD Frederic 
6858ac482aSKONRAD Frederic     uint32_t avbufm_registers[DP_AVBUF_REG_ARRAY_SIZE];
6958ac482aSKONRAD Frederic     MemoryRegion avbufm_iomem;
7058ac482aSKONRAD Frederic 
7158ac482aSKONRAD Frederic     uint32_t vblend_registers[DP_VBLEND_REG_ARRAY_SIZE];
7258ac482aSKONRAD Frederic     MemoryRegion vblend_iomem;
7358ac482aSKONRAD Frederic 
7458ac482aSKONRAD Frederic     uint32_t audio_registers[DP_AUDIO_REG_ARRAY_SIZE];
7558ac482aSKONRAD Frederic     MemoryRegion audio_iomem;
7658ac482aSKONRAD Frederic 
7758ac482aSKONRAD Frederic     QemuConsole *console;
7858ac482aSKONRAD Frederic 
7958ac482aSKONRAD Frederic     /*
8058ac482aSKONRAD Frederic      * This is the planes used to display in console. When the blending is
8158ac482aSKONRAD Frederic      * enabled bout_plane is displayed in console else it's g_plane.
8258ac482aSKONRAD Frederic      */
8358ac482aSKONRAD Frederic     struct PixmanPlane g_plane;
8458ac482aSKONRAD Frederic     struct PixmanPlane v_plane;
8558ac482aSKONRAD Frederic     struct PixmanPlane bout_plane;
8658ac482aSKONRAD Frederic 
8758ac482aSKONRAD Frederic     QEMUSoundCard aud_card;
8858ac482aSKONRAD Frederic     SWVoiceOut *amixer_output_stream;
8958ac482aSKONRAD Frederic     int16_t audio_buffer_0[AUD_CHBUF_MAX_DEPTH];
9058ac482aSKONRAD Frederic     int16_t audio_buffer_1[AUD_CHBUF_MAX_DEPTH];
9158ac482aSKONRAD Frederic     size_t audio_data_available[2];
9258ac482aSKONRAD Frederic     int64_t temp_buffer[AUD_CHBUF_MAX_DEPTH];
9358ac482aSKONRAD Frederic     int16_t out_buffer[AUD_CHBUF_MAX_DEPTH];
9458ac482aSKONRAD Frederic     size_t byte_left; /* byte available in out_buffer. */
9558ac482aSKONRAD Frederic     size_t data_ptr;  /* next byte to be sent to QEMU. */
9658ac482aSKONRAD Frederic 
9758ac482aSKONRAD Frederic     /* Associated DPDMA controller. */
9858ac482aSKONRAD Frederic     XlnxDPDMAState *dpdma;
9958ac482aSKONRAD Frederic 
10058ac482aSKONRAD Frederic     qemu_irq irq;
10158ac482aSKONRAD Frederic 
10258ac482aSKONRAD Frederic     AUXBus *aux_bus;
10358ac482aSKONRAD Frederic     Fifo8 rx_fifo;
10458ac482aSKONRAD Frederic     Fifo8 tx_fifo;
10558ac482aSKONRAD Frederic 
10658ac482aSKONRAD Frederic     /*
10758ac482aSKONRAD Frederic      * XXX: This should be in an other module.
10858ac482aSKONRAD Frederic      */
10958ac482aSKONRAD Frederic     DPCDState *dpcd;
11058ac482aSKONRAD Frederic     I2CDDCState *edid;
111*759ae1b4SSai Pavan Boddu 
112*759ae1b4SSai Pavan Boddu     ptimer_state *vblank;
113db1015e9SEduardo Habkost };
11458ac482aSKONRAD Frederic 
11558ac482aSKONRAD Frederic #define TYPE_XLNX_DP "xlnx.v-dp"
1168063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(XlnxDPState, XLNX_DP)
11758ac482aSKONRAD Frederic 
1180553d895SMarkus Armbruster #endif
119