1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#pragma once
6
7#include <assert.h>
8#include <ddk/io-buffer.h>
9#include <stdint.h>
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <ddk/device.h>
14#include <ddk/io-buffer.h>
15#include <ddk/mmio-buffer.h>
16#include <ddk/protocol/platform-device.h>
17#include <ddk/protocol/display-controller.h>
18#include <zircon/listnode.h>
19#include <zircon/types.h>
20#include <threads.h>
21
22#define DISP_ERROR(fmt, ...) zxlogf(ERROR, "[%s %d]" fmt, __func__, __LINE__, ##__VA_ARGS__)
23#define DISP_INFO(fmt, ...) zxlogf(INFO, "[%s %d]" fmt, __func__, __LINE__, ##__VA_ARGS__)
24#define DISP_TRACE  zxlogf(INFO, "[%s %d]\n", __func__, __LINE__)
25
26typedef struct {
27    zx_device_t*                        zxdev;
28    zx_device_t*                        parent;
29    platform_device_protocol_t          pdev;
30    zx_handle_t                         bti;
31
32    thrd_t                              main_thread;
33    // Lock for general display state, in particular display_id.
34    mtx_t                               display_lock;
35    // Lock for imported images.
36    mtx_t                               image_lock;
37
38    mmio_buffer_t                       mmio_dc;
39    io_buffer_t                         fbuffer;
40
41    display_controller_cb_t*            dc_cb;
42    void*                               dc_cb_ctx;
43    list_node_t                         imported_images;
44} imx8m_display_t;
45