first and last commit

This commit is contained in:
Chris Nutter committed 2023-07-08 13:03:17 -07:00
commit 1bf4efd552
2612 files changed
+636500

No files matched your search

+178
View File
@@ -0,0 +1,178 @@
/*
* Copyright (C) 2009-2013 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#include <debug.h>
#include <drivers/display.h>
#include <lib/paint.h>
#include <platform/soc/hwclocks.h>
#include <drivers/dither.h>
#include "clcd_regs.h"
#ifndef CLCD_VERSION
#error CLCD_VERSION undefined
#endif
static void clcd_load_gamma_table(u_int32_t lut_id, u_int32_t *lut_data, uint32_t coeff);
void clcd_enable_clocks(bool enable)
{
int device;
if (CLCD_DISPLAYPIPE_BASE_ADDR == DISP0_BASE_ADDR)
device = CLK_DISP0;
else
device = CLK_DISP1;
// Enable/disable displaypipe and clcd clocks
if (enable) {
clock_gate(device, true);
clock_gate(CLK_CLCD, true);
}
else {
clock_gate(CLK_CLCD, false);
clock_gate(device, false);
}
}
void clcd_init(struct display_timing *timing)
{
rCLCD_STATUS = (1 << 8); // Reset CLCD
while (rCLCD_STATUS & (1 << 8)); // Wait for reset complete...
spin(1); // ... and wait some more: <rdar://problem/6090842>
// Enable sync enable
rCLCD_STATUS = (1 << 2);
// Bypass and clock gate MIE
rCLCD_CFG = (1 << 1) | (1 << 0);
#if DITHER_VERSION == 1
rCLCD_DITH_CFG = (1 << 31) | (1 << 0);
// Set dithering constants
rCLCD_DITH_CONST = (2 << 16) | (4 << 8) | (8 << 0);
if (timing->display_depth <= 18) {
#if CLCD_DITHER_BASE_ADDR
rCLCD_DITHER_METHOD = (4 << 4) | (2 << 0);
rCLCD_DITHER_ENABLE = 1;
#else
rCLCD_DITH_CFG |= (1 << 24) | (1 << 20) | (1 << 16);
#endif
}
#endif
#if DITHER_VERSION == 2
//Need to force the bypass dithering in the clcd block
rCLCD_DITH_CFG = (1 << 31) | (1 << 29) | (1 << 0);
rCLCD_DITH_CONST = 0;
dither_init(timing->display_depth);
dither_set_enable(true);
#endif
rCLCD_OTF_CON1 = 0;
rCLCD_OTF_CON2 = (timing->neg_vclk << 3) | (timing->neg_hsync << 2) | (timing->neg_vsync << 1) | (timing->neg_vden << 0);
rCLCD_OTF_TCON1 = (CLCD_OTF_TCON1_VSPP |
CLCD_OTF_TCON1_VBPD(timing->v_back_porch) |
CLCD_OTF_TCON1_VFPD(timing->v_front_porch) |
CLCD_OTF_TCON1_VSPW(timing->v_pulse_width));
#if defined(TARGET_CLCD_VSPP) && (TARGET_CLCD_VSPP == 0)
rCLCD_OTF_TCON1 &= ~CLCD_OTF_TCON1_VSPP;
#endif
rCLCD_OTF_TCON2 = (CLCD_OTF_TCON2_HBPD(timing->h_back_porch) |
CLCD_OTF_TCON2_HFPD(timing->h_front_porch) |
CLCD_OTF_TCON2_HSPW(timing->h_pulse_width));
rCLCD_OTF_TCON3 = (CLCD_OTF_TCON3_HOZVAL(timing->h_active) |
CLCD_OTF_TCON3_LINEVAL(timing->v_active));
}
bool clcd_get_enable_timing_generator(void)
{
return ((rCLCD_OTF_CON1 & 1) == 1);
}
void clcd_enable_timing_generator(bool enable)
{
if (enable) {
rCLCD_OTF_CON1 |= 1; // Turn OTF on
}
else {
rCLCD_OTF_CON1 &= ~1; // Turn off OTF
while ((rCLCD_OTF_CON1 & (1 << 1)) == 0); // Wait for OTF off
}
}
void clcd_install_gamma_table(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, struct syscfg_wpcl *wpcl)
{
RELEASE_ASSERT(red_lut != NULL);
RELEASE_ASSERT(green_lut != NULL);
RELEASE_ASSERT(blue_lut != NULL);
RELEASE_ASSERT(wpcl != NULL);
// Load the Gamma Correction Table
clcd_load_gamma_table(CLCD_GM_COR_RED, red_lut, wpcl->red);
clcd_load_gamma_table(CLCD_GM_COR_GREEN, green_lut, wpcl->green);
clcd_load_gamma_table(CLCD_GM_COR_BLUE, blue_lut, wpcl->blue);
#if CLCD_VERSION >= 1
// Swap to the new Gamma Correction Table
rCLCD_GM_CON = CLCD_GM_CON_GM_CO_TBL_UPDATED;
// Wait for the swap to complete
while ((rCLCD_GM_CON & CLCD_GM_CON_GM_CO_TBL_UPDATED) != 0);
// Load the Alternate Gamma Correction Table
clcd_load_gamma_table(CLCD_GM_COR_RED, red_lut, wpcl->red);
clcd_load_gamma_table(CLCD_GM_COR_GREEN, green_lut, wpcl->green);
clcd_load_gamma_table(CLCD_GM_COR_BLUE, blue_lut, wpcl->blue);
#endif
// Turn on Gamma Correction
rCLCD_GM_CON = CLCD_GM_CON_GM_CO_ENABLE;
}
static void clcd_load_gamma_table(u_int32_t lut_id, u_int32_t *lut_data, uint32_t coeff)
{
u_int32_t cnt;
u_int32_t lut_size = (lut_id == CLCD_GM_ENC) ? 225 : 256;
u_int32_t lut_value, lut_value2;
rCLCD_GM_TBL_ACC_CON = (1 << 16) | (lut_id << 12) | (0 << 0);
for (cnt = 0; cnt < lut_size; cnt++) {
lut_value = lut_data[cnt];
switch (lut_id) {
case CLCD_GM_DEC_RED :
case CLCD_GM_DEC_GREEN :
case CLCD_GM_DEC_BLUE :
break;
case CLCD_GM_COR_RED :
case CLCD_GM_COR_GREEN :
case CLCD_GM_COR_BLUE :
lut_value2 = (lut_data[cnt + 1] * coeff) >> WpCl_Quotation_Denominator;
lut_value = (lut_value * coeff) >> WpCl_Quotation_Denominator;
lut_value = ((lut_value << 10) & 0x000FFC00) | (lut_value2 & 0x000003FF);
break;
case CLCD_GM_ENC :
break;
}
rCLCD_GM_TBL_WDATA = (1 << 31) | lut_value;
}
rCLCD_GM_TBL_ACC_CON = 0;
}
+74
View File
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2009-2012 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef __SAMSUNG_CLCD_REGS_H
#define __SAMSUNG_CLCD_REGS_H
#include <platform/soc/hwregbase.h>
#define rCLCD_STATUS (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0000))
#define rCLCD_CFG (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0004))
#define rCLCD_INT_EN (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0008))
#define rCLCD_INT_STATUS (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x000C))
#define rCLCD_VER (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0010))
#define rCLCD_DITH_CFG (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0014))
#define rCLCD_DITH_CONST (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0018))
#define rCLCD_DPHSYNC_CTRL (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0020))
#define rCLCD_DPVSYNC_CTRL (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0024))
#define rCLCD_GM_CON (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x002C))
#define CLCD_GM_CON_GM_CO_ENABLE (1 << 0)
#define CLCD_GM_CON_GM_CO_TBL_UPDATED (1 << 6)
#define rCLCD_GM_STATUS (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0030))
#define rCLCD_GM_TBL_ACC_CON (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0034))
#define CLCD_GM_OFF (0)
#define CLCD_GM_DEC_RED (1)
#define CLCD_GM_DEC_GREEN (2)
#define CLCD_GM_DEC_BLUE (3)
#define CLCD_GM_COR_RED (4)
#define CLCD_GM_COR_GREEN (5)
#define CLCD_GM_COR_BLUE (6)
#define CLCD_GM_ENC (7)
#define rCLCD_GM_TBL_WDATA (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0038))
#define rCLCD_GM_TBL_RDATA (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x003C))
#define rCLCD_OTF_CON1 (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0050))
#define rCLCD_OTF_CON2 (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0054))
#define rCLCD_OTF_TCON1 (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0058))
#if (DISP_VERSION < 3)
#define CLCD_OTF_TCON1_VSPP (1 << 24)
#define CLCD_OTF_TCON1_VBPD(_l) (((_l)-1) << 16)
#define CLCD_OTF_TCON1_VFPD(_l) (((_l)-1) << 8)
#define CLCD_OTF_TCON1_VSPW(_l) (((_l)-1) << 0)
#else
#define CLCD_OTF_TCON1_VSPP (1 << 30)
#define CLCD_OTF_TCON1_VBPD(_l) (((_l)-1) << 20)
#define CLCD_OTF_TCON1_VFPD(_l) (((_l)-1) << 10)
#define CLCD_OTF_TCON1_VSPW(_l) (((_l)-1) << 0)
#endif
#define rCLCD_OTF_TCON2 (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x005C))
#if (DISP_VERSION < 4)
#define CLCD_OTF_TCON2_HBPD(_p) (((_p)-1) << 16)
#define CLCD_OTF_TCON2_HFPD(_p) (((_p)-1) << 8)
#define CLCD_OTF_TCON2_HSPW(_p) (((_p)-1) << 0)
#else
#define CLCD_OTF_TCON2_HBPD(_p) (((_p)-1) << 20)
#define CLCD_OTF_TCON2_HFPD(_p) (((_p)-1) << 10)
#define CLCD_OTF_TCON2_HSPW(_p) (((_p)-1) << 0)
#endif
#define rCLCD_OTF_TCON3 (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0060))
#define CLCD_OTF_TCON3_HOZVAL(_p) (((_p)-1) << 16)
#define CLCD_OTF_TCON3_LINEVAL(_p) (((_p)-1) << 0)
#define rCLCD_OTF_INT_EN (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0064))
#define rCLCD_OTF_INT_STATUS (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0068))
#define rCLCD_MIE_SAT_CON (*(volatile u_int32_t *)(CLCD_BASE_ADDR + 0x0074))
#define rCLCD_DITHER_ENABLE (*(volatile u_int32_t *)(CLCD_DITHER_BASE_ADDR + 0x0000))
#define rCLCD_DITHER_METHOD (*(volatile u_int32_t *)(CLCD_DITHER_BASE_ADDR + 0x0004))
#endif /* __SAMSUNG_CLCD_REGS_H */
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef __SAMSUNG_CLCD_V2_H
#define __SAMSUNG_CLCD_V2_H
void clcd_enable_clocks(bool enable);
void clcd_init(struct display_timing *timing);
bool clcd_get_enable_timing_generator(void);
void clcd_enable_timing_generator(bool enable);
void clcd_install_gamma_table(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, struct syscfg_wpcl *wpcl);
#endif /* __SAMSUNG_CLCD_V2_H */
+19
View File
@@ -0,0 +1,19 @@
# Copyright (C) 2012 Apple Inc. All rights reserved.
#
# This document is the property of Apple Inc.
# It is considered confidential and proprietary.
#
# This document may not be reproduced or transmitted in any form,
# in whole or in part, without the express written permission of
# Apple Inc.
#
LOCAL_DIR := $(GET_LOCAL_DIR)
OPTIONS += \
DISPLAYPIPE_BASE_ADDR=CLCD_DISPLAYPIPE_BASE_ADDR \
WITH_DBE_CLCD=1
ALL_OBJS += \
$(LOCAL_DIR)/clcd.o
GLOBAL_INCLUDES += $(LOCAL_DIR)/include