📄 osddrv.c
字号:
#include "st92196.h"
#include "macro.h"
#include "tv_glob.h"
#include "register.h"
#include "osddrv.h"
/*================================================================================================
init_osd
--------------------------------------------------------------------------------------------------
Meaning : initialize OSD
Input : none
Output : none
==================================================================================================*/
unsigned char back_row_number;
unsigned char fore_row_number;
void init_osd(void)
{
SAVE_PPR;
spp(OSD_PG); /* OSD registers page */
OSDER = 0x80; /* OSDRAM interface clock on -> CPU clock
OSD function off
Transfer disabled
Double scan off
Interlaced mode
Translucency alternate function off
Mouse pointer off
Fast pixe clock off */
OSDDR = 0x20; /* Palette Swap disabled
HSYNC input pulse positive polarity
VSYNC input pulse negative polarity
FB output pulse positive polarity
internal delay applied to VSYNC : 4us <d< 8us */
OSDMR |= 0x02; /* Line start mute = 4uS */
OSDBCR1 |= 0x80; /* Digital FB control */
OSDBCR2 = 0x00; //feman add
//feman : initialize the variable
OSD_FLAG = 0x00;/* reset OSD flag */
current_displayed_row = (unsigned char)0 ;
fore_row_number = 0;
RESTORE_PPR;
}
/*================================================================================================
OSD INTERRUPT
--------------------------------------------------------------------------------------------------
Meaning : interrupt subroutine for OSD
Input : none
Output : none
==================================================================================================*/
#pragma interrupt (OSD_IT)
void OSD_IT(void)
{
SAVE_PPR; /* save page pointer register */
EI; /* enable ITs */
spp(OSD_PG);
/* check if this interrupt is for OSD or Mouse */
/* I remove mouse function */
if ((OSDFBR & OSDm_MOIT) == OSDm_MOIT)
{ /* Mouse interrupt */
OSDFBR &= ~OSDm_MOIT; /* reset mouse interrupt bit */
// if ((OSD_FLAG & OSD_MOUSE_CHANGE) == OSD_MOUSE_CHANGE)
// { /* mouse data have changed */
// OSD_FLAG &= ~OSD_MOUSE_CHANGE;
// mouse_shift((int) (MOUSE_FLAG1),(int) (MOUSE_FLAG2)); /*move the mouse on the screen */
// }
}
else
{ /* OSD interrupt */
OSDFBR &= ~OSDm_DINT;
if (current_displayed_row >=fore_row_number) /* the displayed row is the last one, */
{ /* so go back to the 1st row */
current_displayed_row = (unsigned char )0; /* reset the current displayed row */
}
if ((OSDFBR & OSDm_BUFL) == OSDm_BUFL) /* check which OSDbuffer is used */
{ /* the bit is set so buffer used is the one pointed by the first buffer start @ : buffer1 */
/* so fill buffer 2 */
fill_osdram_buffer(current_displayed_row ,OSDRAM_BUFFER2);
}
else
{ /* the bit is reset so buffer used is the one NOT pointed by the first buffer start @ : buffer2 */
/* so fill buffer 1 */
fill_osdram_buffer(current_displayed_row ,OSDRAM_BUFFER1);
}
current_displayed_row++; /* set the current displayed row value */
}
RESTORE_PPR; /* restore page pointer register */
}
/*================================================================================================
Blank_screen
--------------------------------------------------------------------------------------------------
Meaning : fill the SRAM buffer with a blank screen in extended // mode (15 rows)
Input : none
Output : none
==================================================================================================*/
//void blank_screen(void)
//{
// unsigned int i,j;
// unsigned char event_line_high, event_line_low, horizontal_shift_high, horizontal_shift_low;
// unsigned char mode, row_att, active_range, nb_char, nb_line;
// unsigned char *pointer_sram;
/* fill 15 rows of 36 char in basic parallel mode with " " */
// nb_char = 36; /* char per line */
// nb_line = 15; /* 15 lines par screen */
// horizontal_shift_low = 0x80; /* horizontal shift = 0x80 */
// horizontal_shift_high = 0;
// horizontal_shift_high |= (nb_char<<2); /* nb_char char to display. RCN is the 5 MBS of horizontal_shift */
// mode = 0x01; /* basic parallel mode */
// row_att = 0x80; /* 18x26 matrix, size 1x1, no flash, no rounding, no fringe */
// active_range = 0x0D; /* start line 0, end line 13 */
// for (i=0 ; i<nb_line ; i++)
// {
// event_line_high = 0; /* event line to let rows be continuous */
// event_line_low = 0x20+(char) 13*i;
// pointer_sram = (unsigned char *) (SRAM_BUFFER_START + SRAM_LINE_BUFFER_SIZE*i); /* set the pointer to the first byte of the line number i */
// *(pointer_sram++) = event_line_high;
// *(pointer_sram++) = event_line_low;
// *(pointer_sram++) = horizontal_shift_high;
// *(pointer_sram++) = horizontal_shift_low;
// *(pointer_sram++) = mode;
// *(pointer_sram++) = row_att;
// *(pointer_sram++) = active_range;
// for (j=0 ; j<nb_char ; j++)
// { /* fill the line with nb_char char, palette attrib, and parallel attrib */
// *(pointer_sram++) = 0x40; /* char */
// *(pointer_sram++) = (unsigned char) (j & 0x000F); /* palette attribute */
// }
// }
//
// fore_row_number = nb_line; /* nb_line lines stored in the OSD SRAM buffer */
// osd_enabled(); /* enable OSD */
//}
/*================================================================================================
Clear_OSDRAM
--------------------------------------------------------------------------------------------------
Meaning : the OSDRAM with 0x00
Input : none
Output : none
==================================================================================================*/
void Clear_OSDRAM(void)
{
unsigned int i, *pointer;
pointer = (unsigned int *) OSDRAM_START;
for (i=0 ; i<192 ; i++)
*(pointer++) = 0x0000;
}
/*================================================================================================
osd_enabled
--------------------------------------------------------------------------------------------------
Meaning : fill first row buffer in osdram & enable OSD
Input : none
Output : none
==================================================================================================*/
void osd_enabled(void)
{
spp(OSD_PG);
while(!(OSDFBR & 0x40));
OSDER |= 0xE4; /* OSDRAM interface clock on
OSD function on
Transfer enabled
Double scan off
Interlaced mode
Translucency alternate function on
Mouse pointer off
Fast pixe clock off */
OSD_FLAG |= OSD_EN; /* set the OSD enabled bit of OSD_FLAG */
spp(EXINT_PG); /* set page to external interrupt registers */
EIMR |= 0x20; /* enable INT5 VSYNC IT */
}
/*================================================================================================
osd_disabled
--------------------------------------------------------------------------------------------------
Meaning : disable OSD
Input : none
Output : none
==================================================================================================*/
void osd_disabled(void)
{
SAVE_PPR;
spp(EXINT_PG); /* set page to external interrupt registers */
EIMR &= ~0x20; /* disable INT5 VSYNC IT */
spp(OSD_PG); /* OSD registers page */
OSDER &= ~0x60; /* OSDRAM interface clock on -> CPU clock */
OSDER |= 0x80; /* OSD function off
Transfer disabled
Double scan off
Interlaced mode
Translucency alternate function off
Mouse pointer off
Fast pixel clock off */
OSD_FLAG &= ~OSD_EN; /* reset the OSD enabled bit of OSD_FLAG */
RESTORE_PPR;
}
/*================================================================================================
fill_osdram_buffer
--------------------------------------------------------------------------------------------------
Meaning : fill the osdram buffer with the content of 1 row stored in SRAM
Input : row : the row ( in sram ) to be transfered,
buff_add : the osdram (in osdram ) buffer start address
Output : none
==================================================================================================*/
void fill_osdram_buffer(unsigned char row, unsigned int osd_buff_add)
{
unsigned char *pointer_osd, *pointer_sram;
unsigned char tmphigh,tmplow, rcn, mode;
unsigned int sram_add;
sram_add = (SRAM_BUFFER_START + (row) * SRAM_LINE_BUFFER_SIZE);
/* set the event line begin */
pointer_osd = (unsigned char *) OSDRAM_START; /* set osd pointer to the begining of osdram */
pointer_sram = (unsigned char *) sram_add; /* set sram pointer to the begining of row block */
*(pointer_osd++) = *(pointer_sram++); /* write the event line high @ */
*(pointer_osd++) = *(pointer_sram); /* write the event line low @ */
/* set the event line end */
/* set start buffer begin */
*(pointer_osd++) = BUFFDRV1HIGH; /* set it to the first buffer start address */
*(pointer_osd ) = BUFFDRV1LOW;
/* set start buffer end */
/* set next bufer start address begin */
pointer_osd = (unsigned char*) osd_buff_add; /* set osd pointer to the begining of the choosen buffer
in osdram (Row mode) */
row++;
if (row >= fore_row_number) /* set sram pointer to the 4th byte of the next row block mode for next row */
pointer_sram = (unsigned char *) (SRAM_BUFFER_START + 4);
else
pointer_sram = (unsigned char *) (sram_add + SRAM_LINE_BUFFER_SIZE + 4);
mode = *(pointer_sram); /* get the row mode for next row*/
mode = mode << 6; /* shift left 6 bits */
if (osd_buff_add == OSDRAM_BUFFER1)
{
tmphigh = BUFFDRV2HIGH; /* set the next buffer start address */
tmplow = BUFFDRV2LOW ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -