DM320: Regorganize LCD and TTB memory layout

Do not introduce any change for M:Robe 500 as it uses the two LCD frames
in non-obvious way.

Sansa Connect and Creative ZVM use only single front framebuffer.
Place TTB at DRAM end to minimize memory loss due to alignment.
Reserve as little as possible memory for the LCD frames.
On Sansa Connect this change extends audio buffer by 858 KiB.

Change-Id: I21bdeec4cfba86d71803a39acd651a87e73767e6
This commit is contained in:
Tomasz Moń 2021-07-08 18:23:18 +02:00
parent 2e9b93dc5d
commit 60e2cd6de9
4 changed files with 93 additions and 42 deletions

View file

@ -36,7 +36,6 @@ OUTPUT_FORMAT(elf32-littlemips)
#elif CONFIG_CPU==DM320 #elif CONFIG_CPU==DM320
/* Give this 1 meg to allow it to align to the MMU boundary */
#ifndef LCD_NATIVE_WIDTH #ifndef LCD_NATIVE_WIDTH
#define LCD_NATIVE_WIDTH LCD_WIDTH #define LCD_NATIVE_WIDTH LCD_WIDTH
#endif #endif
@ -45,9 +44,17 @@ OUTPUT_FORMAT(elf32-littlemips)
#define LCD_NATIVE_HEIGHT LCD_HEIGHT #define LCD_NATIVE_HEIGHT LCD_HEIGHT
#endif #endif
#ifdef MROBE_500
/* Give this 1 meg to allow it to align to the MMU boundary */
#define LCD_FUDGE LCD_NATIVE_WIDTH%32 #define LCD_FUDGE LCD_NATIVE_WIDTH%32
#define LCD_BUFFER_SIZE ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2) #define LCD_BUFFER_SIZE ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2)
#define LCD_TTB_AREA 0x100000*((LCD_BUFFER_SIZE>>19)+1) #define LCD_TTB_AREA 0x100000*((LCD_BUFFER_SIZE>>19)+1)
#else
/* must be 16Kb (0x4000) aligned */
#define TTB_SIZE (0x4000)
#define LCD_BUFFER_SIZE (LCD_NATIVE_WIDTH*LCD_NATIVE_HEIGHT*2)
#define LCD_TTB_AREA (TTB_SIZE + LCD_BUFFER_SIZE)
#endif
#define DRAMSIZE (MEMORYSIZE * 0x100000) - STUBOFFSET - PLUGIN_BUFFER_SIZE - CODEC_SIZE - LCD_TTB_AREA #define DRAMSIZE (MEMORYSIZE * 0x100000) - STUBOFFSET - PLUGIN_BUFFER_SIZE - CODEC_SIZE - LCD_TTB_AREA

View file

@ -30,13 +30,17 @@
#if !defined(__ASSEMBLER__) && !defined(__LD__) #if !defined(__ASSEMBLER__) && !defined(__LD__)
/* These variables are created during linking (app/boot.lds) */ /* These variables are created during linking (app/boot.lds) */
extern unsigned long _lcdbuf; extern unsigned long _lcdbuf;
#ifdef MROBE_500
extern unsigned long _lcdbuf2; extern unsigned long _lcdbuf2;
#endif
extern unsigned long _ttbstart; extern unsigned long _ttbstart;
#endif #endif
#define TTB_BASE_ADDR (_ttbstart) /* End of memory */ #define TTB_BASE_ADDR (_ttbstart) /* End of memory */
#define FRAME ((short *) (&_lcdbuf)) /* Right after TTB */ #define FRAME ((short *) (&_lcdbuf)) /* Right after TTB */
#ifdef MROBE_500
#define FRAME2 ((short *) (&_lcdbuf2)) /* Right after FRAME */ #define FRAME2 ((short *) (&_lcdbuf2)) /* Right after FRAME */
#endif
#define PHY_IO_BASE 0x00030000 #define PHY_IO_BASE 0x00030000
#define DM320_REG(addr) (*(volatile unsigned short *)(PHY_IO_BASE + (addr))) #define DM320_REG(addr) (*(volatile unsigned short *)(PHY_IO_BASE + (addr)))

