void Init_Frame_Buffer_Mode(mp_image_t *mpi) { if(display_mode & LCD_OUT) { if(display_mode & DISP_32BIT) img_param.ipu_d_fmt |= OUT_FMT_RGB888; else // 16BIT img_param.ipu_d_fmt |= OUT_FMT_RGB565; } else //tv_out img_param.ipu_d_fmt |= (OUT_FMT_YUV422 | (1 << 16)); img_param.in_bpp = 16; useframebuf = (int)lcd_get_change_phyframe(); img_param.out_buf = useframebuf; stride.out = get_screen_width() * (img_param.in_bpp / 8 ); jz47_put_image_with_ipu = jz47_put_image_with_framebuf; img_param.y_buf = mpi->planes[0]; img_param.u_buf = mpi->planes[1]; img_param.v_buf = mpi->planes[2]; stride.y = mpi->stride[0]; stride.u = mpi->stride[1]; stride.v = mpi->stride[2]; dump(&img_param); lcd_clean_frame_all(); lcd_ioctl((void*)&img_param,IOCTL_SET_IPU); }
void Init_Direct_Mode(mp_image_t *mpi) { if ((LCD_OUT & display_mode) == TV_OUT) { img_param.ipu_d_fmt |= (OUT_FMT_YUV422 | (1 << 16)); img_param.in_bpp = 16; } else { img_param.ipu_d_fmt |= OUT_FMT_RGB888; img_param.in_bpp = 32; } if(display_mode & DECODE_BUFFER) { img_param.y_buf = mpi->planes[0]; img_param.u_buf = mpi->planes[1]; img_param.v_buf = mpi->planes[2]; stride.y = mpi->stride[0]; stride.u = mpi->stride[1]; stride.v = mpi->stride[2]; lcd_flush_frame_all(); jz47_put_image_with_ipu = jz47_put_image_with_direct_ipu_nobuffer; printf("direct buf\n"); }else { CreateImage(mpi->width,mpi->height,mpi->chroma_width,mpi->chroma_height,mpi->bpp); mpi_copy(yuv_cur,mpi); img_param.y_buf = yuv_cur->y_framebuf; img_param.u_buf = yuv_cur->u_framebuf; img_param.v_buf = yuv_cur->v_framebuf; stride.y = yuv_cur->ystride; stride.u = yuv_cur->ustride; stride.v = yuv_cur->vstride; yuv_cur = yuv_cur->nextframe; jz47_put_image_with_ipu = jz47_put_image_with_direct_ipu_buffer; printf("create buf\n"); } printf("stride.y = %d\n",stride.y); printf("stride.u = %d\n",stride.u); printf("stride.v = %d\n",stride.v); printf("display_mode = %x\n",display_mode); lcd_ioctl(&img_param, IOCTL_DMA1_TO_IPU); }
/********************************************************************** * * Function: tsc_user_interrupt * * Purpose: TSC interrupt handler * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * *********************************************************************/ void tsc_user_interrupt(void) { volatile UNS_32 i=0, j=0, x_val[16], y_val[16]; volatile UNS_32 x_val_av=0, y_val_av=0; /* Read the full FIFO until the FIFO Empty bit is set */ while( ! tsc_ioctl(tscdev,TSC_GET_STATUS, TSC_FIFO_EMPTY_ST)){ tsc_read_fifo[i] = TSC->tsc_fifo; /* Check that the TSC is pressed, sample valid */ if((tsc_read_fifo[i] & TSC_FIFO_TS_P_LEVEL) != TSC_FIFO_TS_P_LEVEL){ x_val[i] = TSC_FIFO_NORMALIZE_X_VAL(tsc_read_fifo[i]); y_val[i] = TSC_FIFO_NORMALIZE_Y_VAL(tsc_read_fifo[i]); i++; } } /* if we have a valid x/y sample, display it! */ if(i>1){ /* Average out the received samples */ for(j=0;j<i;j++){ x_val_av = ((x_val_av + x_val[j])/2); y_val_av = ((y_val_av + y_val[j])/2); } /* Calibrate the received X/Y corordinates */ x_val_av = x_val_av * 240; x_val_av = x_val_av / 1023; y_val_av = y_val_av * 320; y_val_av = y_val_av / 1023; /* set the cursor X/Y position */ lcd_ioctl(lcddev, LCD_CRSR_XY, ((320-y_val_av)<<16)|(240-x_val_av)); } }
void ipu_image_stop() { int lcd_level = 0; lcd_level = kernel_ioctl(&lcd_level,KERNEL_BACKLIGHT_CTRL); lcd_ioctl(0, IOCTL_IPU_TO_DMA1); SetVideoOutMode(NULL); FreeImage(); int pmdata = -1; int curlevel = kernel_ioctl(&pmdata,KERNEL_PM_CONTROL); if(curlevel != init_pm_level) { int enablelcd = 0; kernel_ioctl(&enablelcd,KERNEL_LCD_CTRL); kernel_ioctl(&init_pm_level,KERNEL_PM_CONTROL); enablelcd = 1; kernel_ioctl(&enablelcd,KERNEL_LCD_CTRL); } usec_sleep(150000); // kernel_ioctl(&lcd_level,KERNEL_BACKLIGHT_CTRL); }
/********************************************************************** * * Function: c_entry * * Purpose: Application entry point from the startup code * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * *********************************************************************/ void c_entry(void) { SWIM_WINDOW_T win1; COLOR_T clr, *fblog; int idx; INT_32 lcddev; UNS_16 xgs, ygs, curx, cury, curym, xidx; /* Disable interrupts in ARM core */ disable_irq_fiq(); /* Set virtual address of MMU table */ cp15_set_vmmu_addr((void *) (IRAM_BASE + (256 * 1024) - (16 * 1024))); /* Setup miscellaneous board functions */ phy3250_board_init(); /* Setup LCD muxing for STN Color 16BPP */ clkpwr_setup_lcd(CLKPWR_LCDMUX_TFT16, 1); /* Enable clock to LCD block (HCLK_EN)*/ clkpwr_clk_en_dis(CLKPWR_LCD_CLK, 1); /* Setup LCD paramaters in the LCD controller */ lcddev = lcd_open(CLCDC, (INT_32) &LCD_DISPLAY); /* Upper Panel Frame Base Address register */ lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF); /* Enable LCD controller and power signals */ lcd_ioctl(lcddev, LCD_PWENABLE, 1); /* Enable LCD backlight */ phy3250_lcd_backlight_enable(TRUE); /* Enable LCD power */ phy3250_lcd_power_enable(TRUE); /* Set frame buffer address */ fblog = (COLOR_T *) cp15_map_physical_to_virtual(PHY_LCD_FRAME_BUF); /* Create a SWIM window */ swim_window_open(&win1, LCD_DISPLAY.pixels_per_line, LCD_DISPLAY.lines_per_panel, fblog, 0, 0, (LCD_DISPLAY.pixels_per_line - 1), (LCD_DISPLAY.lines_per_panel - 1),1, WHITE, BLACK, BLACK); /* Compute vertical size for bars */ ygs = LCD_DISPLAY.lines_per_panel / 3; /* Draw Red bars */ cury = 0; curx = 0; curym = ygs - 1; xgs = LCD_DISPLAY.pixels_per_line / RED_COLORS; clr = BLACK; for (xidx = 0; xidx < RED_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0800; } /* Draw green bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / GREEN_COLORS; clr = BLACK; for (xidx = 0; xidx < GREEN_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0020; } /* Draw blue bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / BLUE_COLORS; clr = BLACK; for (xidx = 0; xidx < BLUE_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0001; } }
static void jz47_ipu_init (struct vf_instance_s* vf,mp_image_t *mpi) { F("1\n"); SwsContext *c = vf->priv->ctx; int outW, outH; int out_w,out_h; int out_x,out_y; outW = mpi->width; outH = mpi->height; c->dstW = outW; c->dstH = outH; if(ipu_inited) PEND_IPU(); switch(ipu_size_cfg) { case MP_IMAGE_TYPE_CUSTORM: out_w = g_out_w; out_h = g_out_h; break; case MP_IMAGE_TYPE_INITSIZE: if((outH <= FB_LCD_HEIGHT) && (outW <= FB_LCD_WIDTH)) { out_x = (FB_LCD_WIDTH - outW) / 2; out_y = (FB_LCD_HEIGHT - outH) / 2; out_w = outW; out_h = outH; }else eqscale(outW,outH,&out_x,&out_y,&out_w,&out_h); break; case MP_IMAGE_TYPE_EQSIZE: eqscale(outW,outH,&out_x,&out_y,&out_w,&out_h); break; case MP_IMAGE_TYPE_FULLSCREEN: fullscreen(outW,outH,&out_x,&out_y,&out_w,&out_h); break; } img_param.ratio_table = ipu_ratio_table; { img_param.in_width = outW; img_param.in_height = outH; img_param.out_width = out_w; img_param.out_height = out_h; img_param.out_x = out_x; img_param.out_y = out_y; img_param.stride = &stride; img_param.csc = &ipu_csc; } dump(&img_param); if((ipu_inited == 0) || (display_mode & CHANGE_OUT_MODE)) { display_mode &= ~CHANGE_OUT_MODE; int srcFormat= c->srcFormat; switch (srcFormat) { case PIX_FMT_YUV420P: img_param.ipu_d_fmt = IN_FMT_YUV420; break; case PIX_FMT_YUV422P: img_param.ipu_d_fmt = IN_FMT_YUV422; break; case PIX_FMT_YUV444P: img_param.ipu_d_fmt = IN_FMT_YUV444; break; case PIX_FMT_YUV411P: img_param.ipu_d_fmt = IN_FMT_YUV411; break; } get_ipu_addr(ipu_addr); // if(display_mode & DISP_ALL) // { // if(1)//get_screen_height() * get_screen_width() <= 480 * 272 * 2) // display_mode |= DISP_DIRECT; // else // display_mode &= ~DISP_ALL; // } display_mode &= ~IPU_PEND; Init_Direct_Mode(mpi); // if((display_mode & LCD_OUT) && (display_mode & DISP_DIRECT)) // { // display_mode &= ~IPU_PEND; // Init_Direct_Mode(mpi); // }else // { // printf("Init Frame Buffer mode\n"); // display_mode |= IPU_PEND; // Init_Frame_Buffer_Mode(mpi); // } ipu_inited = 1; }else { printf("+++++++++++++++++++resize\n"); if((display_mode & DISP_DIRECT)) { lcd_ioctl(&img_param, IOCTL_LCD_RESIZE_ALL); }else { lcd_clean_frame_all(); useframebuf = lcd_get_change_phyframe(); img_param.out_buf = useframebuf; lcd_ioctl(&img_param, IOCTL_LCD_RESIZE); } Flush_OSDScrean(); printf("-------------------resize\n"); } SetVideoOutMode(mplayer_setdisplaymode); framebuf_offset = (img_param.out_x + img_param.out_y * get_screen_width()) * (img_param.in_bpp / 8); dump(&img_param); }
void ipu_image_stop() { lcd_ioctl(0, IOCTL_IPU_TO_DMA1); SetVideoOutMode(NULL); FreeImage(); }
void Init_Direct_Mode(mp_image_t *mpi) { if ((LCD_OUT & display_mode) == TV_OUT) { img_param.ipu_d_fmt |= (OUT_FMT_YUV422 | (1 << 16)); img_param.in_bpp = 16; } else { if(get_screen_bpp()==32){ img_param.ipu_d_fmt |= OUT_FMT_RGB888; img_param.in_bpp = 32; }else if(get_screen_bpp()==16){ img_param.ipu_d_fmt |= OUT_FMT_RGB565; img_param.in_bpp = 16; }else{ img_param.ipu_d_fmt |= OUT_FMT_RGB888; img_param.in_bpp = 32; } } if(display_mode & DECODE_BUFFER) { img_param.y_buf = mpi->planes[0]; img_param.u_buf = mpi->planes[1]; img_param.v_buf = mpi->planes[2]; stride.y = mpi->stride[0]; stride.u = mpi->stride[1]; stride.v = mpi->stride[2]; __dcache_writeback_all(); jz47_put_image_with_ipu = jz47_put_image_with_direct_ipu_nobuffer; printf("direct buf\n"); }else { CreateImage(mpi->width,mpi->height,mpi->chroma_width,mpi->chroma_height,mpi->bpp); mpi_copy(yuv_cur,mpi); img_param.y_buf = yuv_cur->y_framebuf; img_param.u_buf = yuv_cur->u_framebuf; img_param.v_buf = yuv_cur->v_framebuf; stride.y = yuv_cur->ystride; stride.u = yuv_cur->ustride; stride.v = yuv_cur->vstride; yuv_cur = yuv_cur->nextframe; jz47_put_image_with_ipu = jz47_put_image_with_direct_ipu_buffer; printf("create buf\n"); } printf("stride.y = %d\n",stride.y); printf("stride.u = %d\n",stride.u); printf("stride.v = %d\n",stride.v); printf("display_mode = %x\n",display_mode); if(init_pm_level == -1) { init_pm_level = -1; init_pm_level = kernel_ioctl(&init_pm_level,KERNEL_PM_CONTROL); int lcd_level = 0; lcd_level = kernel_ioctl(&lcd_level,KERNEL_BACKLIGHT_CTRL); codecs_t *codec = mplayer_get_code_info(1); int isrun_fast = 0; isrun_fast = (mpi->width * mpi->height >= 1280*720); if (!isrun_fast) isrun_fast = Is_Fast_Codes(codec->dll,mpi,"vc1",1024*576); if (!isrun_fast) isrun_fast = Is_Fast_Codes(codec->dll,mpi,"wmv3",1024*576); if (!isrun_fast) isrun_fast = Is_Fast_Codes(codec->dll,mpi,"h264",720*480); F("mplayer enter fast mode codecs = %s width = %d height = %d isrun_fast =%d\n",codec->dll,mpi->width,mpi->height,isrun_fast); if(isrun_fast) { int enablelcd = 0; kernel_ioctl(&enablelcd,KERNEL_LCD_CTRL); int curlevel = 4; kernel_ioctl(&curlevel,KERNEL_PM_CONTROL); //5 = 432000000 enablelcd = 1; kernel_ioctl(&enablelcd,KERNEL_LCD_CTRL); } lcd_ioctl(&img_param, IOCTL_DMA1_TO_IPU); usec_sleep(20000); kernel_ioctl(&lcd_level,KERNEL_BACKLIGHT_CTRL); }else { lcd_ioctl(&img_param, IOCTL_DMA1_TO_IPU); } }
/*********************************************************************** * * Function: c_entry * * Purpose: Application entry point from the startup code * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Always returns 1, or <0 on an error * * Notes: None * **********************************************************************/ int c_entry(void) { SWIM_WINDOW_T win1; COLOR_T *fblog; INT_32 lcddev; /* Disable interrupts in ARM core */ disable_irq_fiq(); /* Setup miscellaneous board functions */ phy3250_board_init(); /* Set virtual address of MMU table */ cp15_set_vmmu_addr((void *) (IRAM_BASE + (256 * 1024) - (16 * 1024))); /* Initialize interrupt system */ int_initialize(0xFFFFFFFF); /* Install standard IRQ dispatcher at ARM IRQ vector */ int_install_arm_vec_handler(IRQ_VEC, (PFV) lpc32xx_irq_handler); /* Install RTC interrupt handler as a IRQ interrupts */ int_install_irq_handler(IRQ_RTC, (PFV) rtc_user_interrupt); /* Open RTC */ rtcdev = rtc_open(RTC, 0); if (rtcdev == 0) { /* Error */ return -1; } /* Set a 1s match rate */ secs = lsecs = 0; mstp.match_num = 0; mstp.use_match_int = TRUE; mstp.enable_onsw = FALSE; mstp.match_tick_val = secs + 1; rtc_ioctl(rtcdev, RTC_ENABLE, 0); rtc_ioctl(rtcdev, RTC_SET_COUNT, 0); rtc_ioctl(rtcdev, RTC_CLEAR_INTS, RTC_MATCH0_INT_STS); rtc_ioctl(rtcdev, RTC_SETUP_MATCH, (INT_32) &mstp); /* Setup LCD muxing for STN Color 16BPP */ clkpwr_setup_lcd(CLKPWR_LCDMUX_TFT16, 1); /* Enable clock to LCD block (HCLK_EN)*/ clkpwr_clk_en_dis(CLKPWR_LCD_CLK, 1); /* Setup LCD paramaters in the LCD controller */ lcddev = lcd_open(CLCDC, (INT_32) & LCD_DISPLAY); /* Upper Panel Frame Base Address register */ lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF); /* Enable LCD controller and power signals */ lcd_ioctl(lcddev, LCD_PWENABLE, 1); /* Enable LCD backlight */ phy3250_lcd_backlight_enable(TRUE); /* Enable LCD power */ phy3250_lcd_power_enable(TRUE); /* Set frame buffer address */ fblog = (COLOR_T *) cp15_map_physical_to_virtual(PHY_LCD_FRAME_BUF); /* Create a SWIM window */ swim_window_open(&win1, LCD_DISPLAY.pixels_per_line, LCD_DISPLAY.lines_per_panel, fblog, 0, 0, (LCD_DISPLAY.pixels_per_line - 1), (LCD_DISPLAY.lines_per_panel - 1), 1, WHITE, BLACK, BLACK); swim_put_ltext(&win1, "RTC example: This example will print the message " "TICK whenever an RTC interrupt occurs (1 second intervals). It will " "quit after 10 seconds\n"); /* Enable RTC (starts counting) */ rtc_ioctl(rtcdev, RTC_ENABLE, 1); /* Enable RTC interrupt in the interrupt controller */ int_enable(IRQ_RTC); /* Enable IRQ interrupts in the ARM core */ enable_irq(); /* Loop for 10 seconds and let interrupts toggle the LEDs */ while (secs < 10) { if (lsecs < secs) { swim_put_ltext(&win1, "TICK\n"); lsecs = secs; } } /* Disable RTC interrupt in the interrupt controller */ int_disable(IRQ_RTC); /* Disable interrupts in ARM core */ disable_irq_fiq(); /* Prior to closing the RTC, the ONSW key value is set. This will allow the RTC to keep it's value across resets as long as RTC power is maintained */ rtc_ioctl(rtcdev, RTC_SETCLR_KEY, 1); /* Close RTC and LCD */ rtc_close(rtcdev); lcd_close(lcddev); return 1; }
/********************************************************************** * * Function: c_entry * * Purpose: Application entry point from the startup code * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * *********************************************************************/ void c_entry(void) { SWIM_WINDOW_T win1; COLOR_T clr, *fblog; int idx; UNS_16 xgs, ygs, curx, cury, curym, xidx; /* Disable interrupts in ARM core */ disable_irq_fiq(); /* Set virtual address of MMU table */ cp15_set_vmmu_addr((void *) (IRAM_BASE + (256 * 1024) - (16 * 1024))); /* Initialize interrupt system */ int_initialize(0xFFFFFFFF); /* Install standard IRQ dispatcher at ARM IRQ vector */ int_install_arm_vec_handler(IRQ_VEC, (PFV) lpc32xx_irq_handler); /* Setup miscellaneous board functions */ phy3250_board_init(); /* enable clock to ADC block - 32KHz clock */ clkpwr_clk_en_dis(CLKPWR_ADC_CLK,1); /* TSC IRQ goes active when the FIFO reaches the Interrupt level */ int_install_irq_handler(IRQ_TS_IRQ, (PFV) tsc_user_interrupt); /* Enable interrupt */ int_enable(IRQ_TS_IRQ); /* Open TSC, sets default timing values, fifo = 16, resolution = 10bits */ tscdev = tsc_open(TSC, 0); /* TSC Auto mode enable, this also sets AUTO bit */ tsc_ioctl(tscdev,TSC_AUTO_EN, 1); /* Setup LCD muxing for STN Color 16BPP */ clkpwr_setup_lcd(CLKPWR_LCDMUX_TFT16, 1); /* Enable clock to LCD block (HCLK_EN)*/ clkpwr_clk_en_dis(CLKPWR_LCD_CLK, 1); /* Setup LCD paramaters in the LCD controller */ lcddev = lcd_open(CLCDC, (INT_32) &LCD_DISPLAY); /* Upper Panel Frame Base Address register */ lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF); /* Enable LCD controller and power signals */ lcd_ioctl(lcddev, LCD_PWENABLE, 1); /* Enable LCD backlight */ phy3250_lcd_backlight_enable(TRUE); /* Enable LCD power */ phy3250_lcd_power_enable(TRUE); /* write cursor image array data to cursor image RAM */ lcd_ioctl(lcddev, LCD_CRSR_INIT_IMG, (INT_32) &cursorimage[0]); /* enable the default cursor 0 */ lcd_ioctl(lcddev,LCD_CRSR_EN,1); /* set the cursor X/Y position */ lcd_ioctl(lcddev, LCD_CRSR_XY, 0x0); /* set the cursor pallette BGR value, col0*/ lcd_ioctl(lcddev, LCD_CRSR_PAL0, 0x00ff0000); /* set the cursor pallette BGR value, col1 */ lcd_ioctl(lcddev, LCD_CRSR_PAL1, 0x000000ff); /* Enable IRQ interrupts in the ARM core */ enable_irq(); /* Set frame buffer address */ fblog = (COLOR_T *)cp15_map_physical_to_virtual(PHY_LCD_FRAME_BUF); /* Create a SWIM window */ swim_window_open(&win1, LCD_DISPLAY.pixels_per_line, LCD_DISPLAY.lines_per_panel, fblog, 0, 0, (LCD_DISPLAY.pixels_per_line - 1), (LCD_DISPLAY.lines_per_panel - 1), 1, WHITE, BLACK, BLACK); /* Compute vertical size for bars */ ygs = LCD_DISPLAY.lines_per_panel / 3; /* Draw Red bars */ cury = 0; curx = 0; curym = ygs - 1; xgs = LCD_DISPLAY.pixels_per_line / RED_COLORS; clr = BLACK; for (xidx = 0; xidx < RED_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0800; } /* Draw green bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / GREEN_COLORS; clr = BLACK; for (xidx = 0; xidx < GREEN_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0020; } /* Draw blue bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / BLUE_COLORS; clr = BLACK; for (xidx = 0; xidx < BLUE_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0001; } /* lets stay here forever */ while(1); }