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

+153
View File
@@ -0,0 +1,153 @@
/*
* 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.
*/
#include <debug.h>
#include <lib/env.h>
#include <lib/paint.h>
#include <lib/syscfg.h>
#include <drivers/dpb.h>
#include "dpb.h"
static void dpb_load_gamma_table(u_int32_t lut_id, u_int32_t *lut_data);
static void dpb_convert_gamma_tables(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, u_int32_t *mod_red_lut, u_int32_t *mod_green_lut, u_int32_t *mod_blue_lut, struct syscfg_wpcl *wpcl);
#define DPB_LUT_SIZE_PER_CHANNEL 129
void dpb_init(void)
{
//do not bypass any of the blocks
//<rdar://problem/13436089> Leave LUT bypass config in default state in DPB::CONTROL_REG
#ifdef DPB_DETECT_VIB_CONTROL_TUNABLE
rDPB_DETECT_VBI_CONTROL_REG = DPB_DETECT_VIB_CONTROL_TUNABLE;
#endif
}
bool dpb_get_enable(void)
{
return false;
}
void dpb_set_enable(bool enable)
{
if (enable) {
rDPB_CONTROL_REG |= DPB_CTRL_ENABLE_CFG;
} else {
rDPB_CONTROL_REG &= ~DPB_CTRL_ENABLE_CFG;
}
}
void dpb_install_gamma_table(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, struct syscfg_wpcl *wpcl)
{
u_int32_t mod_red_lut[DPB_LUT_SIZE_PER_CHANNEL], mod_green_lut[DPB_LUT_SIZE_PER_CHANNEL], mod_blue_lut[DPB_LUT_SIZE_PER_CHANNEL];
dpb_convert_gamma_tables(red_lut, green_lut, blue_lut, mod_red_lut, mod_green_lut, mod_blue_lut, wpcl);
// Load the Gamma Correction Table
dpb_load_gamma_table(DPB_RED, mod_red_lut);
dpb_load_gamma_table(DPB_GREEN, mod_green_lut);
dpb_load_gamma_table(DPB_BLUE, mod_blue_lut);
// Turn on Gamma Correction
rDPB_CONTROL_REG |= DPB_CTRL_CGM_ENABLE_CFG;
// Load the Gamma Correction Table
dpb_load_gamma_table(DPB_RED, mod_red_lut);
dpb_load_gamma_table(DPB_GREEN, mod_green_lut);
dpb_load_gamma_table(DPB_BLUE, mod_blue_lut);
rDPB_TABLE_CONTROL_REG |= DPB_UPDATE_REGISTERS | DPB_IMMEDIATE_UPDATE | DPB_UPDATE_CGM_GREEN_TABLE | DPB_UPDATE_CGM_RED_TABLE | DPB_UPDATE_CGM_BLUE_TABLE;
//Wait till HW is cleared
while ((rDPB_TABLE_CONTROL_REG & DPB_UPDATE_CGM_GREEN_TABLE) && (rDPB_TABLE_CONTROL_REG & DPB_UPDATE_CGM_RED_TABLE) && (rDPB_TABLE_CONTROL_REG & DPB_UPDATE_CGM_BLUE_TABLE));
// Load the Gamma Correction Table again since the OS reads them (double buffered registers)
dpb_load_gamma_table(DPB_RED, mod_red_lut);
dpb_load_gamma_table(DPB_GREEN, mod_green_lut);
dpb_load_gamma_table(DPB_BLUE, mod_blue_lut);
}
static void dpb_load_gamma_table(u_int32_t lut_id, u_int32_t *lut_data)
{
u_int32_t cnt;
u_int32_t lut_size = DPB_LUT_SIZE_PER_CHANNEL;
volatile u_int32_t * lut_addr;
switch(lut_id) {
case DPB_RED:
lut_addr = &DPB_CGM_RED;
break;
case DPB_GREEN:
lut_addr = &DPB_CGM_GREEN;
break;
case DPB_BLUE:
lut_addr = &DPB_CGM_BLUE;
break;
default:
panic("invalid gamma lut id");
}
for (cnt = 0; cnt < lut_size; cnt++, lut_addr++) {
*lut_addr = lut_data[cnt];
}
}
//Gamma table is passed in the old clcd format, which is not compatible "as is" with dpb HW format.
// The table provided has the following charasteristics:
// 1. its values are compressed
// 2. the layout is linear layout 1..n
// For H6 , we need the following table charasterictics:
// 1. decompress
// 2. layout is bankbased entry = (2N+1) << 16 | 2N
static void dpb_convert_gamma_tables(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, u_int32_t *mod_red_lut, u_int32_t *mod_green_lut, u_int32_t *mod_blue_lut, struct syscfg_wpcl *wpcl)
{
int i, j;
u_int32_t oddValue, evenValue;
u_int32_t reg;
const u_int32_t *orig_luts[3];
u_int32_t *mod_luts[3];
uint32_t coeffs[3];
orig_luts[0] = red_lut;
orig_luts[1] = green_lut;
orig_luts[2] = blue_lut;
mod_luts[0] = mod_red_lut;
mod_luts[1] = mod_green_lut;
mod_luts[2] = mod_blue_lut;
coeffs[0] = wpcl->red;
coeffs[1] = wpcl->green;
coeffs[2] = wpcl->blue;
// For H6, there are 129 10-bit entries on 2 banks, totalling 258:
// RESERVED1 BANK 1 RESERVED0 BANK 0
// [31:26] [25:16] [15:10] [9:0]
// X 1 X 0
// X 3 X 2
// ...
// X 257 X 256
for (i = 0; i < DPB_LUT_SIZE_PER_CHANNEL; i++)
{
for (j = 0; j < 3; j++)
{
//extract 2n+1
oddValue = (2*i+1 >= 257) ? 0 : orig_luts[j][2*i+1];
//decompress
oddValue = ((oddValue * coeffs[j]) >> WpCl_Quotation_Denominator) & 0x03FF;
//extract 2n
evenValue = orig_luts[j][2*i];
//decompress
evenValue = ((evenValue * coeffs[j]) >> WpCl_Quotation_Denominator) & 0x03FF;
reg = (oddValue << 16) | evenValue;
mod_luts[j][i] = reg;
}
}
}
+117
View File
@@ -0,0 +1,117 @@
/*
* 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.
*/
#ifndef __APPLE_DPB_H
#define __APPLE_DPB_H
#include <platform/soc/hwregbase.h>
#ifdef DISP0_DPB_BASE_ADDR
#define DPB_BASE_ADDR DISP0_DPB_BASE_ADDR
#endif
#ifndef DPB_BASE_ADDR
#error "DPB base addr for AppleDynamicPixelBackligh (DPB) Block is not defined"
#endif
#define DPB_RED 0
#define DPB_GREEN 1
#define DPB_BLUE 2
#define rDPB_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0000)) //Main Control Register
#define DPB_CTRL_CGM_BYPASSCFG (1 << 9)
#define DPB_CTRL_TMF_BYPASS_CFG (1 << 8)
#define DPB_CTRL_PMR_BYPASS_CFG (1 << 7)
#define DPB_CTRL_MIN_PIXEL_MASK_ENABLE_CFG (1 << 6)
#define DPB_CTRL_CGM_ENABLE_CFG (1 << 5)
#define DPB_CTRL_PMR_ENABLE_CFG (1 << 4)
#define DPB_CTRL_LOW_PASS_FILTER_BYPASS_CFG (1 << 3)
#define DPB_CTRL_SMOOTH_OFF_CFG (1 << 2)
#define DPB_CTRL_DYNAMIC_TMF_CFG (1 << 1)
#define DPB_CTRL_ENABLE_CFG (1 << 0)
#define DPB_CTRL_BCL_ENABLE (1 << 7)
#define DPB_CTRL_DYNAMIC_BACKLIGHT (1 << 6)
#define DPB_CTRL_TMF_BYPASS (1 << 5)
#define DPB_CTRL_MIN_PIXEL_MASK_ENABLE (1 << 4)
#define DPB_CTRL_TEMPORTAL_FILTER_BYPASS (1 << 3)
#define DPB_CTRL_SMOOTH_OFF (1 << 2)
#define DPB_CTRL_DPB_DYNAMIC_TMF (1 << 1)
#define rDPB_HISTOGRAM_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0004)) //Definition of luminance calculation for histogram
#define rDPB_WINDOW_UPPER_LEFT_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0008)) //Register defining top and left boundaries of active pixel window
#define rDPB_WINDOW_BOTTOM_RIGHT_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x000c)) //Register defining bottom and right boundaries of active pixel window
#define rDPB_LOW_PASS_FILTER_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0010)) //Temporal Filter Control Register 1
#define rDPB_LOW_PASS_FILTER_CONTROL2_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0014)) //Temporal Filter Control Register 2
#define rDPB_SLOPE_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0018)) //Slope Control Register
#define DPB_SLOPEM2_SHIFT (20)
#define DPB_SLOPEM2_MASK (0x1FF << DPB_SLOPEM2_SHIFT)
#define rDPB_TABLE_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x001c)) //Synchronize LUT and register updates to next vertical blank interval
#define DPB_IMMEDIATE_UPDATE (1 << 15)
#define DPB_DUMP_HISTOGRAM (1 << 14)
#define DPB_UPDATE_REGISTERS (1 << 13)
#define DPB_UPDATE_CGM_BLUE_TABLE (1 << 12)
#define DPB_UPDATE_CGM_GREEN_TABLE (1 << 11)
#define DPB_UPDATE_CGM_RED_TABLE (1 << 10)
#define DPB_UPDATE_PMR_BLUE_TABLE (1 << 9)
#define DPB_UPDATE_PMR_GREEN_TABLE (1 << 8)
#define DPB_UPDATE_PMR_RED_TABLE (1 << 7)
#define DPB_UPDATE_ENGAMMA_BLUE_TABLE (1 << 6)
#define DPB_UPDATE_ENGAMMA_GREEN_TABLE (1 << 5)
#define DPB_UPDATE_ENGAMMA_RED_TABLE (1 << 4)
#define DPB_UPDATE_DEGAMMA_BLUE_TABLE (1 << 2)
#define DPB_UPDATE_DEGAMMA_GREEN_TABLE (1 << 1)
#define DPB_UPDATE_DEGAMMA_RED_TABLE (1 << 0)
#define rDPB_DETECT_VBI_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0020)) //Detect VBI Register
#define rDPB_MAX_SLOPE_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0024)) //Max Slope Control Register
#define rDPB_SLOPE_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0028)) //Slope Status Register
#define rDPB_HISTOGRAM_BIN_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x002c)) //Histogram Bin Status Register
#define rDPB_HISTOGRAM_PIXEL_CNT_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0030)) //Histogram Pixel Count Status Register
#define rDPB_BACK_LIGHT_LEVEL_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0034)) //Backlight Level Status Register
#define rDPB_FRAME_COUNTER_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0038)) //Frame Counter Register
#define rDPB_HISTOGRAM_MIN_PIXEL_CNT_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x003c)) //Histogram Min Pixel Count Status Register
#define rDPB_MIN_PIXEL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0040)) //Minimum Pixel Threshold Register
#define rDPB_CLIP_PIXEL_CNT_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0044)) //Pixel Count Register
#define rDPB_MAX_KNEE_POINT_DELTA_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0048)) //Max Kneepoint Delta Register
#define rDPB_CRC_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x004c)) //CRC Control Register
#define rDPB_CRC_WINDOW_START_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0050)) //CRC Window Start Register
#define rDPB_CRC_WINDOW_END_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0054)) //CRC Window End Register
#define rDPB_CRC0_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0058)) //CRC0 Status Register
#define rDPB_CRC1_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x005c)) //CRC1 Status Register (reserved)
#define rDPB_BACK_LIGHT_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0060)) //Back light control register used to override computed back light value
#define rDPB_INTERRUPT_CONTROL_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0064)) //DPB Interrupt Control Register
#define rDPB_INTERRUPT_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0068)) //DPB Interrupt Status Register
#define rDPB_DEGAMMA_KNEE_POINT_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x006c)) //Knee Point values in gamma decoded domain
#define rDPB_DEGAMMA_MAX_BRIGHT_STATUS_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0070)) //Maximum Brightness value in gamma decoded domain
#define rDPB_VERSION_REG (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0074)) //DPB Version
//DPB_MEMORY Register
#define DPB_HISTOGRAM_STATS (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x0400)) // [32][256] Histogram of binned brightness values over one frame
#define DPB_TMF_RED (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x1000)) // [32][33] Tone Modifier LUT, Red component
#define DPB_TMF_GREEN (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x1400)) // [32][33] Tone Modifier LUT, Green component
#define DPB_TMF_BLUE (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x1800)) // [32][33] Tone Modifier LUT, Blue component
#define DPB_PMR_RED (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x2000)) // [32][129] Pixel Manager LUT, Red component
#define DPB_PMR_GREEN (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x2400)) // [32][129] Pixel Manager LUT, Green component
#define DPB_PMR_BLUE (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x2800)) // [32][129] Pixel Manager LUT, Blue component
#define DPB_CGM_RED (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x3000)) // [32][129] Gamma Correction LUT, Red component
#define DPB_CGM_GREEN (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x3400)) // [32][129] Gamma Correction LUT, Green component
#define DPB_CGM_BLUE (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x3800)) // [32][129] Gamma Correction LUT, Blue component
#define DPB_DEGAMMA_RED (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x4000)) // [32][65] Gamma Decode LUT, Red component
#define DPB_DEGAMMA_GREEN (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x4400)) // [32][65] Gamma Decode LUT, Green component
#define DPB_DEGAMMA_BLUE (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x4800)) // [32][65] Gamma Decode LUT, Blue component
#define DPB_DEGAMMA_SLOPE (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x4c00)) // [32][65] Slope LUT in gamma-decoded domain
#define DPB_ENGAMMA_RED (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x5000)) // [32][113] Gamma encode LUT, Red component
#define DPB_ENGAMMA_GREEN (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x5400)) // [32][113] Gamma encode LUT, Green component
#define DPB_ENGAMMA_BLUE (*(volatile u_int32_t *)(DPB_BASE_ADDR + 0x5800)) // [32][113] Gamma encode LUT, Blue component
#endif /* ! __APPLE_DPB_H */
+17
View File
@@ -0,0 +1,17 @@
# 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 += \
WITH_DPB=1 \
DPB_VERSION=1
ALL_OBJS += \
$(LOCAL_DIR)/dpb.o