mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
3 new ports: Samsung YH-820, YH-920, and YH-925. Mostly functional. Audio working on 820 & 925 (untested on the 920). No battery readings. No recording. No plugins. Keymap needs work.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21083 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d2ea7db6f5
commit
758bb3bc62
46 changed files with 5028 additions and 26 deletions
36
firmware/target/arm/samsung/adc-target.h
Normal file
36
firmware/target/arm/samsung/adc-target.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _ADC_TARGET_H_
|
||||
#define _ADC_TARGET_H_
|
||||
|
||||
#define NUM_ADC_CHANNELS 2
|
||||
|
||||
#define ADC_CHANNEL_0 0
|
||||
#define ADC_CHANNEL_1 1
|
||||
#define ADC_CHANNEL_2 2
|
||||
#define ADC_CHANNEL_3 3
|
||||
|
||||
#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
|
||||
|
||||
/* Force a scan now */
|
||||
unsigned short adc_scan(int channel);
|
||||
|
||||
#endif
|
||||
102
firmware/target/arm/samsung/akcodec-yh82x_yh92x.c
Normal file
102
firmware/target/arm/samsung/akcodec-yh82x_yh92x.c
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2009 Mark Arigo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
#include "audiohw.h"
|
||||
#include "i2c-pp.h"
|
||||
#include "i2s.h"
|
||||
#include "akcodec.h"
|
||||
|
||||
// #define LOGF_ENABLE
|
||||
#include "logf.h"
|
||||
|
||||
#define I2C_AUDIO_ADDRESS 0x10
|
||||
|
||||
/*
|
||||
* Initialise the PP I2C and I2S.
|
||||
*/
|
||||
void audiohw_init(void)
|
||||
{
|
||||
unsigned long tmp;
|
||||
|
||||
logf("audiohw_init");
|
||||
|
||||
/* I2S device enable */
|
||||
DEV_EN |= (DEV_I2S | DEV_EXTCLOCKS);
|
||||
|
||||
/* I2S device reset */
|
||||
DEV_RS |= DEV_I2S;
|
||||
asm volatile ("nop\n");
|
||||
DEV_RS &= ~DEV_I2S;
|
||||
|
||||
DEV_INIT1 &= ~0x3000000;
|
||||
|
||||
tmp = DEV_INIT1;
|
||||
DEV_INIT1 = tmp;
|
||||
|
||||
DEV_INIT2 &= ~0x100;
|
||||
|
||||
/* reset the I2S controller into known state */
|
||||
i2s_reset();
|
||||
|
||||
/* this gpio pin maybe powers the codec chip */
|
||||
GPIOB_ENABLE |= 0x01;
|
||||
GPIOB_OUTPUT_EN |= 0x01;
|
||||
GPIOB_OUTPUT_VAL |= 0x01;
|
||||
|
||||
GPIOL_ENABLE |= 0x20;
|
||||
GPIOL_OUTPUT_VAL &= ~0x20;
|
||||
GPIOL_OUTPUT_EN |= 0x20;
|
||||
|
||||
GPO32_VAL |= 0x00000020;
|
||||
GPO32_ENABLE |= 0x00000020;
|
||||
|
||||
GPIOF_ENABLE |= 0x80;
|
||||
GPIOF_OUTPUT_VAL |= 0x80;
|
||||
GPIOF_OUTPUT_EN |= 0x80;
|
||||
|
||||
audiohw_preinit();
|
||||
|
||||
GPIOL_ENABLE |= 0x20;
|
||||
GPIOL_OUTPUT_VAL |= 0x20;
|
||||
GPIOL_OUTPUT_EN |= 0x20;
|
||||
}
|
||||
|
||||
void akcodec_close(void)
|
||||
{
|
||||
GPIOF_ENABLE |= 0x80;
|
||||
GPIOF_OUTPUT_VAL &= ~0x80;
|
||||
GPIOF_OUTPUT_EN |= 0x80;
|
||||
|
||||
GPIOB_ENABLE |= 0x01;
|
||||
GPIOB_OUTPUT_EN |= 0x01;
|
||||
GPIOB_OUTPUT_VAL |= 0x01;
|
||||
}
|
||||
|
||||
void akcodec_write(int reg, int data)
|
||||
{
|
||||
pp_i2c_send(I2C_AUDIO_ADDRESS, reg, data);
|
||||
}
|
||||
|
||||
int akcodec_read(int reg)
|
||||
{
|
||||
return i2c_readbyte(I2C_AUDIO_ADDRESS, reg);
|
||||
}
|
||||
198
firmware/target/arm/samsung/app.lds
Normal file
198
firmware/target/arm/samsung/app.lds
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
#include "config.h"
|
||||
|
||||
ENTRY(start)
|
||||
|
||||
OUTPUT_FORMAT(elf32-littlearm)
|
||||
OUTPUT_ARCH(arm)
|
||||
STARTUP(target/arm/crt0-pp.o)
|
||||
|
||||
#define PLUGINSIZE PLUGIN_BUFFER_SIZE
|
||||
#define CODECSIZE CODEC_SIZE
|
||||
|
||||
#ifdef DEBUG
|
||||
#define STUBOFFSET 0x10000
|
||||
#else
|
||||
#define STUBOFFSET 0
|
||||
#endif
|
||||
|
||||
#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
|
||||
|
||||
#define DRAMORIG 0x00000000 + STUBOFFSET
|
||||
#define IRAMORIG 0x40000000
|
||||
#define IRAMSIZE 0xc000
|
||||
|
||||
#ifdef CPU_PP502x
|
||||
#define NOCACHE_BASE 0x10000000
|
||||
#else
|
||||
#define NOCACHE_BASE 0x28000000
|
||||
#endif
|
||||
|
||||
#define CACHEALIGN_SIZE 16
|
||||
|
||||
/* End of the audio buffer, where the codec buffer starts */
|
||||
#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
|
||||
|
||||
/* Where the codec buffer ends, and the plugin buffer starts */
|
||||
#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
|
||||
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
loadaddress = .;
|
||||
_loadaddress = .;
|
||||
. = ALIGN(0x200);
|
||||
*(.init.text)
|
||||
*(.text*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
. = ALIGN(0x4);
|
||||
} > DRAM
|
||||
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata) /* problems without this, dunno why */
|
||||
*(.rodata*)
|
||||
*(.rodata.str1.1)
|
||||
*(.rodata.str1.4)
|
||||
. = ALIGN(0x4);
|
||||
|
||||
/* Pseudo-allocate the copies of the data sections */
|
||||
_datacopy = .;
|
||||
} > DRAM
|
||||
|
||||
/* TRICK ALERT! For RAM execution, we put the .data section at the
|
||||
same load address as the copy. Thus, we don't waste extra RAM
|
||||
when we don't actually need the copy. */
|
||||
.data : AT ( _datacopy )
|
||||
{
|
||||
_datastart = .;
|
||||
*(.data*)
|
||||
. = ALIGN(0x4);
|
||||
_dataend = .;
|
||||
} > DRAM
|
||||
|
||||
#if NOCACHE_BASE != 0
|
||||
/* .ncdata section is placed at uncached physical alias address and is
|
||||
* loaded at the proper cached virtual address - no copying is
|
||||
* performed in the init code */
|
||||
.ncdata . + NOCACHE_BASE :
|
||||
{
|
||||
. = ALIGN(CACHEALIGN_SIZE);
|
||||
*(.ncdata*)
|
||||
. = ALIGN(CACHEALIGN_SIZE);
|
||||
} AT> DRAM
|
||||
#endif
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.eh_frame)
|
||||
}
|
||||
|
||||
.vectors 0x0 :
|
||||
{
|
||||
_vectorsstart = .;
|
||||
*(.vectors);
|
||||
_vectorsend = .;
|
||||
} AT> DRAM
|
||||
|
||||
_vectorscopy = LOADADDR(.vectors);
|
||||
_noloaddram = LOADADDR(.vectors);
|
||||
|
||||
.ibss IRAMORIG (NOLOAD) :
|
||||
{
|
||||
_iedata = .;
|
||||
*(.qharray)
|
||||
*(.ibss)
|
||||
. = ALIGN(0x4);
|
||||
_iend = .;
|
||||
} > IRAM
|
||||
|
||||
.iram _iend :
|
||||
{
|
||||
_iramstart = .;
|
||||
*(.icode)
|
||||
*(.irodata)
|
||||
*(.idata)
|
||||
. = ALIGN(0x4);
|
||||
_iramend = .;
|
||||
} > IRAM AT> DRAM
|
||||
|
||||
_iramcopy = LOADADDR(.iram);
|
||||
|
||||
.idle_stacks (NOLOAD) :
|
||||
{
|
||||
*(.idle_stacks)
|
||||
#if NUM_CORES > 1
|
||||
cpu_idlestackbegin = .;
|
||||
. += IDLE_STACK_SIZE;
|
||||
cpu_idlestackend = .;
|
||||
#endif
|
||||
cop_idlestackbegin = .;
|
||||
. += IDLE_STACK_SIZE;
|
||||
cop_idlestackend = .;
|
||||
} > IRAM
|
||||
|
||||
.stack (NOLOAD) :
|
||||
{
|
||||
*(.stack)
|
||||
stackbegin = .;
|
||||
. += 0x2000;
|
||||
stackend = .;
|
||||
} > IRAM
|
||||
|
||||
/* .bss and .ncbss are treated as a single section to use one init loop to
|
||||
* zero it - note "_edata" and "_end" */
|
||||
.bss _noloaddram (NOLOAD) :
|
||||
{
|
||||
_edata = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4);
|
||||
} > DRAM
|
||||
|
||||
#if NOCACHE_BASE != 0
|
||||
.ncbss . + NOCACHE_BASE (NOLOAD):
|
||||
{
|
||||
. = ALIGN(CACHEALIGN_SIZE);
|
||||
*(.ncbss*)
|
||||
. = ALIGN(CACHEALIGN_SIZE);
|
||||
} AT> DRAM
|
||||
#endif
|
||||
|
||||
/* This will be aligned by preceding alignments */
|
||||
.endaddr . - NOCACHE_BASE (NOLOAD) :
|
||||
{
|
||||
_end = .;
|
||||
} > DRAM
|
||||
|
||||
.audiobuf (NOLOAD) :
|
||||
{
|
||||
_audiobuffer = .;
|
||||
audiobuffer = .;
|
||||
} > DRAM
|
||||
|
||||
.audiobufend ENDAUDIOADDR (NOLOAD) :
|
||||
{
|
||||
audiobufend = .;
|
||||
_audiobufend = .;
|
||||
} > DRAM
|
||||
|
||||
.codec ENDAUDIOADDR (NOLOAD) :
|
||||
{
|
||||
codecbuf = .;
|
||||
_codecbuf = .;
|
||||
}
|
||||
|
||||
.plugin ENDADDR (NOLOAD) :
|
||||
{
|
||||
_pluginbuf = .;
|
||||
pluginbuf = .;
|
||||
}
|
||||
}
|
||||
28
firmware/target/arm/samsung/backlight-target.h
Normal file
28
firmware/target/arm/samsung/backlight-target.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef BACKLIGHT_TARGET_H
|
||||
#define BACKLIGHT_TARGET_H
|
||||
|
||||
#define _backlight_init() true
|
||||
void _backlight_on(void);
|
||||
void _backlight_off(void);
|
||||
|
||||
#endif
|
||||
64
firmware/target/arm/samsung/boot.lds
Normal file
64
firmware/target/arm/samsung/boot.lds
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include "config.h"
|
||||
|
||||
ENTRY(start)
|
||||
OUTPUT_FORMAT(elf32-littlearm)
|
||||
OUTPUT_ARCH(arm)
|
||||
STARTUP(target/arm/crt0-pp-bl.o)
|
||||
|
||||
#define DRAMSIZE (MEMORYSIZE * 0x100000)
|
||||
|
||||
#define DRAMORIG 0x10000000
|
||||
#define IRAMORIG 0x40000000
|
||||
#define IRAMSIZE 0x18000
|
||||
#define FLASHORIG 0x001f0000
|
||||
#define FLASHSIZE 2M
|
||||
|
||||
MEMORY
|
||||
{
|
||||
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
|
||||
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = IRAMORIG;
|
||||
|
||||
.text : {
|
||||
*(.init.text)
|
||||
*(.text*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
} > IRAM
|
||||
|
||||
.data : {
|
||||
*(.icode)
|
||||
*(.irodata)
|
||||
*(.idata)
|
||||
*(.data*)
|
||||
*(.ncdata*)
|
||||
*(.rodata*)
|
||||
_dataend = . ;
|
||||
} > IRAM
|
||||
|
||||
.stack : {
|
||||
*(.stack)
|
||||
_stackbegin = .;
|
||||
stackbegin = .;
|
||||
. += 0x2000;
|
||||
_stackend = .;
|
||||
stackend = .;
|
||||
} > IRAM
|
||||
|
||||
/* The bss section is too large for IRAM - we just move it 16MB into the
|
||||
DRAM */
|
||||
|
||||
. = DRAMORIG;
|
||||
.bss . + (16*1024*1024) : {
|
||||
_edata = .;
|
||||
*(.bss*);
|
||||
*(.ibss);
|
||||
*(COMMON)
|
||||
*(.ncbss*);
|
||||
_end = .;
|
||||
} > DRAM
|
||||
}
|
||||
55
firmware/target/arm/samsung/button-target.h
Normal file
55
firmware/target/arm/samsung/button-target.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2009 by Mark Arigo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _BUTTON_TARGET_H_
|
||||
#define _BUTTON_TARGET_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
|
||||
#define HAS_BUTTON_HOLD
|
||||
|
||||
bool button_hold(void);
|
||||
void button_init_device(void);
|
||||
int button_read_device(void);
|
||||
|
||||
/* Button codes for Samsung YH-820, 920, 925 */
|
||||
|
||||
/* Main unit's buttons */
|
||||
/* Left = Menu, Right = Sel */
|
||||
#define BUTTON_LEFT 0x00000001
|
||||
#define BUTTON_RIGHT 0x00000002
|
||||
#define BUTTON_UP 0x00000004
|
||||
#define BUTTON_DOWN 0x00000008
|
||||
#define BUTTON_PLAY 0x00000010
|
||||
#define BUTTON_REW 0x00000020
|
||||
#define BUTTON_FFWD 0x00000040
|
||||
#define BUTTON_REC 0x00000080
|
||||
|
||||
#define BUTTON_MAIN 0x000000ff
|
||||
|
||||
/* No Remote control */
|
||||
#define BUTTON_REMOTE 0
|
||||
|
||||
#define POWEROFF_BUTTON BUTTON_PLAY
|
||||
#define POWEROFF_COUNT 15
|
||||
|
||||
#endif /* _BUTTON_TARGET_H_ */
|
||||
72
firmware/target/arm/samsung/button-yh82x_yh92x.c
Normal file
72
firmware/target/arm/samsung/button-yh82x_yh92x.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2009 by Mark Arigo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
#include "button.h"
|
||||
#include "backlight.h"
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
/* TODO...for now, hardware initialisation is done by the OF bootloader */
|
||||
}
|
||||
|
||||
bool button_hold(void)
|
||||
{
|
||||
return (~GPIOA_INPUT_VAL & 0x1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get button pressed from hardware
|
||||
*/
|
||||
int button_read_device(void)
|
||||
{
|
||||
int btn = BUTTON_NONE;
|
||||
static bool hold_button = false;
|
||||
bool hold_button_old;
|
||||
|
||||
/* Hold */
|
||||
hold_button_old = hold_button;
|
||||
hold_button = button_hold();
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
if (hold_button != hold_button_old)
|
||||
backlight_hold_changed(hold_button);
|
||||
#endif
|
||||
|
||||
/* device buttons */
|
||||
if (!hold_button)
|
||||
{
|
||||
if (~GPIOA_INPUT_VAL & 0x04) btn |= BUTTON_LEFT;
|
||||
if (~GPIOA_INPUT_VAL & 0x20) btn |= BUTTON_RIGHT;
|
||||
if (~GPIOA_INPUT_VAL & 0x10) btn |= BUTTON_UP;
|
||||
if (~GPIOA_INPUT_VAL & 0x08) btn |= BUTTON_DOWN;
|
||||
if (~GPIOA_INPUT_VAL & 0x02) btn |= BUTTON_FFWD;
|
||||
if (~GPIOA_INPUT_VAL & 0x80) btn |= BUTTON_REW;
|
||||
if (~GPIOA_INPUT_VAL & 0x40) btn |= BUTTON_REC;
|
||||
#if defined(SAMSUNG_YH820)
|
||||
if ( GPIOB_INPUT_VAL & 0x80) btn |= BUTTON_PLAY;
|
||||
#elif defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
|
||||
if ( GPIOD_INPUT_VAL & 0x04) btn |= BUTTON_PLAY;
|
||||
#endif
|
||||
}
|
||||
|
||||
return btn;
|
||||
}
|
||||
77
firmware/target/arm/samsung/power-yh82x_yh92x.c
Normal file
77
firmware/target/arm/samsung/power-yh82x_yh92x.c
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2009 by Mark Arigo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* Created from power.c using some iPod code, and some custom stuff based on
|
||||
GPIO analysis
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include <stdbool.h>
|
||||
#include "adc.h"
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
#include "power.h"
|
||||
#include "logf.h"
|
||||
#include "usb.h"
|
||||
|
||||
void power_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int power_input_status(void)
|
||||
{
|
||||
unsigned int status = POWER_INPUT_NONE;
|
||||
|
||||
if (GPIOL_INPUT_VAL & 0x80)
|
||||
status = POWER_INPUT_MAIN_CHARGER;
|
||||
|
||||
if (GPIOD_INPUT_VAL & 0x10)
|
||||
status |= POWER_INPUT_USB_CHARGER;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void ide_power_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
/* We do nothing */
|
||||
}
|
||||
|
||||
|
||||
bool ide_powered(void)
|
||||
{
|
||||
/* pretend we are always powered - we don't turn it off */
|
||||
return true;
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
{
|
||||
/* Disable interrupts on this core */
|
||||
disable_interrupt(IRQ_FIQ_STATUS);
|
||||
|
||||
/* Mask them on both cores */
|
||||
CPU_INT_DIS = -1;
|
||||
COP_INT_DIS = -1;
|
||||
|
||||
while (1)
|
||||
DEV_RS = -1;
|
||||
}
|
||||
47
firmware/target/arm/samsung/yh820/backlight-yh820.c
Normal file
47
firmware/target/arm/samsung/yh820/backlight-yh820.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "system.h"
|
||||
#include "backlight.h"
|
||||
#include "lcd.h"
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(false); /* stop counter */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd + visible display */
|
||||
#endif
|
||||
GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x2);
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x2);
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(false); /* power off visible display */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
}
|
||||
551
firmware/target/arm/samsung/yh820/lcd-as-yh820.S
Normal file
551
firmware/target/arm/samsung/yh820/lcd-as-yh820.S
Normal file
|
|
@ -0,0 +1,551 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 by Jens Arnold
|
||||
* Heavily based on lcd-as-memframe.c by Michael Sevakis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
|
||||
/****************************************************************************
|
||||
* void lcd_write_yuv_420_lines(unsigned char const * const src[3],
|
||||
* int width,
|
||||
* int stride);
|
||||
*
|
||||
* |R| |1.000000 -0.000001 1.402000| |Y'|
|
||||
* |G| = |1.000000 -0.334136 -0.714136| |Pb|
|
||||
* |B| |1.000000 1.772000 0.000000| |Pr|
|
||||
* Scaled, normalized, rounded and tweaked to yield RGB 565:
|
||||
* |R| |74 0 101| |Y' - 16| >> 9
|
||||
* |G| = |74 -24 -51| |Cb - 128| >> 8
|
||||
* |B| |74 128 0| |Cr - 128| >> 9
|
||||
*
|
||||
* Write four RGB565 pixels in the following order on each loop:
|
||||
* 1 3 + > down
|
||||
* 2 4 \/ left
|
||||
*/
|
||||
.section .icode, "ax", %progbits
|
||||
.align 2
|
||||
.global lcd_write_yuv420_lines
|
||||
.type lcd_write_yuv420_lines, %function
|
||||
lcd_write_yuv420_lines:
|
||||
@ r0 = yuv_src
|
||||
@ r1 = width
|
||||
@ r2 = stride
|
||||
stmfd sp!, { r4-r12 } @ save non-scratch
|
||||
ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p
|
||||
@ r5 = yuv_src[1] = Cb_p
|
||||
@ r6 = yuv_src[2] = Cr_p
|
||||
@ r0 = scratch
|
||||
sub r2, r2, #1 @
|
||||
mov r3, #0x70000000 @
|
||||
orr r3, r3, #0x3000 @ r3 = LCD1_BASE
|
||||
10: @ loop line @
|
||||
ldrb r7, [r4], #1 @ r7 = *Y'_p++;
|
||||
ldrb r8, [r5], #1 @ r8 = *Cb_p++;
|
||||
ldrb r9, [r6], #1 @ r9 = *Cr_p++;
|
||||
@
|
||||
sub r7, r7, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @ actually (Y' - 16)*37 and shift right
|
||||
add r7, r12, r7, asl #5 @ by one less when adding - same for all
|
||||
@
|
||||
sub r8, r8, #128 @ Cb -= 128
|
||||
sub r9, r9, #128 @ Cr -= 128
|
||||
@
|
||||
add r10, r9, r9, asl #1 @ r10 = Cr*51 + Cb*24
|
||||
add r10, r10, r10, asl #4 @
|
||||
add r10, r10, r8, asl #3 @
|
||||
add r10, r10, r8, asl #4 @
|
||||
@
|
||||
add r11, r9, r9, asl #2 @ r9 = Cr*101
|
||||
add r11, r11, r9, asl #5 @
|
||||
add r9, r11, r9, asl #6 @
|
||||
@
|
||||
add r8, r8, #2 @ r8 = bu = (Cb*128 + 128) >> 8
|
||||
mov r8, r8, asr #2 @
|
||||
add r9, r9, #256 @ r9 = rv = (r9 + 256) >> 9
|
||||
mov r9, r9, asr #9 @
|
||||
rsb r10, r10, #128 @ r10 = guv = (-r10 + 128) >> 8
|
||||
mov r10, r10, asr #8 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r0, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r0, #31 @ clamp b
|
||||
mvnhi r0, r0, asr #31 @
|
||||
andhi r0, r0, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
mov r11, r11, lsl #3 @
|
||||
orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
|
||||
orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r7, r12, r7, asl #5 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r0, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r0, #31 @ clamp b
|
||||
mvnhi r0, r0, asr #31 @
|
||||
andhi r0, r0, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++)
|
||||
@
|
||||
mov r11, r11, lsl #3 @
|
||||
orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
|
||||
orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r7, r12, r7, asl #5 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r0, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r0, #31 @ clamp b
|
||||
mvnhi r0, r0, asr #31 @
|
||||
andhi r0, r0, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
@
|
||||
mov r11, r11, lsl #3 @
|
||||
orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
|
||||
orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r7, r12, r7, asl #5 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r0, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r0, #31 @ clamp b
|
||||
mvnhi r0, r0, asr #31 @
|
||||
andhi r0, r0, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
mov r11, r11, lsl #3 @
|
||||
orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
|
||||
orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
@
|
||||
subs r1, r1, #2 @ subtract block from width
|
||||
bgt 10b @ loop line @
|
||||
@
|
||||
ldmfd sp!, { r4-r12 } @ restore registers and return
|
||||
bx lr @
|
||||
.ltorg @ dump constant pool
|
||||
.size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines
|
||||
|
||||
/****************************************************************************
|
||||
* void lcd_write_yuv_420_lines_odither(unsigned char const * const src[3],
|
||||
* int width,
|
||||
* int stride,
|
||||
* int x_screen,
|
||||
* int y_screen);
|
||||
*
|
||||
* |R| |1.000000 -0.000001 1.402000| |Y'|
|
||||
* |G| = |1.000000 -0.334136 -0.714136| |Pb|
|
||||
* |B| |1.000000 1.772000 0.000000| |Pr|
|
||||
* Red scaled at twice g & b but at same precision to place it in correct
|
||||
* bit position after multiply and leave instruction count lower.
|
||||
* |R| |258 0 408| |Y' - 16|
|
||||
* |G| = |149 -49 -104| |Cb - 128|
|
||||
* |B| |149 258 0| |Cr - 128|
|
||||
*
|
||||
* Write four RGB565 pixels in the following order on each loop:
|
||||
* 1 3 + > down
|
||||
* 2 4 \/ left
|
||||
*
|
||||
* Kernel pattern (raw|rotated|use order):
|
||||
* 5 3 4 2 2 6 3 7 row0 row2 > down
|
||||
* 1 7 0 6 | 4 0 5 1 | 2 4 6 0 3 5 7 1 col0 left
|
||||
* 4 2 5 3 | 3 7 2 6 | 3 5 7 1 2 4 6 0 col2 \/
|
||||
* 0 6 1 7 5 1 4 0
|
||||
*/
|
||||
.section .icode, "ax", %progbits
|
||||
.align 2
|
||||
.global lcd_write_yuv420_lines_odither
|
||||
.type lcd_write_yuv420_lines_odither, %function
|
||||
lcd_write_yuv420_lines_odither:
|
||||
@ r0 = yuv_src
|
||||
@ r1 = width
|
||||
@ r2 = stride
|
||||
@ r3 = x_screen
|
||||
@ [sp] = y_screen
|
||||
stmfd sp!, { r4-r12, lr } @ save non-scratch
|
||||
ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p
|
||||
@ r5 = yuv_src[1] = Cb_p
|
||||
@ r6 = yuv_src[2] = Cr_p
|
||||
@
|
||||
sub r2, r2, #1 @
|
||||
ldr r14, [sp, #40] @ Line up pattern and kernel quadrant
|
||||
eor r14, r14, r3 @
|
||||
and r14, r14, #0x2 @
|
||||
mov r14, r14, lsl #6 @ 0x00 or 0x80
|
||||
mov r3, #0x70000000 @
|
||||
orr r3, r3, #0x3000 @ r3 = LCD1_BASE
|
||||
10: @ loop line @
|
||||
@
|
||||
ldrb r7, [r4], #1 @ r7 = *Y'_p++;
|
||||
ldrb r8, [r5], #1 @ r8 = *Cb_p++;
|
||||
ldrb r9, [r6], #1 @ r9 = *Cr_p++;
|
||||
@
|
||||
eor r14, r14, #0x80 @ flip pattern quadrant
|
||||
@
|
||||
sub r7, r7, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@
|
||||
sub r8, r8, #128 @ Cb -= 128
|
||||
sub r9, r9, #128 @ Cr -= 128
|
||||
@
|
||||
add r10, r8, r8, asl #4 @ r10 = guv = Cr*104 + Cb*49
|
||||
add r10, r10, r8, asl #5 @
|
||||
add r10, r10, r9, asl #3 @
|
||||
add r10, r10, r9, asl #5 @
|
||||
add r10, r10, r9, asl #6 @
|
||||
@
|
||||
mov r8, r8, asl #1 @ r8 = bu = Cb*258
|
||||
add r8, r8, r8, asl #7 @
|
||||
@
|
||||
add r9, r9, r9, asl #1 @ r9 = rv = Cr*408
|
||||
add r9, r9, r9, asl #4 @
|
||||
mov r9, r9, asl #3 @
|
||||
@
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7 @ r0 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
@ r8 = bu, r9 = rv, r10 = guv
|
||||
@
|
||||
sub r12, r0, r0, lsr #5 @ r0 = 31/32*b + b/256
|
||||
add r0, r12, r0, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
add r12, r14, #0x100 @
|
||||
@
|
||||
add r0, r0, r12 @ b = r0 + delta
|
||||
add r11, r11, r12, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r12, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r0, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r0, asr #15 @ clamp b
|
||||
mvnne r0, r12, lsr #15 @
|
||||
andne r0, r0, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
mov r11, r11, lsr #8
|
||||
and r7, r7, #0x7e00
|
||||
orr r11, r11, r7, lsr #12
|
||||
mov r7, r7, lsr#4
|
||||
orr r0, r7, r0, lsr #10
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7 @ r0 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
sub r12, r0, r0, lsr #5 @ r0 = 31/32*b' + b'/256
|
||||
add r0, r12, r0, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
add r12, r14, #0x200 @
|
||||
@
|
||||
add r0, r0, r12 @ b = r0 + delta
|
||||
add r11, r11, r12, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r12, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r0, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r0, asr #15 @ clamp b
|
||||
mvnne r0, r12, lsr #15 @
|
||||
andne r0, r0, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++)
|
||||
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
mov r11, r11, lsr #8
|
||||
and r7, r7, #0x7e00
|
||||
orr r11, r11, r7, lsr #12
|
||||
mov r7, r7, lsr#4
|
||||
orr r0, r7, r0, lsr #10
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7 @ r0 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
@ r8 = bu, r9 = rv, r10 = guv
|
||||
@
|
||||
sub r12, r0, r0, lsr #5 @ r0 = 31/32*b' + b'/256
|
||||
add r0, r12, r0, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
add r12, r14, #0x300 @
|
||||
@
|
||||
add r0, r0, r12 @ b = r0 + delta
|
||||
add r11, r11, r12, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r12, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r0, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r0, asr #15 @ clamp b
|
||||
mvnne r0, r12, lsr #15 @
|
||||
andne r0, r0, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
mov r11, r11, lsr #8
|
||||
and r7, r7, #0x7e00
|
||||
orr r11, r11, r7, lsr #12
|
||||
mov r7, r7, lsr#4
|
||||
orr r0, r7, r0, lsr #10
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@ compute R, G, and B
|
||||
add r0, r8, r7 @ r0 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
sub r12, r0, r0, lsr #5 @ r0 = 31/32*b + b/256
|
||||
add r0, r12, r0, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
@ This element is zero - use r14 @
|
||||
@
|
||||
add r0, r0, r14 @ b = r0 + delta
|
||||
add r11, r11, r14, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r14, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r0, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r0, asr #15 @ clamp b
|
||||
mvnne r0, r12, lsr #15 @
|
||||
andne r0, r0, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
mov r11, r11, lsr #8
|
||||
and r7, r7, #0x7e00
|
||||
orr r11, r11, r7, lsr #12
|
||||
mov r7, r7, lsr#4
|
||||
orr r0, r7, r0, lsr #10
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r11, [r3, #0x10] @ send MSB
|
||||
1: @ busy @
|
||||
ldr r7, [r3] @ r7 = LCD1_BASE
|
||||
tst r7, #LCD1_BUSY_MASK @ bridge busy?
|
||||
bne 1b @
|
||||
str r0, [r3, #0x10] @ send LSB
|
||||
|
||||
subs r1, r1, #2 @ subtract block from width
|
||||
bgt 10b @ loop line @
|
||||
@
|
||||
ldmfd sp!, { r4-r12, pc } @ restore registers and return
|
||||
.ltorg @ dump constant pool
|
||||
.size lcd_write_yuv420_lines_odither, .-lcd_write_yuv420_lines_odither
|
||||
375
firmware/target/arm/samsung/yh820/lcd-yh820.c
Normal file
375
firmware/target/arm/samsung/yh820/lcd-yh820.c
Normal file
|
|
@ -0,0 +1,375 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 by Mark Arigo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "lcd.h"
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
|
||||
/* Display status */
|
||||
static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
|
||||
|
||||
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
||||
static bool is_lcd_enabled = true;
|
||||
#endif
|
||||
|
||||
/* NOTE: the LCD is rotated 90 degrees */
|
||||
|
||||
/* LCD command set for Samsung S6B33B2 */
|
||||
|
||||
#define R_NOP 0x00
|
||||
#define R_OSCILLATION_MODE 0x02
|
||||
#define R_DRIVER_OUTPUT_MODE 0x10
|
||||
#define R_DCDC_SET 0x20
|
||||
#define R_BIAS_SET 0x22
|
||||
#define R_DCDC_CLOCK_DIV 0x24
|
||||
#define R_DCDC_AMP_ONOFF 0x26
|
||||
#define R_TEMP_COMPENSATION 0x28
|
||||
#define R_CONTRAST_CONTROL1 0x2a
|
||||
#define R_CONTRAST_CONTROL2 0x2b
|
||||
#define R_STANDBY_OFF 0x2c
|
||||
#define R_STANDBY_ON 0x2d
|
||||
#define R_DDRAM_BURST_OFF 0x2e
|
||||
#define R_DDRAM_BURST_ON 0x2f
|
||||
#define R_ADDRESSING_MODE 0x30
|
||||
#define R_ROW_VECTOR_MODE 0x32
|
||||
#define R_N_LINE_INVERSION 0x34
|
||||
#define R_FRAME_FREQ_CONTROL 0x36
|
||||
#define R_RED_PALETTE 0x38
|
||||
#define R_GREEN_PALETTE 0x3a
|
||||
#define R_BLUE_PALETTE 0x3c
|
||||
#define R_ENTRY_MODE 0x40
|
||||
#define R_X_ADDR_AREA 0x42
|
||||
#define R_Y_ADDR_AREA 0x43
|
||||
#define R_RAM_SKIP_AREA 0x45
|
||||
#define R_DISPLAY_OFF 0x50
|
||||
#define R_DISPLAY_ON 0x51
|
||||
#define R_SPEC_DISPLAY_PATTERN 0x53
|
||||
#define R_PARTIAL_DISPLAY_MODE 0x55
|
||||
#define R_PARTIAL_START_LINE 0x56
|
||||
#define R_PARTIAL_END_LINE 0x57
|
||||
#define R_AREA_SCROLL_MODE 0x59
|
||||
#define R_SCROLL_START_LINE 0x5a
|
||||
#define R_DATA_FORMAT_SELECT 0x60
|
||||
|
||||
|
||||
/* wait for LCD */
|
||||
static inline void lcd_wait_write(void)
|
||||
{
|
||||
while (LCD1_CONTROL & LCD1_BUSY_MASK);
|
||||
}
|
||||
|
||||
/* send LCD data */
|
||||
static void lcd_send_data(unsigned data)
|
||||
{
|
||||
lcd_wait_write();
|
||||
LCD1_DATA = data >> 8;
|
||||
lcd_wait_write();
|
||||
LCD1_DATA = data & 0xff;
|
||||
}
|
||||
|
||||
/* send LCD command */
|
||||
static void lcd_send_command(unsigned cmd)
|
||||
{
|
||||
lcd_wait_write();
|
||||
LCD1_CMD = cmd;
|
||||
}
|
||||
|
||||
/* LCD init */
|
||||
void lcd_init_device(void)
|
||||
{
|
||||
#if 0
|
||||
/* This is the init sequence from the yh820 OF bootloader */
|
||||
unsigned long tmp;
|
||||
|
||||
DEV_INIT1 &= ~0x3000;
|
||||
tmp = DEV_INIT1;
|
||||
DEV_INIT1 = tmp;
|
||||
DEV_INIT2 &= ~0x400;
|
||||
|
||||
LCD1_CONTROL &= ~0x4;
|
||||
udelay(15);
|
||||
LCD1_CONTROL |= 0x4;
|
||||
|
||||
LCD1_CONTROL = 0x680;
|
||||
LCD1_CONTROL = 0x684;
|
||||
|
||||
LCD1_CONTROL |= 0x1;
|
||||
udelay(200);
|
||||
|
||||
lcd_send_command(R_STANDBY_OFF);
|
||||
udelay(100000);
|
||||
|
||||
lcd_send_command(R_DISPLAY_OFF);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_OSCILLATION_MODE);
|
||||
lcd_send_command(0x01);
|
||||
udelay(30000);
|
||||
|
||||
lcd_send_command(R_DCDC_SET);
|
||||
lcd_send_command(0x01);
|
||||
udelay(30000);
|
||||
|
||||
lcd_send_command(R_DCDC_AMP_ONOFF);
|
||||
lcd_send_command(0x01);
|
||||
udelay(30000);
|
||||
|
||||
lcd_send_command(R_DCDC_AMP_ONOFF);
|
||||
lcd_send_command(0x09);
|
||||
udelay(30000);
|
||||
|
||||
lcd_send_command(R_DCDC_AMP_ONOFF);
|
||||
lcd_send_command(0x0b);
|
||||
udelay(30000);
|
||||
|
||||
lcd_send_command(R_DCDC_AMP_ONOFF);
|
||||
lcd_send_command(0x0f);
|
||||
udelay(30000);
|
||||
|
||||
lcd_send_command(R_DCDC_CLOCK_DIV);
|
||||
lcd_send_command(0x03);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_CONTRAST_CONTROL1);
|
||||
lcd_send_command(0x89);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_TEMP_COMPENSATION);
|
||||
lcd_send_command(0x01);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_ADDRESSING_MODE);
|
||||
lcd_send_command(0x19);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_ROW_VECTOR_MODE);
|
||||
lcd_send_command(0x00);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_N_LINE_INVERSION);
|
||||
lcd_send_command(0x8b);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_ENTRY_MODE);
|
||||
lcd_send_command(0x01);
|
||||
|
||||
lcd_send_command(R_DRIVER_OUTPUT_MODE);
|
||||
lcd_send_command(0x34);
|
||||
udelay(10000);
|
||||
|
||||
lcd_send_command(R_X_ADDR_AREA); /* vertical dimensions */
|
||||
lcd_send_command(0x00); /* y1 */
|
||||
lcd_send_command(LCD_HEIGHT - 1); /* y2 */
|
||||
|
||||
lcd_send_command(R_Y_ADDR_AREA); /* horizontal dimensions */
|
||||
lcd_send_command(0x04); /* x1 + 4 */
|
||||
lcd_send_command(LCD_WIDTH - 1 + 4); /* x2 + 4 */
|
||||
udelay(100);
|
||||
|
||||
lcd_send_command(R_BIAS_SET);
|
||||
lcd_send_command(0x01);
|
||||
|
||||
lcd_send_command(R_DDRAM_BURST_OFF);
|
||||
udelay(100);
|
||||
|
||||
lcd_send_command(R_DISPLAY_ON);
|
||||
udelay(30000);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*** hardware configuration ***/
|
||||
int lcd_default_contrast(void)
|
||||
{
|
||||
return DEFAULT_CONTRAST_SETTING;
|
||||
}
|
||||
|
||||
void lcd_set_contrast(int val)
|
||||
{
|
||||
lcd_send_command(R_CONTRAST_CONTROL1);
|
||||
lcd_send_command(val);
|
||||
}
|
||||
|
||||
void lcd_set_invert_display(bool yesno)
|
||||
{
|
||||
/* TODO: Implement lcd_set_invert_display() */
|
||||
(void)yesno;
|
||||
}
|
||||
|
||||
#if defined(HAVE_LCD_ENABLE)
|
||||
void lcd_enable(bool yesno)
|
||||
{
|
||||
if (yesno == is_lcd_enabled)
|
||||
return;
|
||||
|
||||
if ((is_lcd_enabled = yesno))
|
||||
{
|
||||
lcd_send_command(R_STANDBY_OFF);
|
||||
lcd_send_command(R_DISPLAY_ON);
|
||||
lcd_activation_call_hook();
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_send_command(R_STANDBY_ON);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
||||
bool lcd_active(void)
|
||||
{
|
||||
return is_lcd_enabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_FLIP
|
||||
/* turn the display upside down (call lcd_update() afterwards) */
|
||||
/* Note: since the lcd is rotated, this will flip horiz instead of vert */
|
||||
void lcd_set_flip(bool yesno)
|
||||
{
|
||||
lcd_send_command(R_DRIVER_OUTPUT_MODE);
|
||||
lcd_send_command(yesno ? 0x30 : 0x34);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*** update functions ***/
|
||||
|
||||
void lcd_yuv_set_options(unsigned options)
|
||||
{
|
||||
lcd_yuv_options = options;
|
||||
}
|
||||
|
||||
/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
|
||||
extern void lcd_write_yuv420_lines(unsigned char const * const src[3],
|
||||
int width,
|
||||
int stride);
|
||||
extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3],
|
||||
int width,
|
||||
int stride,
|
||||
int x_screen, /* To align dither pattern */
|
||||
int y_screen);
|
||||
/* Performance function to blit a YUV bitmap directly to the LCD */
|
||||
void lcd_blit_yuv(unsigned char * const src[3],
|
||||
int src_x, int src_y, int stride,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
unsigned char const * yuv_src[3];
|
||||
off_t z;
|
||||
|
||||
/* Sorry, but width and height must be >= 2 or else */
|
||||
width &= ~1;
|
||||
height >>= 1;
|
||||
|
||||
z = stride*src_y;
|
||||
yuv_src[0] = src[0] + z + src_x;
|
||||
yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
|
||||
yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
|
||||
|
||||
lcd_send_command(R_ENTRY_MODE);
|
||||
lcd_send_command(0x03);
|
||||
|
||||
lcd_send_command(R_Y_ADDR_AREA);
|
||||
lcd_send_command(x + 4);
|
||||
lcd_send_command(x + width - 1 + 4);
|
||||
|
||||
if (lcd_yuv_options & LCD_YUV_DITHER)
|
||||
{
|
||||
do
|
||||
{
|
||||
lcd_send_command(R_X_ADDR_AREA);
|
||||
lcd_send_command(y);
|
||||
lcd_send_command(y + 1);
|
||||
|
||||
lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y);
|
||||
yuv_src[0] += stride << 1; /* Skip down two luma lines */
|
||||
yuv_src[1] += stride >> 1; /* Skip down one chroma line */
|
||||
yuv_src[2] += stride >> 1;
|
||||
y += 2;
|
||||
}
|
||||
while (--height > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
lcd_send_command(R_X_ADDR_AREA);
|
||||
lcd_send_command(y);
|
||||
lcd_send_command(y + 1);
|
||||
|
||||
lcd_write_yuv420_lines(yuv_src, width, stride);
|
||||
yuv_src[0] += stride << 1; /* Skip down two luma lines */
|
||||
yuv_src[1] += stride >> 1; /* Skip down one chroma line */
|
||||
yuv_src[2] += stride >> 1;
|
||||
y += 2;
|
||||
}
|
||||
while (--height > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the display.
|
||||
This must be called after all other LCD functions that change the display. */
|
||||
void lcd_update(void)
|
||||
{
|
||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
}
|
||||
|
||||
/* Update a fraction of the display. */
|
||||
void lcd_update_rect(int x, int y, int width, int height)
|
||||
{
|
||||
const fb_data *addr;
|
||||
|
||||
if (x + width >= LCD_WIDTH)
|
||||
width = LCD_WIDTH - x;
|
||||
if (y + height >= LCD_HEIGHT)
|
||||
height = LCD_HEIGHT - y;
|
||||
|
||||
if ((width <= 0) || (height <= 0))
|
||||
return; /* Nothing left to do. */
|
||||
|
||||
addr = &lcd_framebuffer[y][x];
|
||||
|
||||
if (width <= 1) {
|
||||
lcd_send_command(R_ENTRY_MODE); /* The X end address must be larger */
|
||||
lcd_send_command(0x03); /* that the X start address, so we */
|
||||
lcd_send_command(R_Y_ADDR_AREA); /* switch to vertical mode for */
|
||||
lcd_send_command(x + 4); /* single column updates and set */
|
||||
lcd_send_command(x + 1 + 4); /* the window width to 2 */
|
||||
} else {
|
||||
lcd_send_command(R_ENTRY_MODE);
|
||||
lcd_send_command(0x01);
|
||||
lcd_send_command(R_Y_ADDR_AREA);
|
||||
lcd_send_command(x + 4);
|
||||
lcd_send_command(x + width - 1 + 4);
|
||||
}
|
||||
|
||||
lcd_send_command(R_X_ADDR_AREA);
|
||||
lcd_send_command(y);
|
||||
lcd_send_command(y + height - 1);
|
||||
|
||||
do {
|
||||
int w = width;
|
||||
do {
|
||||
lcd_send_data(*addr++);
|
||||
} while (--w > 0);
|
||||
addr += LCD_WIDTH - width;
|
||||
} while (--height > 0);
|
||||
}
|
||||
59
firmware/target/arm/samsung/yh820/powermgmt-yh820.c
Normal file
59
firmware/target/arm/samsung/yh820/powermgmt-yh820.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
|
||||
* Revisions copyright (C) 2005 by Gerald Van Baren
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
|
||||
/* TODO: Not yet calibrated */
|
||||
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3695
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3627
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 3695, 3714, 3772, 3791, 3811, 3850, 3908, 3985, 4024, 4111, 4198 }
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
3850, 3888, 3927, 3966, 4024, 4063, 4111, 4150, 4198, 4237, 4286
|
||||
};
|
||||
|
||||
#define BATTERY_SCALE_FACTOR 4650
|
||||
/* full-scale ADC readout (2^10) in millivolt */
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
unsigned int battery_adc_voltage(void)
|
||||
{
|
||||
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
|
||||
return 4100;
|
||||
}
|
||||
47
firmware/target/arm/samsung/yh920/backlight-yh920.c
Normal file
47
firmware/target/arm/samsung/yh920/backlight-yh920.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "system.h"
|
||||
#include "backlight.h"
|
||||
#include "lcd.h"
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(false); /* stop counter */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd + visible display */
|
||||
#endif
|
||||
GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x2);
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x2);
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(false); /* power off visible display */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
}
|
||||
294
firmware/target/arm/samsung/yh920/lcd-yh920.c
Normal file
294
firmware/target/arm/samsung/yh920/lcd-yh920.c
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2004 by Linus Nielsen Feltzing
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "lcd.h"
|
||||
|
||||
/*** definitions ***/
|
||||
|
||||
/* LCD command codes */
|
||||
#define LCD_CNTL_POWER_CONTROL 0x25
|
||||
#define LCD_CNTL_VOLTAGE_SELECT 0x2b
|
||||
#define LCD_CNTL_LINE_INVERT_DRIVE 0x36
|
||||
#define LCD_CNTL_GRAY_SCALE_PATTERN 0x39
|
||||
#define LCD_CNTL_TEMP_GRADIENT_SELECT 0x4e
|
||||
#define LCD_CNTL_OSC_FREQUENCY 0x5f
|
||||
#define LCD_CNTL_ON_OFF 0xae
|
||||
#define LCD_CNTL_OSC_ON_OFF 0xaa
|
||||
#define LCD_CNTL_OFF_MODE 0xbe
|
||||
#define LCD_CNTL_REVERSE 0xa6
|
||||
#define LCD_CNTL_ALL_LIGHTING 0xa4
|
||||
#define LCD_CNTL_COMMON_OUTPUT_STATUS 0xc4
|
||||
#define LCD_CNTL_COLUMN_ADDRESS_DIR 0xa0
|
||||
#define LCD_CNTL_NLINE_ON_OFF 0xe4
|
||||
#define LCD_CNTL_DISPLAY_MODE 0x66
|
||||
#define LCD_CNTL_DUTY_SET 0x6d
|
||||
#define LCD_CNTL_ELECTRONIC_VOLUME 0x81
|
||||
#define LCD_CNTL_DATA_INPUT_DIR 0x84
|
||||
#define LCD_CNTL_DISPLAY_START_LINE 0x8a
|
||||
#define LCD_CNTL_AREA_SCROLL 0x10
|
||||
|
||||
#define LCD_CNTL_PAGE 0xb1
|
||||
#define LCD_CNTL_COLUMN 0x13
|
||||
#define LCD_CNTL_DATA_WRITE 0x1d
|
||||
|
||||
/* lcd commands */
|
||||
static void lcd_send_data(unsigned byte)
|
||||
{
|
||||
while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */
|
||||
LCD1_DATA = byte;
|
||||
}
|
||||
|
||||
static void lcd_send_cmd(unsigned byte)
|
||||
{
|
||||
while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */
|
||||
LCD1_CMD = byte;
|
||||
}
|
||||
|
||||
static void lcd_write_reg(unsigned cmd, unsigned data)
|
||||
{
|
||||
lcd_send_cmd(cmd);
|
||||
lcd_send_data(data);
|
||||
}
|
||||
|
||||
static void lcd_write_reg_ex(unsigned cmd, unsigned data0, unsigned data1)
|
||||
{
|
||||
lcd_send_cmd(cmd);
|
||||
lcd_send_data(data0);
|
||||
lcd_send_data(data1);
|
||||
}
|
||||
|
||||
/*** hardware configuration ***/
|
||||
int lcd_default_contrast(void)
|
||||
{
|
||||
return DEFAULT_CONTRAST_SETTING;
|
||||
}
|
||||
|
||||
void lcd_set_contrast(int val)
|
||||
{
|
||||
/* Keep val in acceptable hw range */
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
else if (val > 127)
|
||||
val = 127;
|
||||
|
||||
lcd_write_reg_ex(LCD_CNTL_ELECTRONIC_VOLUME, val, -1);
|
||||
}
|
||||
|
||||
void lcd_set_invert_display(bool yesno)
|
||||
{
|
||||
lcd_send_cmd(LCD_CNTL_REVERSE | (yesno?1:0));
|
||||
}
|
||||
|
||||
/* turn the display upside down (call lcd_update() afterwards) */
|
||||
void lcd_set_flip(bool yesno)
|
||||
{
|
||||
if (yesno)
|
||||
{
|
||||
lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 1);
|
||||
lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 0);
|
||||
lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x20, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 0);
|
||||
lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 1);
|
||||
lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x20, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_init_device(void)
|
||||
{
|
||||
#if 0
|
||||
/* This is the init sequence from the yh820 OF bootloader */
|
||||
unsigned long tmp;
|
||||
|
||||
DEV_INIT2 |= 0x400;
|
||||
|
||||
DEV_INIT1 &= ~0x3000;
|
||||
tmp = DEV_INIT1;
|
||||
DEV_INIT1 = tmp;
|
||||
DEV_INIT2 &= ~0x400;
|
||||
|
||||
LCD1_CONTROL &= ~0x4;
|
||||
udelay(15);
|
||||
LCD1_CONTROL |= 0x4;
|
||||
|
||||
LCD1_CONTROL = 0x680;
|
||||
LCD1_CONTROL = 0x684;
|
||||
|
||||
LCD1_CONTROL |= 0x1;
|
||||
|
||||
lcd_send_cmd(LCD_CNTL_RESET);
|
||||
lcd_send_cmd(LCD_CNTL_DISCHARGE_ON_OFF | 0);
|
||||
lcd_send_cmd(LCD_CNTL_ON_OFF | 0); /* LCD OFF */
|
||||
lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); /* Normal */
|
||||
lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); /* Normal */
|
||||
lcd_send_cmd(LCD_CNTL_REVERSE | 0); /* Reverse OFF */
|
||||
lcd_send_cmd(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */
|
||||
lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x1f, 0x00);
|
||||
lcd_send_cmd(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */
|
||||
lcd_write_reg(LCD_CNTL_VOLTAGE_SELECT, 0x03);
|
||||
lcd_write_reg(LCD_CNTL_ELECTRONIC_VOLUME, 0x40);
|
||||
lcd_write_reg(LCD_CNTL_TEMP_GRADIENT_SELECT, 0x00);
|
||||
lcd_write_reg(LCD_CNTL_LINE_INVERT_DRIVE, 0x1f);
|
||||
lcd_send_cmd(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */
|
||||
lcd_write_reg(LCD_CNTL_OSC_FREQUENCY, 0x00);
|
||||
lcd_send_cmd(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */
|
||||
lcd_write_reg(LCD_CNTL_STEPUP_CK_FREQ, 0x03);
|
||||
lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1c);
|
||||
lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1e);
|
||||
lcd_write_reg(LCD_CNTL_DISPLAY_START_LINE, 0x00);
|
||||
lcd_send_cmd(LCD_CNTL_DATA_INPUT_DIR | 0); /* Column mode */
|
||||
lcd_send_cmd(LCD_CNTL_DISPLAY_MODE, 0); /* Greyscale mode */
|
||||
lcd_write_reg(LCD_CNTL_GRAY_SCALE_PATTERN, 0x52);
|
||||
lcd_send_cmd(LCD_CNTL_PARTIAL_DISPLAY_ON_OFF | 0);
|
||||
lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1f);
|
||||
lcd_send_cmd(LCD_CNTL_ON_OFF | 1); /* LCD ON */
|
||||
#endif
|
||||
}
|
||||
|
||||
/*** update functions ***/
|
||||
|
||||
/* Performance function that works with an external buffer
|
||||
note that by and bheight are in 8-pixel units! */
|
||||
void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
|
||||
int bheight, int stride)
|
||||
{
|
||||
(void)data;
|
||||
(void)x;
|
||||
(void)by;
|
||||
(void)width;
|
||||
(void)bheight;
|
||||
(void)stride;
|
||||
|
||||
#if 0
|
||||
/* This is from the h100 lcd code, perhaps we can adapt */
|
||||
const unsigned char *src, *src_end;
|
||||
unsigned char *dst_u, *dst_l;
|
||||
static unsigned char upper[LCD_WIDTH] IBSS_ATTR;
|
||||
static unsigned char lower[LCD_WIDTH] IBSS_ATTR;
|
||||
unsigned int byte;
|
||||
|
||||
by *= 2;
|
||||
|
||||
while (bheight--)
|
||||
{
|
||||
src = data;
|
||||
src_end = data + width;
|
||||
dst_u = upper;
|
||||
dst_l = lower;
|
||||
do
|
||||
{
|
||||
byte = *src++;
|
||||
*dst_u++ = lcd_dibits[byte & 0x0F];
|
||||
byte >>= 4;
|
||||
*dst_l++ = lcd_dibits[byte & 0x0F];
|
||||
}
|
||||
while (src < src_end);
|
||||
|
||||
lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1);
|
||||
lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1);
|
||||
lcd_send_cmd(LCD_CNTL_DATA_WRITE);
|
||||
lcd_write_data(upper, width);
|
||||
|
||||
lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1);
|
||||
lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1);
|
||||
lcd_send_cmd(LCD_CNTL_DATA_WRITE);
|
||||
lcd_write_data(lower, width);
|
||||
|
||||
data += stride;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Helper function for lcd_grey_phase_blit(). */
|
||||
/* void lcd_grey_data(unsigned char *values, unsigned char *phases, int count); */
|
||||
|
||||
/* Performance function that works with an external buffer
|
||||
note that by and bheight are in 4-pixel units! */
|
||||
void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
|
||||
int x, int by, int width, int bheight, int stride)
|
||||
{
|
||||
(void)values;
|
||||
(void)phases;
|
||||
(void)x;
|
||||
(void)by;
|
||||
(void)width;
|
||||
(void)bheight;
|
||||
(void)stride;
|
||||
|
||||
#if 0
|
||||
/* This is from the h100 lcd code, perhaps we can adapt */
|
||||
stride <<= 2; /* 4 pixels per block */
|
||||
while (bheight--)
|
||||
{
|
||||
lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1);
|
||||
lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1);
|
||||
lcd_send_cmd(LCD_CNTL_DATA_WRITE);
|
||||
lcd_grey_data(values, phases, width);
|
||||
values += stride;
|
||||
phases += stride;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Update a fraction of the display. */
|
||||
/* void lcd_update_rect(int, int, int, int) ICODE_ATTR; */
|
||||
void lcd_update_rect(int x0, int y, int width, int height)
|
||||
{
|
||||
const fb_data *addr;
|
||||
int ymax;
|
||||
int x = x0;
|
||||
|
||||
/* The Y coordinates have to work on even 8 pixel rows */
|
||||
ymax = (y + height-1) >> 2;
|
||||
y >>= 2;
|
||||
|
||||
if(x + width > LCD_WIDTH)
|
||||
width = LCD_WIDTH - x;
|
||||
if (width <= 0)
|
||||
return; /* nothing left to do, 0 is harmful to lcd_write_data() */
|
||||
if(ymax >= LCD_FBHEIGHT)
|
||||
ymax = LCD_FBHEIGHT-1;
|
||||
|
||||
/* Copy specified rectange bitmap to hardware */
|
||||
for (; y <= ymax; y++)
|
||||
{
|
||||
lcd_write_reg(LCD_CNTL_PAGE, y);
|
||||
lcd_write_reg(LCD_CNTL_COLUMN, x0);
|
||||
|
||||
addr = &lcd_framebuffer[y][x0];
|
||||
|
||||
lcd_send_cmd(LCD_CNTL_DATA_WRITE);
|
||||
for (x = x0; x < width; x++)
|
||||
lcd_send_data(*addr++);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the display.
|
||||
This must be called after all other LCD functions that change the display. */
|
||||
void lcd_update(void)
|
||||
{
|
||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
}
|
||||
59
firmware/target/arm/samsung/yh920/powermgmt-yh920.c
Normal file
59
firmware/target/arm/samsung/yh920/powermgmt-yh920.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
|
||||
* Revisions copyright (C) 2005 by Gerald Van Baren
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
|
||||
/* TODO: Not yet calibrated */
|
||||
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3733
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3627
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 3733, 3772, 3821, 3840, 3869, 3917, 3985, 4034, 4072, 4140, 4198 }
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
3956, 3995, 4024, 4043, 4063, 4082, 4111, 4140, 4179, 4218, 4266
|
||||
};
|
||||
|
||||
#define BATTERY_SCALE_FACTOR 4650
|
||||
/* full-scale ADC readout (2^10) in millivolt */
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
unsigned int battery_adc_voltage(void)
|
||||
{
|
||||
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
|
||||
return 4100;
|
||||
}
|
||||
47
firmware/target/arm/samsung/yh925/backlight-yh925.c
Normal file
47
firmware/target/arm/samsung/yh925/backlight-yh925.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "system.h"
|
||||
#include "backlight.h"
|
||||
#include "lcd.h"
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(false); /* stop counter */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd + visible display */
|
||||
#endif
|
||||
GPIO_SET_BITWISE(GPIOF_OUTPUT_VAL, 0x1);
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
GPIO_CLEAR_BITWISE(GPIOF_OUTPUT_VAL, 0x1);
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(false); /* power off visible display */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
}
|
||||
538
firmware/target/arm/samsung/yh925/lcd-as-yh925.S
Normal file
538
firmware/target/arm/samsung/yh925/lcd-as-yh925.S
Normal file
|
|
@ -0,0 +1,538 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007-2008 by Michael Sevakis
|
||||
*
|
||||
* H10 20GB LCD assembly routines
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
|
||||
/****************************************************************************
|
||||
* void lcd_write_yuv_420_lines(unsigned char const * const src[3],
|
||||
* int width,
|
||||
* int stride);
|
||||
*
|
||||
* |R| |1.000000 -0.000001 1.402000| |Y'|
|
||||
* |G| = |1.000000 -0.334136 -0.714136| |Pb|
|
||||
* |B| |1.000000 1.772000 0.000000| |Pr|
|
||||
* Scaled, normalized, rounded and tweaked to yield RGB 565:
|
||||
* |R| |74 0 101| |Y' - 16| >> 9
|
||||
* |G| = |74 -24 -51| |Cb - 128| >> 8
|
||||
* |B| |74 128 0| |Cr - 128| >> 9
|
||||
*
|
||||
* Write four RGB565 pixels in the following order on each loop:
|
||||
* 1 3 + > down
|
||||
* 2 4 \/ left
|
||||
*/
|
||||
.section .icode, "ax", %progbits
|
||||
.align 2
|
||||
.global lcd_write_yuv420_lines
|
||||
.type lcd_write_yuv420_lines, %function
|
||||
lcd_write_yuv420_lines:
|
||||
@ r0 = yuv_src
|
||||
@ r1 = width
|
||||
@ r2 = stride
|
||||
stmfd sp!, { r4-r12, lr } @ save non-scratch
|
||||
ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p
|
||||
@ r5 = yuv_src[1] = Cb_p
|
||||
@ r6 = yuv_src[2] = Cr_p
|
||||
@
|
||||
mov r0, #0x7000000c @ r0 = &LCD2_PORT = 0x70008a0c
|
||||
add r0, r0, #0x8a00 @
|
||||
mov r14, #LCD2_DATA_MASK @
|
||||
@
|
||||
sub r2, r2, #1 @ Adjust stride because of increment
|
||||
10: @ loop line @
|
||||
ldrb r7, [r4], #1 @ r7 = *Y'_p++;
|
||||
ldrb r8, [r5], #1 @ r8 = *Cb_p++;
|
||||
ldrb r9, [r6], #1 @ r9 = *Cr_p++;
|
||||
@
|
||||
sub r7, r7, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @ actually (Y' - 16)*37 and shift right
|
||||
add r7, r12, r7, asl #5 @ by one less when adding - same for all
|
||||
@
|
||||
sub r8, r8, #128 @ Cb -= 128
|
||||
sub r9, r9, #128 @ Cr -= 128
|
||||
@
|
||||
add r10, r9, r9, asl #1 @ r10 = Cr*51 + Cb*24
|
||||
add r10, r10, r10, asl #4 @
|
||||
add r10, r10, r8, asl #3 @
|
||||
add r10, r10, r8, asl #4 @
|
||||
@
|
||||
add r11, r9, r9, asl #2 @ r9 = Cr*101
|
||||
add r11, r11, r9, asl #5 @
|
||||
add r9, r11, r9, asl #6 @
|
||||
@
|
||||
add r8, r8, #2 @ r8 = bu = (Cb*128 + 128) >> 8
|
||||
mov r8, r8, asr #2 @
|
||||
add r9, r9, #256 @ r9 = rv = (r8 + 256) >> 9
|
||||
mov r9, r9, asr #9 @
|
||||
rsb r10, r10, #128 @ r10 = guv = (-r9 + 128) >> 8
|
||||
mov r10, r10, asr #8 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r3, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r3, #31 @ clamp b
|
||||
mvnhi r3, r3, asr #31 @
|
||||
andhi r3, r3, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
orr r3, r3, r11, lsl #11 @ r3 = b | (r << 11)
|
||||
orr r3, r3, r7, lsl #5 @ r3 |= (g << 5)
|
||||
@
|
||||
orr r7, r14, r3, lsr #8 @ store pixel
|
||||
orr r11, r14, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r7, r12, r7, asl #5 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r3, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r3, #31 @ clamp b
|
||||
mvnhi r3, r3, asr #31 @
|
||||
andhi r3, r3, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++)
|
||||
@
|
||||
orr r3, r3, r11, lsl #11 @ r3 = b | (r << 11)
|
||||
orr r3, r3, r7, lsl #5 @ r3 |= (g << 5)
|
||||
@
|
||||
orr r7, r14, r3, lsr #8 @ store pixel
|
||||
orr r11, r14, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r7, r12, r7, asl #5 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r3, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r3, #31 @ clamp b
|
||||
mvnhi r3, r3, asr #31 @
|
||||
andhi r3, r3, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
orr r3, r3, r7, lsl #5 @ r3 = b | (g << 5)
|
||||
orr r3, r3, r11, lsl #11 @ r3 |= (r << 11)
|
||||
@
|
||||
orr r7, r14, r3, lsr #8 @ store pixel
|
||||
orr r11, r14, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r7, r12, r7, asl #5 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu
|
||||
add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
|
||||
add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
|
||||
@
|
||||
orr r12, r3, r11 @ check if clamping is needed...
|
||||
orr r12, r12, r7, asr #1 @ ...at all
|
||||
cmp r12, #31 @
|
||||
bls 15f @ no clamp @
|
||||
cmp r3, #31 @ clamp b
|
||||
mvnhi r3, r3, asr #31 @
|
||||
andhi r3, r3, #31 @
|
||||
cmp r11, #31 @ clamp r
|
||||
mvnhi r11, r11, asr #31 @
|
||||
andhi r11, r11, #31 @
|
||||
cmp r7, #63 @ clamp g
|
||||
mvnhi r7, r7, asr #31 @
|
||||
andhi r7, r7, #63 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
orr r3, r3, r11, lsl #11 @ r3 = b | (r << 11)
|
||||
orr r3, r3, r7, lsl #5 @ r3 |= (g << 5)
|
||||
@
|
||||
orr r7, r14, r3, lsr #8 @ store pixel
|
||||
orr r11, r14, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
subs r1, r1, #2 @ subtract block from width
|
||||
bgt 10b @ loop line @
|
||||
@
|
||||
ldmfd sp!, { r4-r12, pc } @ restore registers and return
|
||||
.ltorg @ dump constant pool
|
||||
.size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* void lcd_write_yuv_420_lines_odither(unsigned char const * const src[3],
|
||||
* int width,
|
||||
* int stride,
|
||||
* int x_screen,
|
||||
* int y_screen);
|
||||
*
|
||||
* |R| |1.000000 -0.000001 1.402000| |Y'|
|
||||
* |G| = |1.000000 -0.334136 -0.714136| |Pb|
|
||||
* |B| |1.000000 1.772000 0.000000| |Pr|
|
||||
* Red scaled at twice g & b but at same precision to place it in correct
|
||||
* bit position after multiply and leave instruction count lower.
|
||||
* |R| |258 0 408| |Y' - 16|
|
||||
* |G| = |149 -49 -104| |Cb - 128|
|
||||
* |B| |149 258 0| |Cr - 128|
|
||||
*
|
||||
* Write four RGB565 pixels in the following order on each loop:
|
||||
* 1 3 + > down
|
||||
* 2 4 \/ left
|
||||
*
|
||||
* Kernel pattern (raw|use order):
|
||||
* 5 3 4 2 row0 row2 > down
|
||||
* 1 7 0 6 | 5 1 3 7 4 0 2 6 col0 left
|
||||
* 4 2 5 3 | 4 0 2 6 5 1 3 7 col2 \/
|
||||
* 0 6 1 7
|
||||
*/
|
||||
.section .icode, "ax", %progbits
|
||||
.align 2
|
||||
.global lcd_write_yuv420_lines_odither
|
||||
.type lcd_write_yuv420_lines_odither, %function
|
||||
lcd_write_yuv420_lines_odither:
|
||||
@ r0 = yuv_src
|
||||
@ r1 = width
|
||||
@ r2 = stride
|
||||
@ r3 = x_screen
|
||||
@ [sp] = y_screen
|
||||
stmfd sp!, { r4-r12, lr } @ save non-scratch
|
||||
ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p
|
||||
@ r5 = yuv_src[1] = Cb_p
|
||||
@ r6 = yuv_src[2] = Cr_p
|
||||
@
|
||||
ldr r0, [sp, #40] @ Line up pattern and kernel quadrant
|
||||
eor r14, r3, r0 @
|
||||
and r14, r14, #0x2 @
|
||||
mov r14, r14, lsl #6 @ 0x00 or 0x80
|
||||
@
|
||||
mov r0, #0x7000000c @ r0 = &LCD2_PORT = 0x70008a0c
|
||||
add r0, r0, #0x8a00 @
|
||||
@
|
||||
sub r2, r2, #1 @ Adjust stride because of increment
|
||||
10: @ loop line @
|
||||
@
|
||||
ldrb r7, [r4], #1 @ r7 = *Y'_p++;
|
||||
ldrb r8, [r5], #1 @ r8 = *Cb_p++;
|
||||
ldrb r9, [r6], #1 @ r9 = *Cr_p++;
|
||||
@
|
||||
eor r14, r14, #0x80 @ flip pattern quadrant
|
||||
@
|
||||
sub r7, r7, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@
|
||||
sub r8, r8, #128 @ Cb -= 128
|
||||
sub r9, r9, #128 @ Cr -= 128
|
||||
@
|
||||
add r10, r8, r8, asl #4 @ r10 = guv = Cr*104 + Cb*49
|
||||
add r10, r10, r8, asl #5 @
|
||||
add r10, r10, r9, asl #3 @
|
||||
add r10, r10, r9, asl #5 @
|
||||
add r10, r10, r9, asl #6 @
|
||||
@
|
||||
mov r8, r8, asl #1 @ r8 = bu = Cb*258
|
||||
add r8, r8, r8, asl #7 @
|
||||
@
|
||||
add r9, r9, r9, asl #1 @ r9 = rv = Cr*408
|
||||
add r9, r9, r9, asl #4 @
|
||||
mov r9, r9, asl #3 @
|
||||
@
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7 @ r3 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
@ r8 = bu, r9 = rv, r10 = guv
|
||||
@
|
||||
sub r12, r3, r3, lsr #5 @ r3 = 31/32*b + b/256
|
||||
add r3, r12, r3, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
add r12, r14, #0x200 @
|
||||
@
|
||||
add r3, r3, r12 @ b = r3 + delta
|
||||
add r11, r11, r12, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r12, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r3, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r3, asr #15 @ clamp b
|
||||
mvnne r3, r12, lsr #15 @
|
||||
andne r3, r3, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) |
|
||||
orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) |
|
||||
orr r3, r11, r3, lsr #10 @ (b >> 10)
|
||||
@
|
||||
mov r11, #LCD2_DATA_MASK @ store pixel
|
||||
orr r7, r11, r3, lsr #8 @
|
||||
orr r11, r11, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7 @ r3 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
sub r12, r3, r3, lsr #5 @ r3 = 31/32*b' + b'/256
|
||||
add r3, r12, r3, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
@ This element is zero - use r14 @
|
||||
@
|
||||
add r3, r3, r14 @ b = r3 + delta
|
||||
add r11, r11, r14, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r14, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r3, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r3, asr #15 @ clamp b
|
||||
mvnne r3, r12, lsr #15 @
|
||||
andne r3, r3, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++)
|
||||
@
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) |
|
||||
orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) |
|
||||
orr r3, r11, r3, lsr #10 @ (b >> 10)
|
||||
@
|
||||
mov r11, #LCD2_DATA_MASK @ store pixel
|
||||
orr r7, r11, r3, lsr #8 @
|
||||
orr r11, r11, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7 @ r3 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
@ r8 = bu, r9 = rv, r10 = guv
|
||||
@
|
||||
sub r12, r3, r3, lsr #5 @ r3 = 31/32*b' + b'/256
|
||||
add r3, r12, r3, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
add r12, r14, #0x100 @
|
||||
@
|
||||
add r3, r3, r12 @ b = r3 + delta
|
||||
add r11, r11, r12, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r12, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r3, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r3, asr #15 @ clamp b
|
||||
mvnne r3, r12, lsr #15 @
|
||||
andne r3, r3, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
|
||||
@
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) |
|
||||
orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) |
|
||||
orr r3, r11, r3, lsr #10 @ (b >> 10)
|
||||
@
|
||||
mov r11, #LCD2_DATA_MASK @ store pixel
|
||||
orr r7, r11, r3, lsr #8 @
|
||||
orr r11, r11, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149
|
||||
add r12, r7, r7, asl #2 @
|
||||
add r12, r12, r12, asl #4 @
|
||||
add r7, r12, r7, asl #6 @
|
||||
@ compute R, G, and B
|
||||
add r3, r8, r7 @ r3 = b' = Y + bu
|
||||
add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv
|
||||
rsb r7, r10, r7 @ r7 = g' = Y + guv
|
||||
@
|
||||
sub r12, r3, r3, lsr #5 @ r3 = 31/32*b + b/256
|
||||
add r3, r12, r3, lsr #8 @
|
||||
@
|
||||
sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256
|
||||
add r11, r12, r11, lsr #8 @
|
||||
@
|
||||
sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256
|
||||
add r7, r12, r7, lsr #8 @
|
||||
@
|
||||
add r12, r14, #0x300 @
|
||||
@
|
||||
add r3, r3, r12 @ b = r3 + delta
|
||||
add r11, r11, r12, lsl #1 @ r = r11 + delta*2
|
||||
add r7, r7, r12, lsr #1 @ g = r7 + delta/2
|
||||
@
|
||||
orr r12, r3, r11, asr #1 @ check if clamping is needed...
|
||||
orr r12, r12, r7 @ ...at all
|
||||
movs r12, r12, asr #15 @
|
||||
beq 15f @ no clamp @
|
||||
movs r12, r3, asr #15 @ clamp b
|
||||
mvnne r3, r12, lsr #15 @
|
||||
andne r3, r3, #0x7c00 @ mask b only if clamped
|
||||
movs r12, r11, asr #16 @ clamp r
|
||||
mvnne r11, r12, lsr #16 @
|
||||
movs r12, r7, asr #15 @ clamp g
|
||||
mvnne r7, r12, lsr #15 @
|
||||
15: @ no clamp @
|
||||
@
|
||||
and r11, r11, #0xf800 @ pack pixel
|
||||
and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) |
|
||||
orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) |
|
||||
orr r3, r11, r3, lsr #10 @ (b >> 10)
|
||||
@
|
||||
mov r11, #LCD2_DATA_MASK @ store pixel
|
||||
orr r7, r11, r3, lsr #8 @
|
||||
orr r11, r11, r3 @
|
||||
20: @
|
||||
ldr r3, [r0] @
|
||||
tst r3, #LCD2_BUSY_MASK @
|
||||
bne 20b @
|
||||
str r7, [r0] @
|
||||
str r11, [r0] @
|
||||
@
|
||||
subs r1, r1, #2 @ subtract block from width
|
||||
bgt 10b @ loop line @
|
||||
@
|
||||
ldmfd sp!, { r4-r12, pc } @ restore registers and return
|
||||
.ltorg @ dump constant pool
|
||||
.size lcd_write_yuv420_lines_odither, .-lcd_write_yuv420_lines_odither
|
||||
638
firmware/target/arm/samsung/yh925/lcd-yh925.c
Normal file
638
firmware/target/arm/samsung/yh925/lcd-yh925.c
Normal file
|
|
@ -0,0 +1,638 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "lcd.h"
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
|
||||
/** Initialized in lcd_init_device() **/
|
||||
/* Is the power turned on? */
|
||||
static bool power_on;
|
||||
/* Is the display turned on? */
|
||||
static bool display_on;
|
||||
/* Amount of vertical offset. Used for flip offset correction/detection. */
|
||||
static int y_offset;
|
||||
/* Reverse flag. Must be remembered when display is turned off. */
|
||||
static unsigned short disp_control_rev;
|
||||
/* Contrast setting << 8 */
|
||||
static int lcd_contrast;
|
||||
|
||||
static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
|
||||
|
||||
/* Forward declarations */
|
||||
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
||||
static void lcd_display_off(void);
|
||||
#endif
|
||||
|
||||
/* register defines for the Renesas HD66773R */
|
||||
#define R_START_OSC 0x00
|
||||
#define R_DEVICE_CODE_READ 0x00
|
||||
#define R_DRV_OUTPUT_CONTROL 0x01
|
||||
#define R_DRV_AC_CONTROL 0x02
|
||||
#define R_POWER_CONTROL1 0x03
|
||||
#define R_POWER_CONTROL2 0x04
|
||||
#define R_ENTRY_MODE 0x05
|
||||
#define R_COMPARE_REG 0x06
|
||||
#define R_DISP_CONTROL 0x07
|
||||
#define R_FRAME_CYCLE_CONTROL 0x0b
|
||||
#define R_POWER_CONTROL3 0x0c
|
||||
#define R_POWER_CONTROL4 0x0d
|
||||
#define R_POWER_CONTROL5 0x0e
|
||||
#define R_GATE_SCAN_START_POS 0x0f
|
||||
#define R_VERT_SCROLL_CONTROL 0x11
|
||||
#define R_1ST_SCR_DRV_POS 0x14
|
||||
#define R_2ND_SCR_DRV_POS 0x15
|
||||
#define R_HORIZ_RAM_ADDR_POS 0x16
|
||||
#define R_VERT_RAM_ADDR_POS 0x17
|
||||
#define R_RAM_WRITE_DATA_MASK 0x20
|
||||
#define R_RAM_ADDR_SET 0x21
|
||||
#define R_WRITE_DATA_2_GRAM 0x22
|
||||
#define R_RAM_READ_DATA 0x22
|
||||
#define R_GAMMA_FINE_ADJ_POS1 0x30
|
||||
#define R_GAMMA_FINE_ADJ_POS2 0x31
|
||||
#define R_GAMMA_FINE_ADJ_POS3 0x32
|
||||
#define R_GAMMA_GRAD_ADJ_POS 0x33
|
||||
#define R_GAMMA_FINE_ADJ_NEG1 0x34
|
||||
#define R_GAMMA_FINE_ADJ_NEG2 0x35
|
||||
#define R_GAMMA_FINE_ADJ_NEG3 0x36
|
||||
#define R_GAMMA_GRAD_ADJ_NEG 0x37
|
||||
#define R_GAMMA_AMP_ADJ_POS 0x3a
|
||||
#define R_GAMMA_AMP_ADJ_NEG 0x3b
|
||||
|
||||
static inline void lcd_wait_write(void)
|
||||
{
|
||||
while (LCD2_PORT & LCD2_BUSY_MASK);
|
||||
}
|
||||
|
||||
/* Send command */
|
||||
static inline void lcd_send_cmd(unsigned cmd)
|
||||
{
|
||||
lcd_wait_write();
|
||||
LCD2_PORT = LCD2_CMD_MASK; /* Send MSB first (should always be 0) */
|
||||
lcd_wait_write();
|
||||
LCD2_PORT = LCD2_CMD_MASK | cmd;
|
||||
}
|
||||
|
||||
/* Send 16-bit data */
|
||||
static inline void lcd_send_data(unsigned data)
|
||||
{
|
||||
lcd_wait_write();
|
||||
LCD2_PORT = (data >> 8) | LCD2_DATA_MASK; /* Send MSB first */
|
||||
lcd_wait_write();
|
||||
LCD2_PORT = (data & 0xff) | LCD2_DATA_MASK;
|
||||
}
|
||||
|
||||
/* Send 16-bit data byte-swapped. Only needed until we can use block transfer. */
|
||||
static inline void lcd_send_data_swapped(unsigned v)
|
||||
{
|
||||
lcd_wait_write();
|
||||
LCD2_PORT = LCD2_DATA_MASK | (v & 0xff); /* Send LSB first */
|
||||
LCD2_PORT = LCD2_DATA_MASK | (v >> 8);
|
||||
}
|
||||
|
||||
/* Write value to register */
|
||||
static void lcd_write_reg(int reg, int val)
|
||||
{
|
||||
lcd_send_cmd(reg);
|
||||
lcd_send_data(val);
|
||||
}
|
||||
|
||||
/*** hardware configuration ***/
|
||||
|
||||
int lcd_default_contrast(void)
|
||||
{
|
||||
return DEFAULT_CONTRAST_SETTING;
|
||||
}
|
||||
|
||||
void lcd_set_contrast(int val)
|
||||
{
|
||||
/* Clamp val in range 0-14, 16-30 */
|
||||
if (val < 1)
|
||||
val = 0;
|
||||
else if (val <= 15)
|
||||
--val;
|
||||
else if (val > 30)
|
||||
val = 30;
|
||||
|
||||
lcd_contrast = val << 8;
|
||||
|
||||
if (!power_on)
|
||||
return;
|
||||
|
||||
/* VCOMG=1, VDV4-0=xxxxx, VCM4-0=11000 */
|
||||
lcd_write_reg(R_POWER_CONTROL5, 0x2018 | lcd_contrast);
|
||||
}
|
||||
|
||||
void lcd_set_invert_display(bool yesno)
|
||||
{
|
||||
if (yesno == (disp_control_rev == 0x0000))
|
||||
return;
|
||||
|
||||
disp_control_rev = yesno ? 0x0000 : 0x0004;
|
||||
|
||||
if (!display_on)
|
||||
return;
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0033 | disp_control_rev);
|
||||
}
|
||||
|
||||
|
||||
/* turn the display upside down (call lcd_update() afterwards) */
|
||||
void lcd_set_flip(bool yesno)
|
||||
{
|
||||
/* NOT MODIFIED FOR THE YH-925 */
|
||||
|
||||
if (yesno == (y_offset != 0))
|
||||
return;
|
||||
|
||||
/* The LCD controller is 132x160 while the LCD itself is 128x160, so we need
|
||||
* to shift the origin by 4 when we flip the LCD */
|
||||
y_offset = yesno ? 4 : 0;
|
||||
|
||||
if (!power_on)
|
||||
return;
|
||||
|
||||
/* SCN4-0=000x0 (G1/G160) */
|
||||
lcd_write_reg(R_GATE_SCAN_START_POS, yesno ? 0x0002 : 0x0000);
|
||||
/* SM=0, GS=x, SS=x, NL4-0=10011 (G1-G160) */
|
||||
lcd_write_reg(R_DRV_OUTPUT_CONTROL, yesno ? 0x0213 : 0x0113);
|
||||
}
|
||||
|
||||
/* LCD init */
|
||||
void lcd_init_device(void)
|
||||
{
|
||||
#if 0
|
||||
/* This is the OF LCD init */
|
||||
int i;
|
||||
|
||||
DEV_EN2 |= 0x2000;
|
||||
DEV_INIT1 |= 0xfc000000;
|
||||
CLCD_CLOCK_SRC &= ~0xf;
|
||||
DEV_INIT2 &= ~0x400;
|
||||
|
||||
GPIOF_ENABLE |= 0x4;
|
||||
GPIOF_OUTPUT_EN |= 0x4;
|
||||
GPIOF_OUTPUT_VAL &= ~0x4;
|
||||
udelay(300000);
|
||||
GPIOF_OUTPUT_VAL |= 0x4;
|
||||
|
||||
outl(0x220, 0x70008a00);
|
||||
outl(0x1f00, 0x70008a04);
|
||||
LCD2_BLOCK_CTRL = 0x10008080;
|
||||
LCD2_BLOCK_CONFIG = 0xf00000;
|
||||
udelay(100000);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
lcd_send_data(0);
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
lcd_write_reg(R_START_OSC, 0x0001);
|
||||
udelay(20000);
|
||||
lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0315);
|
||||
lcd_write_reg(R_DRV_AC_CONTROL, 0x0700);
|
||||
lcd_write_reg(R_ENTRY_MODE, 0x1028);
|
||||
lcd_write_reg(R_COMPARE_REG, 0x0000);
|
||||
lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x4008);
|
||||
lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0700);
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0000);
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
|
||||
lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0100);
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0707);
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0007);
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0700);
|
||||
lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0001);
|
||||
lcd_write_reg(R_GATE_SCAN_START_POS, 0x0000);
|
||||
lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
|
||||
lcd_write_reg(R_1ST_SCR_DRV_POS, 0xaf10);
|
||||
lcd_write_reg(R_2ND_SCR_DRV_POS, 0x0000);
|
||||
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00); /* ((LCD_HEIGHT - 1) << 8 | 0 */
|
||||
lcd_write_reg(R_VERT_RAM_ADDR_POS, 0xaf10); /* ((LCD_WIDTH + 16 - 1) << 8) | 16 */
|
||||
lcd_write_reg(R_GAMMA_AMP_ADJ_POS, 0x1600);
|
||||
lcd_write_reg(R_GAMMA_AMP_ADJ_NEG, 0x0006);
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0104);
|
||||
lcd_write_reg(R_POWER_CONTROL4, 0x0100);
|
||||
lcd_write_reg(R_POWER_CONTROL5, 0x0d18);
|
||||
lcd_write_reg(R_POWER_CONTROL3, 0x0000);
|
||||
udelay(50000);
|
||||
lcd_write_reg(R_POWER_CONTROL1, 0x0008);
|
||||
lcd_write_reg(R_POWER_CONTROL3, 0x0000);
|
||||
lcd_write_reg(R_POWER_CONTROL2, 0x0000);
|
||||
udelay(50000);
|
||||
lcd_write_reg(R_POWER_CONTROL5, 0x2d18);
|
||||
lcd_write_reg(R_POWER_CONTROL3, 0x0000);
|
||||
udelay(50000);
|
||||
lcd_write_reg(R_POWER_CONTROL4, 0x0110);
|
||||
//~ lcd_clear_display();
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0105);
|
||||
udelay(20000);
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0125);
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0127);
|
||||
udelay(20000);
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0137);
|
||||
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
|
||||
|
||||
GPIOF_ENABLE |= 0x02;
|
||||
GPIOF_OUTPUT_EN |= 0x02;
|
||||
GPIOF_OUTPUT_VAL |= 0x02;
|
||||
#endif
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
/* The OF won't boot if this is done in the bootloader - ideally we should
|
||||
tweak the lcd controller speed settings but this will do for now */
|
||||
CLCD_CLOCK_SRC |= 0xc0000000; /* Set LCD interface clock to PLL */
|
||||
#endif
|
||||
|
||||
/* only these bits are needed from the OF init */
|
||||
lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0215);
|
||||
lcd_write_reg(R_ENTRY_MODE, 0x1028);
|
||||
|
||||
power_on = true;
|
||||
display_on = true;
|
||||
y_offset = 0;
|
||||
disp_control_rev = 0x0004;
|
||||
lcd_contrast = DEFAULT_CONTRAST_SETTING << 8;
|
||||
}
|
||||
|
||||
/* THE SLEEP AND POWER FUNCTIONS HAVE NOT BEEN MODIFIED FOR THE YH-925 */
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
static void lcd_power_on(void)
|
||||
{
|
||||
/* Be sure standby bit is clear. */
|
||||
/* BT2-0=000, DC2-0=000, AP2-0=000, SLP=0, STB=0 */
|
||||
lcd_write_reg(R_POWER_CONTROL1, 0x0000);
|
||||
|
||||
/** Power ON Sequence **/
|
||||
/* Per datasheet Rev.1.10, Jun.21.2003, p. 99 */
|
||||
|
||||
lcd_write_reg(R_START_OSC, 0x0001); /* Start Oscillation */
|
||||
/* 10ms or more for oscillation circuit to stabilize */
|
||||
sleep(HZ/50);
|
||||
/* Instruction (1) for power setting; VC2-0, VRH3-0, CAD,
|
||||
VRL3-0, VCM4-0, VDV4-0 */
|
||||
/* VC2-0=001 */
|
||||
lcd_write_reg(R_POWER_CONTROL3, 0x0001);
|
||||
/* VRL3-0=0100, PON=0, VRH3-0=0001 */
|
||||
lcd_write_reg(R_POWER_CONTROL4, 0x0401);
|
||||
/* CAD=1 */
|
||||
lcd_write_reg(R_POWER_CONTROL2, 0x8000);
|
||||
/* VCOMG=0, VDV4-0=xxxxx (19), VCM4-0=11000 */
|
||||
lcd_write_reg(R_POWER_CONTROL5, 0x0018 | lcd_contrast);
|
||||
/* Instruction (2) for power setting; BT2-0, DC2-0, AP2-0 */
|
||||
/* BT2-0=000, DC2-0=001, AP2-0=011, SLP=0, STB=0 */
|
||||
lcd_write_reg(R_POWER_CONTROL1, 0x002c);
|
||||
/* Instruction (3) for power setting; VCOMG = "1" */
|
||||
/* VCOMG=1, VDV4-0=xxxxx (19), VCM4-0=11000 */
|
||||
lcd_write_reg(R_POWER_CONTROL5, 0x2018 | lcd_contrast);
|
||||
|
||||
/* 40ms or more; time for step-up circuits 1,2 to stabilize */
|
||||
sleep(HZ/25);
|
||||
|
||||
/* Instruction (4) for power setting; PON = "1" */
|
||||
/* VRL3-0=0100, PON=1, VRH3-0=0001 */
|
||||
lcd_write_reg(R_POWER_CONTROL4, 0x0411);
|
||||
|
||||
/* 40ms or more; time for step-up circuit 4 to stabilize */
|
||||
sleep(HZ/25);
|
||||
|
||||
/* Instructions for other mode settings (in register order). */
|
||||
/* SM=0, GS=x, SS=0, NL4-0=10011 (G1-G160)*/
|
||||
lcd_write_reg(R_DRV_OUTPUT_CONTROL, y_offset ? 0x0013 : 0x0113); /* different to X5 */
|
||||
/* FLD1-0=01 (1 field), B/C=1, EOR=1 (C-pat), NW5-0=000000 (1 row) */
|
||||
lcd_write_reg(R_DRV_AC_CONTROL, 0x0700);
|
||||
/* DIT=0, BGR=1, HWM=0, I/D1-0=10, AM=1, LG2-0=000 */
|
||||
lcd_write_reg(R_ENTRY_MODE, 0x1028); /* different to X5 */
|
||||
/* CP15-0=0000000000000000 */
|
||||
lcd_write_reg(R_COMPARE_REG, 0x0000);
|
||||
/* NO1-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-00000 */
|
||||
lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x4000);
|
||||
/* SCN4-0=000x0 (G1/G160) */
|
||||
/* lcd_write_reg(R_GATE_SCAN_START_POS, y_offset ? 0x0000 : 0x0002); */
|
||||
/* VL7-0=0x00 */
|
||||
lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
|
||||
/* SE17-10(End)=0x9f (159), SS17-10(Start)=0x00 */
|
||||
lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
|
||||
/* SE27-20(End)=0x5c (92), SS27-20(Start)=0x00 */
|
||||
lcd_write_reg(R_2ND_SCR_DRV_POS, 0x5c00);
|
||||
/* HEA7-0=7f, HSA7-0=00 */
|
||||
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
|
||||
/* PKP12-10=0x0, PKP02-00=0x0 */
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0003);
|
||||
/* PKP32-30=0x4, PKP22-20=0x0 */
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0400);
|
||||
/* PKP52-50=0x4, PKP42-40=0x7 */
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0407);
|
||||
/* PRP12-10=0x3, PRP02-00=0x5 */
|
||||
lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
|
||||
/* PKN12-10=0x0, PKN02-00=0x3 */
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0003);
|
||||
/* PKN32-30=0x7, PKN22-20=0x4 */
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0704);
|
||||
/* PKN52-50=0x4, PRN42-40=0x7 */
|
||||
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0407);
|
||||
/* PRN12-10=0x5, PRN02-00=0x3 */
|
||||
lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
|
||||
/* VRP14-10=0x14, VRP03-00=0x09 */
|
||||
lcd_write_reg(R_GAMMA_AMP_ADJ_POS, 0x1409);
|
||||
/* VRN14-00=0x06, VRN03-00=0x02 */
|
||||
lcd_write_reg(R_GAMMA_AMP_ADJ_NEG, 0x0602);
|
||||
|
||||
/* 100ms or more; time for step-up circuits to stabilize */
|
||||
sleep(HZ/10);
|
||||
|
||||
power_on = true;
|
||||
}
|
||||
|
||||
static void lcd_power_off(void)
|
||||
{
|
||||
/* Display must be off first */
|
||||
if (display_on)
|
||||
lcd_display_off();
|
||||
|
||||
power_on = false;
|
||||
|
||||
/** Power OFF sequence **/
|
||||
/* Per datasheet Rev.1.10, Jun.21.2003, p. 99 */
|
||||
|
||||
/* Step-up1 halt setting bit */
|
||||
/* BT2-0=110, DC2-0=001, AP2-0=011, SLP=0, STB=0 */
|
||||
lcd_write_reg(R_POWER_CONTROL1, 0x062c);
|
||||
/* Step-up3,4 halt setting bit */
|
||||
/* VRL3-0=0100, PON=0, VRH3-0=0001 */
|
||||
lcd_write_reg(R_POWER_CONTROL4, 0x0401);
|
||||
/* VCOMG=0, VDV4-0=10011, VCM4-0=11000 */
|
||||
lcd_write_reg(R_POWER_CONTROL5, 0x0018 | lcd_contrast);
|
||||
|
||||
/* Wait 100ms or more */
|
||||
sleep(HZ/10);
|
||||
|
||||
/* Step-up2,amp halt setting bit */
|
||||
/* BT2-0=000, DC2-0=000, AP2-0=000, SLP=0, STB=0 */
|
||||
lcd_write_reg(R_POWER_CONTROL1, 0x0000);
|
||||
}
|
||||
|
||||
void lcd_sleep(void)
|
||||
{
|
||||
if (power_on)
|
||||
lcd_power_off();
|
||||
|
||||
/* Set standby mode */
|
||||
/* BT2-0=000, DC2-0=000, AP2-0=000, SLP=0, STB=1 */
|
||||
lcd_write_reg(R_POWER_CONTROL1, 0x0001);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
||||
static void lcd_display_off(void)
|
||||
{
|
||||
display_on = false;
|
||||
|
||||
/** Display OFF sequence **/
|
||||
/* Per datasheet Rev.1.10, Jun.21.2003, p. 97 */
|
||||
|
||||
/* EQ1-0=00 already */
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=10 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0032 | disp_control_rev);
|
||||
|
||||
sleep(HZ/25); /* Wait 2 frames or more */
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=10 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0022 | disp_control_rev);
|
||||
|
||||
sleep(HZ/25); /* Wait 2 frames or more */
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=0, DTE=0, REV=0, D1-0=00 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0000);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LCD_ENABLE)
|
||||
static void lcd_display_on(void)
|
||||
{
|
||||
/* Be sure power is on first */
|
||||
if (!power_on)
|
||||
lcd_power_on();
|
||||
|
||||
/** Display ON Sequence **/
|
||||
/* Per datasheet Rev.1.10, Jun.21.2003, p. 97 */
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=0, DTE=0, REV=0, D1-0=01 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0001);
|
||||
|
||||
sleep(HZ/25); /* Wait 2 frames or more */
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=01 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0021 | disp_control_rev);
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=11 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0023 | disp_control_rev);
|
||||
|
||||
sleep(HZ/25); /* Wait 2 frames or more */
|
||||
|
||||
/* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */
|
||||
lcd_write_reg(R_DISP_CONTROL, 0x0033 | disp_control_rev);
|
||||
|
||||
display_on = true;
|
||||
}
|
||||
|
||||
void lcd_enable(bool on)
|
||||
{
|
||||
if (on == display_on)
|
||||
return;
|
||||
|
||||
if (on)
|
||||
{
|
||||
lcd_display_on();
|
||||
/* Probably out of sync and we don't wanna pepper the code with
|
||||
lcd_update() calls for this. */
|
||||
lcd_update();
|
||||
lcd_activation_call_hook();
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_display_off();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
||||
bool lcd_active(void)
|
||||
{
|
||||
return display_on;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*** update functions ***/
|
||||
|
||||
void lcd_yuv_set_options(unsigned options)
|
||||
{
|
||||
lcd_yuv_options = options;
|
||||
}
|
||||
|
||||
/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
|
||||
extern void lcd_write_yuv420_lines(unsigned char const * const src[3],
|
||||
int width,
|
||||
int stride);
|
||||
extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3],
|
||||
int width,
|
||||
int stride,
|
||||
int x_screen, /* To align dither pattern */
|
||||
int y_screen);
|
||||
|
||||
/* Performance function to blit a YUV bitmap directly to the LCD */
|
||||
void lcd_blit_yuv(unsigned char * const src[3],
|
||||
int src_x, int src_y, int stride,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
const unsigned char *yuv_src[3];
|
||||
const unsigned char *ysrc_max;
|
||||
int y0;
|
||||
int options;
|
||||
|
||||
/* NOT MODIFIED FOR THE YH-925 */
|
||||
|
||||
if (!display_on)
|
||||
return;
|
||||
|
||||
width &= ~1;
|
||||
height &= ~1;
|
||||
|
||||
/* calculate the drawing region */
|
||||
|
||||
/* The 20GB LCD is actually 128x160 but rotated 90 degrees so the origin
|
||||
* is actually the bottom left and horizontal and vertical are swapped.
|
||||
* Rockbox expects the origin to be the top left so we need to use
|
||||
* 127 - y instead of just y */
|
||||
|
||||
/* max vert << 8 | start vert */
|
||||
lcd_write_reg(R_VERT_RAM_ADDR_POS, ((x + width - 1) << 8) | x);
|
||||
|
||||
y0 = LCD_HEIGHT - 1 - y + y_offset;
|
||||
|
||||
/* DIT=0, BGR=1, HWM=0, I/D1-0=10, AM=0, LG2-0=000 */
|
||||
lcd_write_reg(R_ENTRY_MODE, 0x1020);
|
||||
|
||||
yuv_src[0] = src[0] + src_y * stride + src_x;
|
||||
yuv_src[1] = src[1] + (src_y * stride >> 2) + (src_x >> 1);
|
||||
yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
|
||||
ysrc_max = yuv_src[0] + height * stride;
|
||||
|
||||
options = lcd_yuv_options;
|
||||
|
||||
do
|
||||
{
|
||||
/* max horiz << 8 | start horiz */
|
||||
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (y0 << 8) | (y0 - 1));
|
||||
|
||||
/* position cursor (set AD0-AD15) */
|
||||
/* start vert << 8 | start horiz */
|
||||
lcd_write_reg(R_RAM_ADDR_SET, (x << 8) | y0);
|
||||
|
||||
/* start drawing */
|
||||
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
|
||||
|
||||
if (options & LCD_YUV_DITHER)
|
||||
{
|
||||
lcd_write_yuv420_lines_odither(yuv_src, width, stride,
|
||||
x, y);
|
||||
y -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_write_yuv420_lines(yuv_src, width, stride);
|
||||
}
|
||||
|
||||
y0 -= 2;
|
||||
yuv_src[0] += stride << 1;
|
||||
yuv_src[1] += stride >> 1;
|
||||
yuv_src[2] += stride >> 1;
|
||||
}
|
||||
while (yuv_src[0] < ysrc_max);
|
||||
|
||||
/* DIT=0, BGR=1, HWM=0, I/D1-0=10, AM=1, LG2-0=000 */
|
||||
lcd_write_reg(R_ENTRY_MODE, 0x1028);
|
||||
}
|
||||
|
||||
|
||||
/* Update a fraction of the display. */
|
||||
void lcd_update_rect(int x0, int y0, int width, int height)
|
||||
{
|
||||
int x1, y1;
|
||||
int lcd_x0, lcd_x1, lcd_y0, lcd_y1;
|
||||
unsigned short *addr;
|
||||
|
||||
if (!display_on)
|
||||
return;
|
||||
|
||||
/* calculate the drawing region */
|
||||
y1 = (y0 + height) - 1; /* max vert */
|
||||
x1 = (x0 + width) - 1; /* max horiz */
|
||||
|
||||
if(x1 >= LCD_WIDTH)
|
||||
x1 = LCD_WIDTH - 1;
|
||||
if (x1 <= 0)
|
||||
return; /* nothing left to do, 0 is harmful to lcd_write_data() */
|
||||
if(y1 >= LCD_HEIGHT)
|
||||
y1 = LCD_HEIGHT-1;
|
||||
|
||||
/* The LCD is actually 128x160 rotated 90 degrees */
|
||||
lcd_x0 = (LCD_HEIGHT - 1) - y1 + 4;
|
||||
lcd_x1 = (LCD_HEIGHT - 1) - y0 + 4;
|
||||
lcd_y0 = x0 + 16;
|
||||
lcd_y1 = x1 + 16;
|
||||
|
||||
/* set the drawing window */
|
||||
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (lcd_x1 << 8) | lcd_x0);
|
||||
lcd_write_reg(R_VERT_RAM_ADDR_POS, (lcd_y1 << 8) | lcd_y0);
|
||||
|
||||
/* set the starting position */
|
||||
lcd_write_reg(R_RAM_ADDR_SET, (lcd_y0 << 8) | lcd_x1);
|
||||
|
||||
/* start drawing */
|
||||
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
|
||||
|
||||
addr = (unsigned short*)&lcd_framebuffer[y0][x0];
|
||||
|
||||
int c, r;
|
||||
|
||||
/* for each row */
|
||||
for (r = 0; r < height; r++) {
|
||||
/* for each column */
|
||||
for (c = 0; c < width; c++) {
|
||||
/* output 1 pixel */
|
||||
lcd_send_data(*addr++);
|
||||
}
|
||||
|
||||
addr += (LCD_WIDTH - width);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the display.
|
||||
This must be called after all other LCD functions that change the display. */
|
||||
void lcd_update(void)
|
||||
{
|
||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
}
|
||||
59
firmware/target/arm/samsung/yh925/powermgmt-yh925.c
Normal file
59
firmware/target/arm/samsung/yh925/powermgmt-yh925.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
|
||||
* Revisions copyright (C) 2005 by Gerald Van Baren
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
|
||||
/* TODO: Not yet calibrated */
|
||||
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3733
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3627
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 3733, 3772, 3821, 3840, 3869, 3917, 3985, 4034, 4072, 4140, 4198 }
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
3956, 3995, 4024, 4043, 4063, 4082, 4111, 4140, 4179, 4218, 4266
|
||||
};
|
||||
|
||||
#define BATTERY_SCALE_FACTOR 4650
|
||||
/* full-scale ADC readout (2^10) in millivolt */
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
unsigned int battery_adc_voltage(void)
|
||||
{
|
||||
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
|
||||
return 4100;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue