2018-03-26 23:04:16 +00:00
|
|
|
/*
|
2018-08-05 11:40:32 +00:00
|
|
|
* Copyright (c) 2018 naehrwert
|
2022-01-20 10:09:29 +00:00
|
|
|
* Copyright (c) 2018-2022 CTCaer
|
2018-08-05 11:40:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-03-26 23:04:16 +00:00
|
|
|
|
2018-06-06 10:29:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2018-03-07 01:11:46 +00:00
|
|
|
#include "di.h"
|
2020-06-14 13:45:45 +00:00
|
|
|
#include <power/max77620.h>
|
|
|
|
#include <power/max7762x.h>
|
2020-12-28 03:21:21 +00:00
|
|
|
#include <mem/heap.h>
|
2020-06-14 13:45:45 +00:00
|
|
|
#include <soc/clock.h>
|
2021-08-28 13:38:42 +00:00
|
|
|
#include <soc/fuse.h>
|
2020-06-14 13:45:45 +00:00
|
|
|
#include <soc/gpio.h>
|
2020-06-26 19:29:52 +00:00
|
|
|
#include <soc/hw_init.h>
|
2020-06-14 13:45:45 +00:00
|
|
|
#include <soc/i2c.h>
|
|
|
|
#include <soc/pinmux.h>
|
|
|
|
#include <soc/pmc.h>
|
|
|
|
#include <soc/t210.h>
|
|
|
|
#include <utils/util.h>
|
2018-03-07 01:11:46 +00:00
|
|
|
|
|
|
|
#include "di.inl"
|
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
extern volatile nyx_storage_t *nyx_str;
|
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
static u32 _display_id = 0;
|
|
|
|
static bool _nx_aula = false;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-11-25 23:12:44 +00:00
|
|
|
static void _display_panel_and_hw_end(bool no_panel_deinit);
|
2020-04-30 10:55:26 +00:00
|
|
|
|
2018-03-07 01:11:46 +00:00
|
|
|
static void _display_dsi_wait(u32 timeout, u32 off, u32 mask)
|
|
|
|
{
|
2018-07-04 15:39:26 +00:00
|
|
|
u32 end = get_tmr_us() + timeout;
|
|
|
|
while (get_tmr_us() < end && DSI(off) & mask)
|
2018-03-07 01:11:46 +00:00
|
|
|
;
|
2018-07-04 15:39:26 +00:00
|
|
|
usleep(5);
|
2018-03-07 01:11:46 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
static void _display_dsi_send_cmd(u8 cmd, u32 param, u32 wait)
|
|
|
|
{
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = (param << 8) | cmd;
|
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
|
|
|
|
if (wait)
|
|
|
|
usleep(wait);
|
|
|
|
}
|
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
static void _display_dsi_wait_vblank(bool enable)
|
|
|
|
{
|
|
|
|
if (enable)
|
|
|
|
{
|
|
|
|
// Enable vblank interrupt.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_ENABLE)) = DC_CMD_INT_FRAME_END_INT;
|
|
|
|
|
|
|
|
// Use the 4th line to transmit the host cmd packet.
|
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = DSI_CMD_PKT_VID_ENABLE | DSI_DSI_LINE_TYPE(4);
|
|
|
|
|
|
|
|
// Wait for vblank before starting the transfer.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) = DC_CMD_INT_FRAME_END_INT; // Clear interrupt.
|
|
|
|
while (!(DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) & DC_CMD_INT_FRAME_END_INT))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Wait for vblank before reseting sync points.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) = DC_CMD_INT_FRAME_END_INT; // Clear interrupt.
|
|
|
|
while (!(DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) & DC_CMD_INT_FRAME_END_INT))
|
|
|
|
;
|
|
|
|
usleep(14);
|
|
|
|
|
|
|
|
// Reset all states of syncpt block.
|
|
|
|
DSI(_DSIREG(DSI_INCR_SYNCPT_CNTRL)) = DSI_INCR_SYNCPT_SOFT_RESET;
|
|
|
|
usleep(300); // Stabilization delay.
|
|
|
|
|
|
|
|
// Clear syncpt block reset.
|
|
|
|
DSI(_DSIREG(DSI_INCR_SYNCPT_CNTRL)) = 0;
|
|
|
|
usleep(300); // Stabilization delay.
|
|
|
|
|
|
|
|
// Restore video mode and host control.
|
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 0;
|
|
|
|
|
|
|
|
// Disable and clear vblank interrupt.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_ENABLE)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) = DC_CMD_INT_FRAME_END_INT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-02 00:09:49 +00:00
|
|
|
static void _display_dsi_read_rx_fifo(u32 *data)
|
|
|
|
{
|
|
|
|
u32 fifo_count = DSI(_DSIREG(DSI_STATUS)) & DSI_STATUS_RX_FIFO_SIZE;
|
2022-05-08 01:23:31 +00:00
|
|
|
if (fifo_count)
|
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = 0;
|
|
|
|
|
2020-12-02 00:09:49 +00:00
|
|
|
for (u32 i = 0; i < fifo_count; i++)
|
|
|
|
{
|
|
|
|
// Read or Drain RX FIFO.
|
|
|
|
if (data)
|
|
|
|
data[i] = DSI(_DSIREG(DSI_RD_DATA));
|
|
|
|
else
|
|
|
|
(void)DSI(_DSIREG(DSI_RD_DATA));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
int display_dsi_read(u8 cmd, u32 len, void *data)
|
2020-12-02 00:09:49 +00:00
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
u32 fifo[DSI_STATUS_RX_FIFO_SIZE] = {0};
|
|
|
|
|
|
|
|
// Drain RX FIFO.
|
|
|
|
_display_dsi_read_rx_fifo(NULL);
|
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
// Set reply size.
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
|
|
|
|
_display_dsi_wait(250000, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
|
|
|
|
|
|
|
|
// Request register read.
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_READ, cmd, 0);
|
|
|
|
_display_dsi_wait(250000, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
|
|
|
|
|
|
|
|
// Transfer bus control to device for transmitting the reply.
|
|
|
|
DSI(_DSIREG(DSI_HOST_CONTROL)) |= DSI_HOST_CONTROL_IMM_BTA;
|
|
|
|
|
|
|
|
// Wait for reply to complete. DSI_HOST_CONTROL_IMM_BTA bit acts as a DSI host read busy.
|
|
|
|
_display_dsi_wait(150000, _DSIREG(DSI_HOST_CONTROL), DSI_HOST_CONTROL_IMM_BTA);
|
|
|
|
|
|
|
|
// Wait a bit for the reply.
|
|
|
|
usleep(5000);
|
|
|
|
|
|
|
|
// Read RX FIFO.
|
|
|
|
_display_dsi_read_rx_fifo(fifo);
|
|
|
|
|
|
|
|
// Parse packet and copy over the data.
|
|
|
|
if ((fifo[0] & 0xFF) == DSI_ESCAPE_CMD)
|
2020-12-02 00:09:49 +00:00
|
|
|
{
|
2022-05-08 01:23:31 +00:00
|
|
|
// Act based on reply type.
|
|
|
|
switch (fifo[1] & 0xFF)
|
|
|
|
{
|
|
|
|
case GEN_LONG_RD_RES:
|
|
|
|
case DCS_LONG_RD_RES:
|
|
|
|
memcpy(data, &fifo[2], MIN((fifo[1] >> 8) & 0xFFFF, len));
|
|
|
|
break;
|
2020-12-02 00:09:49 +00:00
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
case GEN_1_BYTE_SHORT_RD_RES:
|
|
|
|
case DCS_1_BYTE_SHORT_RD_RES:
|
|
|
|
memcpy(data, &fifo[2], 1);
|
|
|
|
break;
|
2020-12-02 00:09:49 +00:00
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
case GEN_2_BYTE_SHORT_RD_RES:
|
|
|
|
case DCS_2_BYTE_SHORT_RD_RES:
|
|
|
|
memcpy(data, &fifo[2], 2);
|
|
|
|
break;
|
2020-12-02 00:09:49 +00:00
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
case ACK_ERROR_RES:
|
|
|
|
default:
|
|
|
|
res = 1;
|
|
|
|
break;
|
|
|
|
}
|
2020-12-02 00:09:49 +00:00
|
|
|
}
|
2022-05-08 01:23:31 +00:00
|
|
|
else
|
|
|
|
res = 1;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int display_dsi_vblank_read(u8 cmd, u32 len, void *data)
|
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
u32 host_control = 0;
|
|
|
|
u32 fifo[DSI_STATUS_RX_FIFO_SIZE] = {0};
|
|
|
|
|
|
|
|
// Drain RX FIFO.
|
|
|
|
_display_dsi_read_rx_fifo(NULL);
|
|
|
|
|
|
|
|
// Save host control and enable host cmd packets during video.
|
|
|
|
host_control = DSI(_DSIREG(DSI_HOST_CONTROL));
|
|
|
|
|
|
|
|
_display_dsi_wait_vblank(true);
|
2020-12-02 00:09:49 +00:00
|
|
|
|
|
|
|
// Set reply size.
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
|
2022-05-08 01:23:31 +00:00
|
|
|
_display_dsi_wait(0, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
|
2020-12-02 00:09:49 +00:00
|
|
|
|
|
|
|
// Request register read.
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_READ, cmd, 0);
|
2022-05-08 01:23:31 +00:00
|
|
|
_display_dsi_wait(0, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST | DSI_TRIGGER_VIDEO);
|
|
|
|
|
|
|
|
_display_dsi_wait_vblank(false);
|
2020-12-02 00:09:49 +00:00
|
|
|
|
|
|
|
// Transfer bus control to device for transmitting the reply.
|
2022-05-08 01:23:31 +00:00
|
|
|
DSI(_DSIREG(DSI_HOST_CONTROL)) |= DSI_HOST_CONTROL_IMM_BTA;
|
|
|
|
|
|
|
|
// Wait for reply to complete. DSI_HOST_CONTROL_IMM_BTA bit acts as a DSI host read busy.
|
2020-12-02 00:09:49 +00:00
|
|
|
_display_dsi_wait(150000, _DSIREG(DSI_HOST_CONTROL), DSI_HOST_CONTROL_IMM_BTA);
|
|
|
|
|
|
|
|
// Wait a bit for the reply.
|
|
|
|
usleep(5000);
|
|
|
|
|
|
|
|
// Read RX FIFO.
|
|
|
|
_display_dsi_read_rx_fifo(fifo);
|
|
|
|
|
|
|
|
// Parse packet and copy over the data.
|
|
|
|
if ((fifo[0] & 0xFF) == DSI_ESCAPE_CMD)
|
|
|
|
{
|
|
|
|
// Act based on reply type.
|
|
|
|
switch (fifo[1] & 0xFF)
|
|
|
|
{
|
|
|
|
case GEN_LONG_RD_RES:
|
|
|
|
case DCS_LONG_RD_RES:
|
|
|
|
memcpy(data, &fifo[2], MIN((fifo[1] >> 8) & 0xFFFF, len));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GEN_1_BYTE_SHORT_RD_RES:
|
|
|
|
case DCS_1_BYTE_SHORT_RD_RES:
|
|
|
|
memcpy(data, &fifo[2], 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GEN_2_BYTE_SHORT_RD_RES:
|
|
|
|
case DCS_2_BYTE_SHORT_RD_RES:
|
|
|
|
memcpy(data, &fifo[2], 2);
|
|
|
|
break;
|
2021-08-28 13:38:42 +00:00
|
|
|
|
2020-12-02 00:09:49 +00:00
|
|
|
case ACK_ERROR_RES:
|
|
|
|
default:
|
|
|
|
res = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-08-28 13:38:42 +00:00
|
|
|
else
|
|
|
|
res = 1;
|
2020-12-02 00:09:49 +00:00
|
|
|
|
2022-05-08 01:23:31 +00:00
|
|
|
// Restore host control.
|
|
|
|
DSI(_DSIREG(DSI_HOST_CONTROL)) = host_control;
|
2020-12-02 00:09:49 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_dsi_write(u8 cmd, u32 len, void *data, bool video_enabled)
|
|
|
|
{
|
2022-01-20 10:09:29 +00:00
|
|
|
static u32 *fifo32 = NULL;
|
2020-12-28 03:21:21 +00:00
|
|
|
u8 *fifo8;
|
2020-12-02 00:09:49 +00:00
|
|
|
u32 host_control;
|
|
|
|
|
2022-01-20 10:09:29 +00:00
|
|
|
// Allocate fifo buffer.
|
|
|
|
if (!fifo32)
|
|
|
|
fifo32 = malloc(DSI_STATUS_RX_FIFO_SIZE * 8 * sizeof(u32));
|
|
|
|
|
2020-12-02 00:09:49 +00:00
|
|
|
// Enable host cmd packets during video and save host control.
|
|
|
|
if (video_enabled)
|
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = DSI_CMD_PKT_VID_ENABLE;
|
|
|
|
host_control = DSI(_DSIREG(DSI_HOST_CONTROL));
|
|
|
|
|
|
|
|
// Enable host transfer trigger.
|
2021-08-28 13:38:42 +00:00
|
|
|
DSI(_DSIREG(DSI_HOST_CONTROL)) = host_control | DSI_HOST_CONTROL_TX_TRIG_HOST;
|
2020-12-02 00:09:49 +00:00
|
|
|
|
|
|
|
switch (len)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, cmd, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM, cmd | (*(u8 *)data << 8), 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-01-20 10:09:29 +00:00
|
|
|
memset(fifo32, 0, DSI_STATUS_RX_FIFO_SIZE * 8 * sizeof(u32));
|
2020-12-28 03:21:21 +00:00
|
|
|
fifo8 = (u8 *)fifo32;
|
2020-12-02 00:09:49 +00:00
|
|
|
fifo32[0] = (len << 8) | MIPI_DSI_DCS_LONG_WRITE;
|
|
|
|
fifo8[4] = cmd;
|
|
|
|
memcpy(&fifo8[5], data, len);
|
|
|
|
len += 4 + 1; // Increase length by CMD/length word and DCS CMD.
|
|
|
|
for (u32 i = 0; i < (ALIGN(len, 4) / 4); i++)
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = fifo32[i];
|
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for the write to happen.
|
|
|
|
_display_dsi_wait(250000, _DSIREG(DSI_TRIGGER), DSI_TRIGGER_HOST);
|
|
|
|
|
|
|
|
// Disable host cmd packets during video and restore host control.
|
|
|
|
if (video_enabled)
|
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 0;
|
|
|
|
DSI(_DSIREG(DSI_HOST_CONTROL)) = host_control;
|
|
|
|
}
|
|
|
|
|
2021-08-28 13:38:42 +00:00
|
|
|
void display_dsi_vblank_write(u8 cmd, u32 len, void *data)
|
|
|
|
{
|
2022-01-20 10:09:29 +00:00
|
|
|
static u32 *fifo32 = NULL;
|
2021-08-28 13:38:42 +00:00
|
|
|
u8 *fifo8;
|
2022-01-20 10:09:29 +00:00
|
|
|
|
|
|
|
// Allocate fifo buffer.
|
|
|
|
if (!fifo32)
|
|
|
|
fifo32 = malloc(DSI_STATUS_RX_FIFO_SIZE * 8 * sizeof(u32));
|
2021-08-28 13:38:42 +00:00
|
|
|
|
|
|
|
// Enable vblank interrupt.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_ENABLE)) = DC_CMD_INT_FRAME_END_INT;
|
|
|
|
|
|
|
|
// Use the 4th line to transmit the host cmd packet.
|
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = DSI_CMD_PKT_VID_ENABLE | DSI_DSI_LINE_TYPE(4);
|
|
|
|
|
|
|
|
// Wait for vblank before starting the transfer.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) = DC_CMD_INT_FRAME_END_INT; // Clear interrupt.
|
|
|
|
while (!(DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) & DC_CMD_INT_FRAME_END_INT))
|
|
|
|
;
|
|
|
|
|
|
|
|
switch (len)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = (cmd << 8) | MIPI_DSI_DCS_SHORT_WRITE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = ((cmd | (*(u8 *)data << 8)) << 8) | MIPI_DSI_DCS_SHORT_WRITE_PARAM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-01-20 10:09:29 +00:00
|
|
|
memset(fifo32, 0, DSI_STATUS_RX_FIFO_SIZE * 8 * sizeof(u32));
|
2021-08-28 13:38:42 +00:00
|
|
|
fifo8 = (u8 *)fifo32;
|
|
|
|
fifo32[0] = (len << 8) | MIPI_DSI_DCS_LONG_WRITE;
|
|
|
|
fifo8[4] = cmd;
|
|
|
|
memcpy(&fifo8[5], data, len);
|
|
|
|
len += 4 + 1; // Increase length by CMD/length word and DCS CMD.
|
|
|
|
for (u32 i = 0; i < (ALIGN(len, 4) / 4); i++)
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = fifo32[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for vblank before reseting sync points.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) = DC_CMD_INT_FRAME_END_INT; // Clear interrupt.
|
|
|
|
while (!(DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) & DC_CMD_INT_FRAME_END_INT))
|
|
|
|
;
|
|
|
|
|
|
|
|
// Reset all states of syncpt block.
|
|
|
|
DSI(_DSIREG(DSI_INCR_SYNCPT_CNTRL)) = DSI_INCR_SYNCPT_SOFT_RESET;
|
|
|
|
usleep(300); // Stabilization delay.
|
|
|
|
|
|
|
|
// Clear syncpt block reset.
|
|
|
|
DSI(_DSIREG(DSI_INCR_SYNCPT_CNTRL)) = 0;
|
|
|
|
usleep(300); // Stabilization delay.
|
|
|
|
|
|
|
|
// Restore video mode and host control.
|
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 0;
|
|
|
|
|
|
|
|
// Disable and clear vblank interrupt.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_ENABLE)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_INT_STATUS)) = DC_CMD_INT_FRAME_END_INT;
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:11:46 +00:00
|
|
|
void display_init()
|
|
|
|
{
|
2021-08-28 13:38:42 +00:00
|
|
|
// Get Hardware type, as it's used in various DI functions.
|
2022-05-08 01:34:44 +00:00
|
|
|
_nx_aula = fuse_read_hw_type() == FUSE_NX_HW_TYPE_AULA;
|
2021-08-28 13:38:42 +00:00
|
|
|
|
2020-04-30 10:55:26 +00:00
|
|
|
// Check if display is already initialized.
|
2020-12-28 03:21:21 +00:00
|
|
|
if (CLOCK(CLK_RST_CONTROLLER_CLK_OUT_ENB_L) & BIT(CLK_L_DISP1))
|
2020-11-25 23:12:44 +00:00
|
|
|
_display_panel_and_hw_end(true);
|
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Get Chip ID.
|
|
|
|
bool tegra_t210 = hw_get_chip_id() == GP_HIDREV_MAJOR_T210;
|
2020-04-30 10:55:26 +00:00
|
|
|
|
2020-12-11 15:25:59 +00:00
|
|
|
// T210B01: Power on SD2 regulator for supplying LDO0.
|
2020-06-26 19:29:52 +00:00
|
|
|
if (!tegra_t210)
|
|
|
|
{
|
|
|
|
// Set SD2 regulator voltage.
|
2021-01-04 00:41:15 +00:00
|
|
|
max7762x_regulator_set_voltage(REGULATOR_SD2, 1325000);
|
2020-06-26 19:29:52 +00:00
|
|
|
|
|
|
|
// Set slew rate and enable SD2 regulator.
|
|
|
|
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_SD2_CFG, (1 << MAX77620_SD_SR_SHIFT) | MAX77620_SD_CFG1_FSRADE_SD_ENABLE);
|
2021-01-04 00:41:15 +00:00
|
|
|
max7762x_regulator_enable(REGULATOR_SD2, true);
|
2020-06-26 19:29:52 +00:00
|
|
|
}
|
|
|
|
|
2022-01-28 23:26:00 +00:00
|
|
|
// Enable LCD DVDD.
|
2021-01-04 00:41:15 +00:00
|
|
|
max7762x_regulator_set_voltage(REGULATOR_LDO0, 1200000);
|
|
|
|
max7762x_regulator_enable(REGULATOR_LDO0, true);
|
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
if (tegra_t210)
|
2022-01-28 23:26:00 +00:00
|
|
|
max77620_config_gpio(7, MAX77620_GPIO_OUTPUT_ENABLE); // T210: LD0 -> GPIO7 -> LCD.
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Enable Display Interface specific clocks.
|
2020-07-17 13:50:17 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_RST_DEV_H_CLR) = BIT(CLK_H_MIPI_CAL) | BIT(CLK_H_DSI);
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_H_SET) = BIT(CLK_H_MIPI_CAL) | BIT(CLK_H_DSI);
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_RST_DEV_L_CLR) = BIT(CLK_L_HOST1X) | BIT(CLK_L_DISP1);
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_SET) = BIT(CLK_L_HOST1X) | BIT(CLK_L_DISP1);
|
2019-09-12 20:08:38 +00:00
|
|
|
|
2020-07-17 13:50:17 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_X_SET) = BIT(CLK_X_UART_FST_MIPI_CAL);
|
2019-09-12 20:08:38 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_UART_FST_MIPI_CAL) = 10; // Set PLLP_OUT3 and div 6 (17MHz).
|
|
|
|
|
2020-07-17 13:50:17 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_W_SET) = BIT(CLK_W_DSIA_LP);
|
2020-06-26 19:29:52 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_DSIA_LP) = 10; // Set PLLP_OUT and div 6 (68MHz).
|
2019-09-12 20:08:38 +00:00
|
|
|
|
2020-11-25 23:41:45 +00:00
|
|
|
// Bring every IO rail out of deep power down.
|
|
|
|
PMC(APBDEV_PMC_IO_DPD_REQ) = PMC_IO_DPD_REQ_DPD_OFF;
|
|
|
|
PMC(APBDEV_PMC_IO_DPD2_REQ) = PMC_IO_DPD_REQ_DPD_OFF;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Configure LCD pins.
|
2020-07-17 13:50:17 +00:00
|
|
|
PINMUX_AUX(PINMUX_AUX_NFC_EN) &= ~PINMUX_TRISTATE; // PULL_DOWN
|
|
|
|
PINMUX_AUX(PINMUX_AUX_NFC_INT) &= ~PINMUX_TRISTATE; // PULL_DOWN
|
2020-06-26 19:29:52 +00:00
|
|
|
PINMUX_AUX(PINMUX_AUX_LCD_RST) &= ~PINMUX_TRISTATE; // PULL_DOWN
|
|
|
|
|
|
|
|
// Configure Backlight pins.
|
2020-04-30 10:45:28 +00:00
|
|
|
PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) &= ~PINMUX_TRISTATE; // PULL_DOWN | 1
|
2020-07-17 13:50:17 +00:00
|
|
|
PINMUX_AUX(PINMUX_AUX_LCD_BL_EN) &= ~PINMUX_TRISTATE; // PULL_DOWN
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
if (_nx_aula)
|
2021-08-28 13:38:42 +00:00
|
|
|
{
|
|
|
|
// Configure LCD RST pin.
|
|
|
|
gpio_config(GPIO_PORT_V, GPIO_PIN_2, GPIO_MODE_GPIO);
|
|
|
|
gpio_output_enable(GPIO_PORT_V, GPIO_PIN_2, GPIO_OUTPUT_ENABLE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-28 23:26:00 +00:00
|
|
|
// Set LCD AVDD pins mode and direction
|
2021-08-28 13:38:42 +00:00
|
|
|
gpio_config(GPIO_PORT_I, GPIO_PIN_0 | GPIO_PIN_1, GPIO_MODE_GPIO);
|
|
|
|
gpio_output_enable(GPIO_PORT_I, GPIO_PIN_0 | GPIO_PIN_1, GPIO_OUTPUT_ENABLE);
|
|
|
|
|
2022-01-28 23:26:00 +00:00
|
|
|
// Enable LCD AVDD.
|
|
|
|
gpio_write(GPIO_PORT_I, GPIO_PIN_0, GPIO_HIGH); // LCD AVDD +5.4V enable.
|
2021-08-28 13:38:42 +00:00
|
|
|
usleep(10000);
|
2022-01-28 23:26:00 +00:00
|
|
|
gpio_write(GPIO_PORT_I, GPIO_PIN_1, GPIO_HIGH); // LCD AVDD -5.4V enable.
|
2021-08-28 13:38:42 +00:00
|
|
|
usleep(10000);
|
|
|
|
|
|
|
|
// Configure Backlight PWM/EN and LCD RST pins (BL PWM, BL EN, LCD RST).
|
|
|
|
gpio_config(GPIO_PORT_V, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_MODE_GPIO);
|
|
|
|
gpio_output_enable(GPIO_PORT_V, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_OUTPUT_ENABLE);
|
|
|
|
|
|
|
|
// Enable Backlight power.
|
|
|
|
gpio_write(GPIO_PORT_V, GPIO_PIN_1, GPIO_HIGH);
|
|
|
|
}
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Power up supply regulator for display interface.
|
2020-04-30 10:45:28 +00:00
|
|
|
MIPI_CAL(_DSIREG(MIPI_CAL_MIPI_BIAS_PAD_CFG2)) = 0;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
if (!tegra_t210)
|
|
|
|
{
|
|
|
|
MIPI_CAL(_DSIREG(MIPI_CAL_MIPI_BIAS_PAD_CFG0)) = 0;
|
|
|
|
APB_MISC(APB_MISC_GP_DSI_PAD_CONTROL) = 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 10:45:28 +00:00
|
|
|
// Set DISP1 clock source and parent clock.
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_DISP1) = 0x40000000; // PLLD_OUT.
|
2020-12-28 03:21:21 +00:00
|
|
|
u32 plld_div = (3 << 20) | (20 << 11) | 1; // DIVM: 1, DIVN: 20, DIVP: 3. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 97.5 MHz (offset).
|
2020-04-30 10:45:28 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div;
|
2019-09-12 20:08:38 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
if (tegra_t210)
|
|
|
|
{
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20; // PLLD_SETUP.
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2D0AAA; // PLLD_ENABLE_CLK.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0;
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2DFC00; // PLLD_ENABLE_CLK.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup Display Interface initial window configuration.
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_dc_setup_win_config, CFG_SIZE(_di_dc_setup_win_config));
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
// Setup dsi init sequence packets.
|
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_irq_pkt_config0, CFG_SIZE(_di_dsi_init_irq_pkt_config0));
|
2020-06-26 19:29:52 +00:00
|
|
|
if (tegra_t210)
|
|
|
|
DSI(_DSIREG(DSI_INIT_SEQ_DATA_15)) = 0;
|
|
|
|
else
|
|
|
|
DSI(_DSIREG(DSI_INIT_SEQ_DATA_15_B01)) = 0;
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_irq_pkt_config1, CFG_SIZE(_di_dsi_init_irq_pkt_config1));
|
|
|
|
|
|
|
|
// Reset pad trimmers for T210B01.
|
2020-06-26 19:29:52 +00:00
|
|
|
if (!tegra_t210)
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_pads_t210b01, CFG_SIZE(_di_dsi_init_pads_t210b01));
|
|
|
|
|
|
|
|
// Setup init sequence packets and timings.
|
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_timing_pkt_config2, CFG_SIZE(_di_dsi_init_timing_pkt_config2));
|
|
|
|
DSI(_DSIREG(DSI_PHY_TIMING_0)) = tegra_t210 ? 0x6070601 : 0x6070603; // DSI_THSPREPR: 1 : 3.
|
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_timing_pwrctrl_config, CFG_SIZE(_di_dsi_init_timing_pwrctrl_config));
|
|
|
|
DSI(_DSIREG(DSI_PHY_TIMING_0)) = tegra_t210 ? 0x6070601 : 0x6070603; // DSI_THSPREPR: 1 : 3.
|
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_timing_pkt_config3, CFG_SIZE(_di_dsi_init_timing_pkt_config3));
|
2018-07-04 15:39:26 +00:00
|
|
|
usleep(10000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Enable LCD Reset.
|
2019-09-12 20:08:38 +00:00
|
|
|
gpio_write(GPIO_PORT_V, GPIO_PIN_2, GPIO_HIGH);
|
2018-07-04 15:39:26 +00:00
|
|
|
usleep(60000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Setup DSI device takeover timeout.
|
2022-05-08 01:34:44 +00:00
|
|
|
DSI(_DSIREG(DSI_BTA_TIMING)) = _nx_aula ? 0x40103 : 0x50204;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2020-12-02 00:09:49 +00:00
|
|
|
// Get Display ID.
|
2021-08-28 13:38:42 +00:00
|
|
|
_display_id = 0xCCCCCC;
|
|
|
|
for (u32 i = 0; i < 3; i++)
|
|
|
|
{
|
2022-05-08 01:23:31 +00:00
|
|
|
if (!display_dsi_read(MIPI_DCS_GET_DISPLAY_ID, 3, &_display_id))
|
2021-08-28 13:38:42 +00:00
|
|
|
break;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2021-08-28 13:38:42 +00:00
|
|
|
usleep(10000);
|
|
|
|
}
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
// Save raw Display ID to Nyx storage.
|
|
|
|
nyx_str->info.disp_id = _display_id;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
// Decode Display ID.
|
|
|
|
_display_id = ((_display_id >> 8) & 0xFF00) | (_display_id & 0xFF);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-13 15:16:29 +00:00
|
|
|
if ((_display_id & 0xFF) == PANEL_JDI_XXX062M)
|
|
|
|
_display_id = PANEL_JDI_XXX062M;
|
2020-04-30 10:49:03 +00:00
|
|
|
|
2021-08-28 13:38:42 +00:00
|
|
|
// For Aula ensure that we have a compatible panel id.
|
2022-05-08 01:34:44 +00:00
|
|
|
if (_nx_aula && _display_id == 0xCCCC)
|
2021-10-15 13:07:18 +00:00
|
|
|
_display_id = PANEL_SAM_AMS699VC01;
|
2021-08-28 13:38:42 +00:00
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
// Initialize display panel.
|
|
|
|
switch (_display_id)
|
|
|
|
{
|
2021-10-15 13:07:18 +00:00
|
|
|
case PANEL_SAM_AMS699VC01:
|
2021-08-28 13:38:42 +00:00
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 180000);
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0xA0, 0); // Write 0 to 0xA0.
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM, MIPI_DCS_SET_CONTROL_DISPLAY | (DCS_CONTROL_DISPLAY_BRIGHTNESS_CTRL << 8), 0); // Enable brightness control.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x339; // MIPI_DSI_DCS_LONG_WRITE: 3 bytes.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x000051; // MIPI_DCS_SET_BRIGHTNESS 0000: 0%. FF07: 100%.
|
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
usleep(5000);
|
|
|
|
break;
|
|
|
|
|
2020-06-13 15:16:29 +00:00
|
|
|
case PANEL_JDI_XXX062M:
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_panel_init_config_jdi, CFG_SIZE(_di_dsi_panel_init_config_jdi));
|
2020-04-30 10:49:03 +00:00
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 180000);
|
|
|
|
break;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
case PANEL_INL_P062CCA_AZ1:
|
|
|
|
case PANEL_AUO_A062TAN01:
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 180000);
|
2020-06-26 19:29:52 +00:00
|
|
|
|
|
|
|
// Unlock extension cmds.
|
2020-04-30 10:49:03 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x439; // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
|
2020-06-26 19:29:52 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x9483FFB9; // MIPI_DCS_PRIV_SET_EXTC. (Pass: FF 83 94).
|
2020-04-30 10:49:03 +00:00
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
usleep(5000);
|
2020-06-26 19:29:52 +00:00
|
|
|
|
|
|
|
// Set Power control.
|
2020-04-30 10:49:03 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x739; // MIPI_DSI_DCS_LONG_WRITE: 7 bytes.
|
|
|
|
if (_display_id == PANEL_INL_P062CCA_AZ1)
|
2020-06-26 19:29:52 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x751548B1; // MIPI_DCS_PRIV_SET_POWER_CONTROL. (Not deep standby, BT5 / XDK, VRH gamma volt adj 53 / x40).
|
|
|
|
else // PANEL_AUO_A062TAN01.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x711148B1; // MIPI_DCS_PRIV_SET_POWER_CONTROL. (Not deep standby, BT1 / XDK, VRH gamma volt adj 49 / x40).
|
2020-04-30 10:49:03 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x143209; // (NVRH gamma volt adj 9, Amplifier current small / x30, FS0 freq Fosc/80 / FS1 freq Fosc/32).
|
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
usleep(5000);
|
|
|
|
break;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2020-07-17 13:57:45 +00:00
|
|
|
case PANEL_INL_2J055IA_27A:
|
|
|
|
case PANEL_AUO_A055TAN01:
|
2020-12-01 23:53:00 +00:00
|
|
|
case PANEL_V40_55_UNK:
|
2020-04-30 10:49:03 +00:00
|
|
|
default: // Allow spare part displays to work.
|
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_EXIT_SLEEP_MODE, 120000);
|
|
|
|
break;
|
|
|
|
}
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Unblank display.
|
2020-04-30 10:49:03 +00:00
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_SET_DISPLAY_ON, 20000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Configure PLLD for DISP1.
|
2021-08-28 13:38:42 +00:00
|
|
|
plld_div = (1 << 20) | (24 << 11) | 1; // DIVM: 1, DIVN: 24, DIVP: 1. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 234 MHz (offset, it's ddr btw, so normally div2).
|
2020-04-30 10:45:28 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
|
|
|
if (tegra_t210)
|
2020-12-28 03:21:21 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20; // PLLD_SETUP.
|
2020-06-26 19:29:52 +00:00
|
|
|
else
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0;
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2DFC00; // Use new PLLD_SDM_DIN.
|
2019-09-12 20:08:38 +00:00
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
// Finalize DSI init packet sequence configuration.
|
2020-06-26 19:29:52 +00:00
|
|
|
DSI(_DSIREG(DSI_PAD_CONTROL_1)) = 0;
|
|
|
|
DSI(_DSIREG(DSI_PHY_TIMING_0)) = tegra_t210 ? 0x6070601 : 0x6070603;
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_init_seq_pkt_final_config, CFG_SIZE(_di_dsi_init_seq_pkt_final_config));
|
|
|
|
|
|
|
|
// Set 1-by-1 pixel/clock and pixel clock to 234 / 3 = 78 MHz. For 60 Hz refresh rate.
|
2020-10-23 03:32:24 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_DISP_DISP_CLOCK_CONTROL)) = PIXEL_CLK_DIVIDER_PCD1 | SHIFT_CLK_DIVIDER(4); // 4: div3.
|
2022-05-08 01:34:44 +00:00
|
|
|
|
|
|
|
// Set DSI mode.
|
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_mode_config, CFG_SIZE(_di_dsi_mode_config));
|
2018-07-04 15:39:26 +00:00
|
|
|
usleep(10000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Calibrate display communication pads.
|
2022-05-08 01:34:44 +00:00
|
|
|
u32 loops = tegra_t210 ? 1 : 2; // Calibrate pads 2 times on T210B01.
|
|
|
|
exec_cfg((u32 *)MIPI_CAL_BASE, _di_mipi_pad_cal_config, CFG_SIZE(_di_mipi_pad_cal_config));
|
2020-06-26 19:29:52 +00:00
|
|
|
for (u32 i = 0; i < loops; i++)
|
|
|
|
{
|
|
|
|
// Set MIPI bias pad config.
|
|
|
|
MIPI_CAL(_DSIREG(MIPI_CAL_MIPI_BIAS_PAD_CFG2)) = 0x10010;
|
|
|
|
MIPI_CAL(_DSIREG(MIPI_CAL_MIPI_BIAS_PAD_CFG1)) = tegra_t210 ? 0x300 : 0;
|
|
|
|
|
|
|
|
// Set pad trimmers and set MIPI DSI cal offsets.
|
|
|
|
if (tegra_t210)
|
|
|
|
{
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_pad_cal_config_t210, CFG_SIZE(_di_dsi_pad_cal_config_t210));
|
|
|
|
exec_cfg((u32 *)MIPI_CAL_BASE, _di_mipi_dsi_cal_offsets_config_t210, CFG_SIZE(_di_mipi_dsi_cal_offsets_config_t210));
|
2020-06-26 19:29:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_pad_cal_config_t210b01, CFG_SIZE(_di_dsi_pad_cal_config_t210b01));
|
|
|
|
exec_cfg((u32 *)MIPI_CAL_BASE, _di_mipi_dsi_cal_offsets_config_t210b01, CFG_SIZE(_di_mipi_dsi_cal_offsets_config_t210b01));
|
2020-06-26 19:29:52 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
// Reset all MIPI cal offsets and start calibration.
|
|
|
|
exec_cfg((u32 *)MIPI_CAL_BASE, _di_mipi_start_dsi_cal_config, CFG_SIZE(_di_mipi_start_dsi_cal_config));
|
2020-06-26 19:29:52 +00:00
|
|
|
}
|
2018-07-04 15:39:26 +00:00
|
|
|
usleep(10000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Enable video display controller.
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_dc_video_enable_config, CFG_SIZE(_di_dc_video_enable_config));
|
2018-03-07 01:11:46 +00:00
|
|
|
}
|
|
|
|
|
2018-09-18 21:01:42 +00:00
|
|
|
void display_backlight_pwm_init()
|
|
|
|
{
|
2021-10-15 13:07:18 +00:00
|
|
|
if (_display_id == PANEL_SAM_AMS699VC01)
|
2021-08-28 13:38:42 +00:00
|
|
|
return;
|
|
|
|
|
2018-09-18 21:01:42 +00:00
|
|
|
clock_enable_pwm();
|
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
PWM(PWM_CONTROLLER_PWM_CSR_0) = PWM_CSR_EN; // Enable PWM and set it to 25KHz PFM. 29.5KHz is stock.
|
2018-09-18 21:01:42 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) = (PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) & ~PINMUX_FUNC_MASK) | 1; // Set PWM0 mode.
|
2018-09-18 21:01:42 +00:00
|
|
|
gpio_config(GPIO_PORT_V, GPIO_PIN_0, GPIO_MODE_SPIO); // Backlight power mode.
|
|
|
|
}
|
|
|
|
|
2018-08-13 09:12:53 +00:00
|
|
|
void display_backlight(bool enable)
|
2018-06-06 10:29:38 +00:00
|
|
|
{
|
2018-09-18 21:01:42 +00:00
|
|
|
gpio_write(GPIO_PORT_V, GPIO_PIN_0, enable ? GPIO_HIGH : GPIO_LOW); // Backlight PWM GPIO.
|
|
|
|
}
|
|
|
|
|
2021-08-28 13:38:42 +00:00
|
|
|
void display_dsi_backlight_brightness(u32 brightness)
|
|
|
|
{
|
2021-10-15 13:16:24 +00:00
|
|
|
// Normalize brightness value by 82% and a base of 45 duty.
|
|
|
|
if (brightness)
|
|
|
|
brightness = (brightness * PANEL_OLED_BL_COEFF / 100) + PANEL_OLED_BL_OFFSET;
|
|
|
|
|
2021-08-28 13:38:42 +00:00
|
|
|
u16 bl_ctrl = byte_swap_16((u16)(brightness * 8));
|
|
|
|
display_dsi_vblank_write(MIPI_DCS_SET_BRIGHTNESS, 2, &bl_ctrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_pwm_backlight_brightness(u32 brightness, u32 step_delay)
|
2018-09-18 21:01:42 +00:00
|
|
|
{
|
2019-04-13 23:19:04 +00:00
|
|
|
u32 old_value = (PWM(PWM_CONTROLLER_PWM_CSR_0) >> 16) & 0xFF;
|
2018-09-18 21:01:42 +00:00
|
|
|
if (brightness == old_value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (old_value < brightness)
|
|
|
|
{
|
|
|
|
for (u32 i = old_value; i < brightness + 1; i++)
|
|
|
|
{
|
2021-08-28 13:38:42 +00:00
|
|
|
PWM(PWM_CONTROLLER_PWM_CSR_0) = PWM_CSR_EN | (i << 16);
|
2018-09-18 21:01:42 +00:00
|
|
|
usleep(step_delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (u32 i = old_value; i > brightness; i--)
|
|
|
|
{
|
2021-08-28 13:38:42 +00:00
|
|
|
PWM(PWM_CONTROLLER_PWM_CSR_0) = PWM_CSR_EN | (i << 16);
|
2018-09-18 21:01:42 +00:00
|
|
|
usleep(step_delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!brightness)
|
2019-04-13 23:19:04 +00:00
|
|
|
PWM(PWM_CONTROLLER_PWM_CSR_0) = 0;
|
2018-06-06 10:29:38 +00:00
|
|
|
}
|
|
|
|
|
2021-08-28 13:38:42 +00:00
|
|
|
void display_backlight_brightness(u32 brightness, u32 step_delay)
|
|
|
|
{
|
|
|
|
if (brightness > 255)
|
|
|
|
brightness = 255;
|
|
|
|
|
2021-10-15 13:07:18 +00:00
|
|
|
if (_display_id != PANEL_SAM_AMS699VC01)
|
2021-08-28 13:38:42 +00:00
|
|
|
display_pwm_backlight_brightness(brightness, step_delay);
|
|
|
|
else
|
|
|
|
display_dsi_backlight_brightness(brightness);
|
|
|
|
}
|
|
|
|
|
2021-04-11 06:16:55 +00:00
|
|
|
u32 display_get_backlight_brightness()
|
|
|
|
{
|
|
|
|
return ((PWM(PWM_CONTROLLER_PWM_CSR_0) >> 16) & 0xFF);
|
|
|
|
}
|
|
|
|
|
2020-11-25 23:12:44 +00:00
|
|
|
static void _display_panel_and_hw_end(bool no_panel_deinit)
|
2018-03-07 01:11:46 +00:00
|
|
|
{
|
2020-11-25 23:12:44 +00:00
|
|
|
if (no_panel_deinit)
|
|
|
|
goto skip_panel_deinit;
|
|
|
|
|
2018-09-18 21:01:42 +00:00
|
|
|
display_backlight_brightness(0, 1000);
|
2018-06-15 11:28:27 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Enable host cmd packets during video.
|
2020-04-30 10:45:28 +00:00
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = DSI_CMD_PKT_VID_ENABLE;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
|
|
|
// Blank display.
|
2020-11-25 23:41:45 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = (MIPI_DCS_SET_DISPLAY_OFF << 8) | MIPI_DSI_DCS_SHORT_WRITE;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Propagate changes to all register buffers and disable host cmd packets during video.
|
2018-05-13 22:59:45 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_ACCESS)) = READ_MUX | WRITE_MUX;
|
2020-06-26 19:29:52 +00:00
|
|
|
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 0;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// De-initialize video controller.
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_dc_video_disable_config, CFG_SIZE(_di_dc_video_disable_config));
|
|
|
|
|
|
|
|
// Set timings for lowpower clocks.
|
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_timing_deinit_config, CFG_SIZE(_di_dsi_timing_deinit_config));
|
2021-08-28 13:38:42 +00:00
|
|
|
|
2021-10-15 13:07:18 +00:00
|
|
|
if (_display_id != PANEL_SAM_AMS699VC01)
|
2021-08-28 13:38:42 +00:00
|
|
|
usleep(10000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// De-initialize display panel.
|
2020-04-30 10:49:03 +00:00
|
|
|
switch (_display_id)
|
|
|
|
{
|
2020-06-13 15:16:29 +00:00
|
|
|
case PANEL_JDI_XXX062M:
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_panel_deinit_config_jdi, CFG_SIZE(_di_dsi_panel_deinit_config_jdi));
|
2020-04-30 10:49:03 +00:00
|
|
|
break;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
case PANEL_AUO_A062TAN01:
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DSI_BASE, _di_dsi_panel_deinit_config_auo, CFG_SIZE(_di_dsi_panel_deinit_config_auo));
|
2020-04-30 10:49:03 +00:00
|
|
|
break;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2020-07-17 13:57:45 +00:00
|
|
|
case PANEL_INL_2J055IA_27A:
|
|
|
|
case PANEL_AUO_A055TAN01:
|
2020-12-01 23:53:00 +00:00
|
|
|
case PANEL_V40_55_UNK:
|
2020-06-26 19:29:52 +00:00
|
|
|
// Unlock extension cmds.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x439; // MIPI_DSI_DCS_LONG_WRITE: 4 bytes.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x9483FFB9; // MIPI_DCS_PRIV_SET_EXTC. (Pass: FF 83 94).
|
2020-04-30 10:49:03 +00:00
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
usleep(5000);
|
2020-06-26 19:29:52 +00:00
|
|
|
|
|
|
|
// Set Power control.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0xB39; // MIPI_DSI_DCS_LONG_WRITE: 11 bytes.
|
2020-07-17 13:57:45 +00:00
|
|
|
if (_display_id == PANEL_INL_2J055IA_27A)
|
2020-06-26 19:29:52 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x751548B1; // MIPI_DCS_PRIV_SET_POWER_CONTROL. (Not deep standby, BT5 / XDK, VRH gamma volt adj 53 / x40).
|
2020-12-01 23:53:00 +00:00
|
|
|
else if (_display_id == PANEL_AUO_A055TAN01)
|
2020-06-26 19:29:52 +00:00
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x711148B1; // MIPI_DCS_PRIV_SET_POWER_CONTROL. (Not deep standby, BT1 / XDK, VRH gamma volt adj 49 / x40).
|
2020-12-01 23:53:00 +00:00
|
|
|
else // PANEL_V40_55_UNK.
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x731348B1; // MIPI_DCS_PRIV_SET_POWER_CONTROL. (Not deep standby, BT3 / XDK, VRH gamma volt adj 51 / x40).
|
|
|
|
if (_display_id == PANEL_INL_2J055IA_27A || _display_id == PANEL_AUO_A055TAN01)
|
|
|
|
{
|
|
|
|
// (NVRH gamma volt adj 9, Amplifier current small / x30, FS0 freq Fosc/80 / FS1 freq Fosc/32, Enter standby / PON / VCOMG).
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x71143209;
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x114D31; // (Unknown).
|
|
|
|
}
|
|
|
|
else // PANEL_V40_55_UNK.
|
|
|
|
{
|
|
|
|
// (NVRH gamma volt adj 9, Amplifier current small / x30, FS0 freq Fosc/80 / FS1 freq Fosc/48, Enter standby / PON / VCOMG).
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x71243209;
|
|
|
|
DSI(_DSIREG(DSI_WR_DATA)) = 0x004C31; // (Unknown).
|
|
|
|
}
|
2020-04-30 10:49:03 +00:00
|
|
|
DSI(_DSIREG(DSI_TRIGGER)) = DSI_TRIGGER_HOST;
|
|
|
|
usleep(5000);
|
|
|
|
break;
|
2020-06-26 19:29:52 +00:00
|
|
|
|
2020-04-30 10:49:03 +00:00
|
|
|
case PANEL_INL_P062CCA_AZ1:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Blank - powerdown.
|
2021-08-28 13:38:42 +00:00
|
|
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_ENTER_SLEEP_MODE,
|
2021-10-15 13:07:18 +00:00
|
|
|
(_display_id == PANEL_SAM_AMS699VC01) ? 120000 : 50000);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-11-25 23:12:44 +00:00
|
|
|
skip_panel_deinit:
|
2020-06-26 19:29:52 +00:00
|
|
|
// Disable LCD power pins.
|
2021-08-28 13:38:42 +00:00
|
|
|
gpio_write(GPIO_PORT_V, GPIO_PIN_2, GPIO_LOW); // LCD Reset disable.
|
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
if (!_nx_aula) // HOS uses panel id.
|
2021-08-28 13:38:42 +00:00
|
|
|
{
|
|
|
|
usleep(10000);
|
2022-01-28 23:26:00 +00:00
|
|
|
gpio_write(GPIO_PORT_I, GPIO_PIN_1, GPIO_LOW); // LCD AVDD -5.4V disable.
|
2021-08-28 13:38:42 +00:00
|
|
|
usleep(10000);
|
2022-01-28 23:26:00 +00:00
|
|
|
gpio_write(GPIO_PORT_I, GPIO_PIN_0, GPIO_LOW); // LCD AVDD +5.4V disable.
|
2021-08-28 13:38:42 +00:00
|
|
|
usleep(10000);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
usleep(30000); // Aula Panel.
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Disable Display Interface specific clocks.
|
2020-07-17 13:50:17 +00:00
|
|
|
CLOCK(CLK_RST_CONTROLLER_RST_DEV_H_SET) = BIT(CLK_H_MIPI_CAL) | BIT(CLK_H_DSI);
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_H_CLR) = BIT(CLK_H_MIPI_CAL) | BIT(CLK_H_DSI);
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_RST_DEV_L_SET) = BIT(CLK_L_HOST1X) | BIT(CLK_L_DISP1);
|
|
|
|
CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_CLR) = BIT(CLK_L_HOST1X) | BIT(CLK_L_DISP1);
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2019-09-12 20:08:38 +00:00
|
|
|
// Power down pads.
|
2018-05-13 22:59:45 +00:00
|
|
|
DSI(_DSIREG(DSI_PAD_CONTROL_0)) = DSI_PAD_CONTROL_VS1_PULLDN_CLK | DSI_PAD_CONTROL_VS1_PULLDN(0xF) | DSI_PAD_CONTROL_VS1_PDIO_CLK | DSI_PAD_CONTROL_VS1_PDIO(0xF);
|
2018-08-13 09:12:53 +00:00
|
|
|
DSI(_DSIREG(DSI_POWER_CONTROL)) = 0;
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2020-06-26 19:29:52 +00:00
|
|
|
// Switch LCD PWM backlight pin to special function mode and enable PWM0 mode.
|
2022-05-08 01:34:44 +00:00
|
|
|
if (!_nx_aula)
|
2021-08-28 13:38:42 +00:00
|
|
|
{
|
|
|
|
gpio_config(GPIO_PORT_V, GPIO_PIN_0, GPIO_MODE_SPIO); // Backlight PWM.
|
|
|
|
PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) = (PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) & ~PINMUX_TRISTATE) | PINMUX_TRISTATE;
|
|
|
|
PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) = (PINMUX_AUX(PINMUX_AUX_LCD_BL_PWM) & ~PINMUX_FUNC_MASK) | 1; // Set PWM0 mode.
|
|
|
|
}
|
2018-03-07 01:11:46 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 23:12:44 +00:00
|
|
|
void display_end() { _display_panel_and_hw_end(false); };
|
|
|
|
|
2020-12-11 15:25:59 +00:00
|
|
|
u16 display_get_decoded_panel_id()
|
2020-12-01 23:53:00 +00:00
|
|
|
{
|
|
|
|
return _display_id;
|
|
|
|
}
|
|
|
|
|
2020-12-11 15:49:06 +00:00
|
|
|
void display_set_decoded_panel_id(u32 id)
|
|
|
|
{
|
2021-08-28 13:38:42 +00:00
|
|
|
// Get Hardware type, as it's used in various DI functions.
|
2022-05-08 01:34:44 +00:00
|
|
|
_nx_aula = fuse_read_hw_type() == FUSE_NX_HW_TYPE_AULA;
|
2021-08-28 13:38:42 +00:00
|
|
|
|
2020-12-11 15:49:06 +00:00
|
|
|
// Decode Display ID.
|
|
|
|
_display_id = ((id >> 8) & 0xFF00) | (id & 0xFF);
|
|
|
|
|
|
|
|
if ((_display_id & 0xFF) == PANEL_JDI_XXX062M)
|
|
|
|
_display_id = PANEL_JDI_XXX062M;
|
2021-08-28 13:38:42 +00:00
|
|
|
|
|
|
|
// For Aula ensure that we have a compatible panel id.
|
2022-05-08 01:34:44 +00:00
|
|
|
if (_nx_aula && _display_id == 0xCCCC)
|
2021-10-15 13:07:18 +00:00
|
|
|
_display_id = PANEL_SAM_AMS699VC01;
|
2020-12-11 15:49:06 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:11:46 +00:00
|
|
|
void display_color_screen(u32 color)
|
|
|
|
{
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_win_one_color, CFG_SIZE(_di_win_one_color));
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2018-08-05 11:40:32 +00:00
|
|
|
// Configure display to show single color.
|
2018-03-07 01:11:46 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_WIN_AD_WIN_OPTIONS)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_BD_WIN_OPTIONS)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_CD_WIN_OPTIONS)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_BLEND_BACKGROUND_COLOR)) = color;
|
2018-06-08 09:42:24 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = (DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) & 0xFFFFFFFE) | GENERAL_ACT_REQ;
|
2022-01-28 23:26:00 +00:00
|
|
|
usleep(35000); // Wait 2 frames. No need on Aula.
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2021-10-15 13:07:18 +00:00
|
|
|
if (_display_id != PANEL_SAM_AMS699VC01)
|
2021-08-28 13:38:42 +00:00
|
|
|
display_backlight(true);
|
|
|
|
else
|
|
|
|
display_backlight_brightness(255, 0);
|
2018-03-07 01:11:46 +00:00
|
|
|
}
|
|
|
|
|
2020-06-13 15:16:29 +00:00
|
|
|
u32 *display_init_framebuffer_pitch()
|
2018-03-07 01:11:46 +00:00
|
|
|
{
|
2018-08-05 11:40:32 +00:00
|
|
|
// Sanitize framebuffer area.
|
2022-01-20 10:12:19 +00:00
|
|
|
memset((u32 *)IPL_FB_ADDRESS, 0, IPL_FB_SZ);
|
2019-12-08 00:23:03 +00:00
|
|
|
|
2022-05-08 01:34:44 +00:00
|
|
|
// This configures the framebuffer @ IPL_FB_ADDRESS with a resolution of 720x1280 (line stride 720).
|
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_win_framebuffer_pitch, CFG_SIZE(_di_win_framebuffer_pitch));
|
2022-01-28 23:26:00 +00:00
|
|
|
//usleep(35000); // Wait 2 frames. No need on Aula.
|
2018-03-07 01:11:46 +00:00
|
|
|
|
2022-01-20 10:12:19 +00:00
|
|
|
return (u32 *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR));
|
2018-03-07 01:11:46 +00:00
|
|
|
}
|
2019-09-12 20:08:38 +00:00
|
|
|
|
2020-06-13 15:16:29 +00:00
|
|
|
u32 *display_init_framebuffer_pitch_inv()
|
|
|
|
{
|
2022-05-08 01:34:44 +00:00
|
|
|
// This configures the framebuffer @ NYX_FB_ADDRESS with a resolution of 720x1280 (line stride 720).
|
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_win_framebuffer_pitch_inv, CFG_SIZE(_di_win_framebuffer_pitch_inv));
|
2022-01-28 23:26:00 +00:00
|
|
|
usleep(35000); // Wait 2 frames. No need on Aula.
|
2020-06-13 15:16:29 +00:00
|
|
|
|
2022-01-20 10:12:19 +00:00
|
|
|
return (u32 *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR));
|
2020-06-13 15:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 *display_init_framebuffer_block()
|
|
|
|
{
|
2022-05-08 01:34:44 +00:00
|
|
|
// This configures the framebuffer @ NYX_FB_ADDRESS with a resolution of 720x1280.
|
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_win_framebuffer_block, CFG_SIZE(_di_win_framebuffer_block));
|
2022-01-28 23:26:00 +00:00
|
|
|
usleep(35000); // Wait 2 frames. No need on Aula.
|
2020-06-13 15:16:29 +00:00
|
|
|
|
2022-01-20 10:12:19 +00:00
|
|
|
return (u32 *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR));
|
2020-06-13 15:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 *display_init_framebuffer_log()
|
|
|
|
{
|
|
|
|
// This configures the framebuffer @ LOG_FB_ADDRESS with a resolution of 1280x720 (line stride 720).
|
2022-05-08 01:34:44 +00:00
|
|
|
exec_cfg((u32 *)DISPLAY_A_BASE, _di_win_framebuffer_log, CFG_SIZE(_di_win_framebuffer_log));
|
2020-06-13 15:16:29 +00:00
|
|
|
|
2022-01-20 10:12:19 +00:00
|
|
|
return (u32 *)DISPLAY_A(_DIREG(DC_WINBUF_START_ADDR));
|
2020-06-13 15:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void display_activate_console()
|
|
|
|
{
|
2020-11-25 23:41:45 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = WINDOW_D_SELECT; // Select window D.
|
2020-06-13 15:16:29 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_WIN_WIN_OPTIONS)) = WIN_ENABLE; // Enable window DD.
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_POSITION)) = 0xFF80;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
|
|
|
|
|
|
|
|
for (u32 i = 0xFF80; i < 0x10000; i++)
|
|
|
|
{
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_POSITION)) = i & 0xFFFF;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
|
|
|
|
usleep(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_POSITION)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_deactivate_console()
|
|
|
|
{
|
2020-11-25 23:41:45 +00:00
|
|
|
DISPLAY_A(_DIREG(DC_CMD_DISPLAY_WINDOW_HEADER)) = WINDOW_D_SELECT; // Select window D.
|
2020-06-13 15:16:29 +00:00
|
|
|
|
|
|
|
for (u32 i = 0xFFFF; i > 0xFF7F; i--)
|
|
|
|
{
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_POSITION)) = i & 0xFFFF;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
|
|
|
|
usleep(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_POSITION)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_WIN_WIN_OPTIONS)) = 0; // Disable window DD.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | WIN_D_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | WIN_D_ACT_REQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_init_cursor(void *crs_fb, u32 size)
|
|
|
|
{
|
|
|
|
// Setup cursor.
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_CURSOR_START_ADDR)) = CURSOR_CLIPPING(CURSOR_CLIP_WIN_A) | size | ((u32)crs_fb >> 10);
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_BLEND_CURSOR_CONTROL)) =
|
|
|
|
CURSOR_BLEND_R8G8B8A8 | CURSOR_BLEND_DST_FACTOR(CURSOR_BLEND_K1) | CURSOR_BLEND_SRC_FACTOR(CURSOR_BLEND_K1) | 0xFF;
|
|
|
|
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_DISP_WIN_OPTIONS)) |= CURSOR_ENABLE;
|
|
|
|
|
|
|
|
// Arm and activate changes.
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | CURSOR_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | CURSOR_ACT_REQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_set_pos_cursor(u32 x, u32 y)
|
|
|
|
{
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_CURSOR_POSITION)) = x | (y << 16);
|
|
|
|
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | CURSOR_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | CURSOR_ACT_REQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_deinit_cursor()
|
|
|
|
{
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_BLEND_CURSOR_CONTROL)) = 0;
|
|
|
|
DISPLAY_A(_DIREG(DC_DISP_DISP_WIN_OPTIONS)) &= ~CURSOR_ENABLE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_UPDATE | CURSOR_UPDATE;
|
|
|
|
DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = GENERAL_ACT_REQ | CURSOR_ACT_REQ;
|
|
|
|
}
|