View file

@ -14,22 +14,29 @@ STARTUP(target/arm/tms320dm320/crt0.o)
#define LCD_NATIVE_HEIGHT LCD_HEIGHT #define LCD_NATIVE_HEIGHT LCD_HEIGHT
#endif #endif
#define LCD_FUDGE LCD_NATIVE_WIDTH%32
#define LCD_BUFFER_SIZE ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2)
/* must be 16Kb (0x4000) aligned */ /* must be 16Kb (0x4000) aligned */
#define TTB_SIZE 0x4000 #define TTB_SIZE 0x4000
#define DRAMSIZE (MEMORYSIZE * 0x100000)
#define DRAMORIG CONFIG_SDRAM_START
#ifdef MROBE_500
#define LCD_FUDGE LCD_NATIVE_WIDTH%32
#define LCD_BUFFER_SIZE ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2)
/* Give this some memory to allow it to align to the MMU boundary. /* Give this some memory to allow it to align to the MMU boundary.
* Note that since there are two buffers (YUV/RGB) it calculates the approximate * Note that since there are two buffers (YUV/RGB) it calculates the approximate
* memory needed in steps of 1 Meg. * memory needed in steps of 1 Meg.
*/ */
#define LCD_TTB_AREA 0x100000*((LCD_BUFFER_SIZE>>19)+1) #define LCD_TTB_AREA (0x100000*((LCD_BUFFER_SIZE>>19)+1))
#else
#define LCD_BUFFER_SIZE (LCD_NATIVE_WIDTH*LCD_NATIVE_HEIGHT*2)
#define LCD_TTB_AREA (TTB_SIZE + LCD_BUFFER_SIZE)
#endif
#define DRAMSIZE (MEMORYSIZE * 0x100000) /* End of the audio buffer, where the codec buffer starts */
#define ENDAUDIOADDR \
#define DRAMORIG CONFIG_SDRAM_START (DRAMORIG + DRAMSIZE - PLUGIN_BUFFER_SIZE - CODEC_SIZE - LCD_TTB_AREA)
#define FLASHORIG 0x00100000 #define FLASHORIG 0x00100000
#define FLASHSIZE 0x00800000 #define FLASHSIZE 0x00800000
@ -44,10 +51,6 @@ PRO_STACK_SIZE = 0x2000;
IRQ_STACK_SIZE = 0x600; IRQ_STACK_SIZE = 0x600;
FIQ_STACK_SIZE = 0x400; FIQ_STACK_SIZE = 0x400;
/* End of the audio buffer, where the codec buffer starts */
#define ENDAUDIOADDR \
(DRAMORIG + DRAMSIZE - PLUGIN_BUFFER_SIZE - CODEC_SIZE - LCD_TTB_AREA)
MEMORY MEMORY
{ {
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
@ -196,6 +199,7 @@ SECTIONS
_endsdram = .; _endsdram = .;
#ifdef MROBE_500
.ttbtable (NOLOAD) : .ttbtable (NOLOAD) :
{ {
. = ALIGN (0x4000); . = ALIGN (0x4000);
@ -219,5 +223,21 @@ SECTIONS
_lcdbuf2 = .; _lcdbuf2 = .;
. += LCD_BUFFER_SIZE; . += LCD_BUFFER_SIZE;
} > DRAM } > DRAM
#else
.lcdbuffer (NOLOAD) :
{
. = ALIGN(32);
_lcdbuf = .;
. += LCD_BUFFER_SIZE;
} > DRAM
/* Place TTB at the end of RAM to minimize alignment losses */
.ttbtable (NOLOAD) :
{
. = ALIGN (0x4000);
_ttbstart = .;
. += TTB_SIZE;
} > DRAM
#endif
} }

View file

