1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pkg/devices/lib/hdmi/include/hdmi-jz4780.h Fri May 22 00:17:25 2020 +0200
1.3 @@ -0,0 +1,90 @@
1.4 +/*
1.5 + * JZ4780 HDMI peripheral support.
1.6 + *
1.7 + * Copyright (C) 2020 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#pragma once
1.26 +
1.27 +#include <l4/sys/types.h>
1.28 +#include <stdint.h>
1.29 +
1.30 +
1.31 +
1.32 +#ifdef __cplusplus
1.33 +
1.34 +#include <l4/devices/hw_mmio_register_block.h>
1.35 +
1.36 +// HDMI device control.
1.37 +
1.38 +class Hdmi_jz4780_chip
1.39 +{
1.40 +private:
1.41 + l4_addr_t _start, _end;
1.42 + l4_cap_idx_t _irq;
1.43 + Hw::Register_block<8> _regs;
1.44 +
1.45 + // Identification.
1.46 +
1.47 + uint16_t _version;
1.48 +
1.49 + // Transfer properties.
1.50 +
1.51 + bool _segment_read;
1.52 + uint8_t _device_register;
1.53 +
1.54 +protected:
1.55 + void get_identification();
1.56 +
1.57 + void int_init();
1.58 +
1.59 + void i2c_init();
1.60 + long i2c_wait();
1.61 +
1.62 +public:
1.63 + Hdmi_jz4780_chip(l4_addr_t start, l4_addr_t end, l4_cap_idx_t irq);
1.64 +
1.65 + void get_version(uint8_t *major, uint16_t *minor);
1.66 +
1.67 + int i2c_read(uint8_t *buf, unsigned int length);
1.68 + void i2c_set_address(uint8_t address);
1.69 + void i2c_set_segment(uint8_t segment);
1.70 + void i2c_set_register(uint8_t device_register);
1.71 +};
1.72 +
1.73 +#endif /* __cplusplus */
1.74 +
1.75 +
1.76 +
1.77 +/* C language interface. */
1.78 +
1.79 +EXTERN_C_BEGIN
1.80 +
1.81 +void *jz4780_hdmi_init(l4_addr_t start, l4_addr_t end, l4_cap_idx_t irq);
1.82 +
1.83 +void jz4780_hdmi_get_version(void *hdmi, uint8_t *major, uint16_t *minor);
1.84 +
1.85 +int jz4780_hdmi_i2c_read(void *hdmi, uint8_t *buf, unsigned int length);
1.86 +
1.87 +void jz4780_hdmi_i2c_set_address(void *hdmi, uint8_t address);
1.88 +
1.89 +void jz4780_hdmi_i2c_set_segment(void *hdmi, uint8_t segment);
1.90 +
1.91 +void jz4780_hdmi_i2c_set_register(void *hdmi, uint8_t device_register);
1.92 +
1.93 +EXTERN_C_END