@ -14,22 +14,28 @@ STARTUP(target/arm/tms320dm320/crt0.o)
#define LCD_NATIVE_HEIGHT LCD_HEIGHT #define LCD_NATIVE_HEIGHT LCD_HEIGHT
#endif #endif
#define LCD_FUDGE LCD_NATIVE_WIDTH%32
#define LCD_BUFFER_SIZE ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2)
/* must be 16Kb (0x4000) aligned */ /* must be 16Kb (0x4000) aligned */
#define TTB_SIZE (0x4000) #define TTB_SIZE (0x4000)
/* Bootloader only uses/knows about the upper 32 M */
#define DRAMSIZE (MEMORYSIZE * 0x100000 / 2)
#define DRAMORIG CONFIG_SDRAM_START+DRAMSIZE
#ifdef MROBE_500
#define LCD_FUDGE LCD_NATIVE_WIDTH%32
#define LCD_BUFFER_SIZE ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2)
/* Give this some memory to allow it to align to the MMU boundary. /* Give this some memory to allow it to align to the MMU boundary.
* Note that since there are two buffers (YUV/RGB) it calculates the approximate * Note that since there are two buffers (YUV/RGB) it calculates the approximate
* memory needed in steps of 1 Meg. * memory needed in steps of 1 Meg.
*/ */
#define LCD_TTB_AREA 0x100000*((LCD_BUFFER_SIZE>>19)+1) #define LCD_TTB_AREA (0x100000*((LCD_BUFFER_SIZE>>19)+1))
/* End of the audio buffer, where the codec buffer starts */
/* Bootloader only uses/knows about the upper 32 M */ #define TTB_BEGIN (DRAMORIG + DRAMSIZE - LCD_TTB_AREA)
#define DRAMORIG CONFIG_SDRAM_START+0x02000000 #else
#define DRAMSIZE (MEMORYSIZE * 0x80000) #define LCD_BUFFER_SIZE (LCD_NATIVE_WIDTH*LCD_NATIVE_HEIGHT*2)
#define LCD_TTB_AREA (TTB_SIZE + LCD_BUFFER_SIZE)
#define LCD_BEGIN (DRAMORIG + DRAMSIZE - LCD_TTB_AREA)
#endif
#define IRAMORIG 0x00000000 #define IRAMORIG 0x00000000
#define IRAMSIZE 0x4000 #define IRAMSIZE 0x4000
@ -59,9 +65,6 @@ PRO_STACK_SIZE = 0x2000;
IRQ_STACK_SIZE = 0x400; IRQ_STACK_SIZE = 0x400;
FIQ_STACK_SIZE = 0x400; FIQ_STACK_SIZE = 0x400;
/* End of the audio buffer, where the codec buffer starts */
#define TTB_BEGIN (DRAMORIG + DRAMSIZE - LCD_TTB_AREA)
MEMORY MEMORY
{ {
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
@ -187,6 +190,7 @@ SECTIONS
_fiq_stack_start = .; _fiq_stack_start = .;
} > IRAM } > IRAM
#ifdef MROBE_500
.ttbtable TTB_BEGIN (NOLOAD) : .ttbtable TTB_BEGIN (NOLOAD) :
{ {
. = ALIGN (0x4000); . = ALIGN (0x4000);
@ -210,4 +214,20 @@ SECTIONS
_lcdbuf2 = .; _lcdbuf2 = .;
. += LCD_BUFFER_SIZE; . += LCD_BUFFER_SIZE;
} > DRAM } > DRAM
#else
.lcdbuffer LCD_BEGIN (NOLOAD) :
{
. = ALIGN(32);
_lcdbuf = .;
. += LCD_BUFFER_SIZE;
} > DRAM
/* Place TTB at the end of RAM to minimize alignment losses */
.ttbtable (NOLOAD) :
{
. = ALIGN (0x4000);
_ttbstart = .;
. += TTB_SIZE;
} > DRAM
#endif
} }