static int osd1_init(logo_object_t *plogo) { int hpd_state = 0; if(plogo->para.output_dev_type==output_osd1.idx) { DisableVideoLayer(); if((plogo->platform_res[output_osd1.idx].mem_end - plogo->platform_res[output_osd1.idx].mem_start) ==0) { return OUTPUT_DEV_UNFOUND; } if(plogo->para.loaded) { osd_init_hw(plogo->para.loaded); if(plogo->para.vout_mode > VMODE_4K2K_SMPTE){ plogo->para.vout_mode|=VMODE_LOGO_BIT_MASK; } } #ifdef CONFIG_AM_HDMI_ONLY if(plogo->para.vout_mode > VMODE_4K2K_SMPTE) { set_current_vmode(plogo->para.vout_mode); }else{ extern int read_hpd_gpio(void); hpd_state = read_hpd_gpio(); if (hpd_state == 0){ set_current_vmode(cvbsmode_hdmionly); } else{ set_current_vmode(hdmimode_hdmionly); } } #else set_current_vmode(plogo->para.vout_mode); #endif output_osd1.vinfo=get_current_vinfo(); plogo->dev=&output_osd1; plogo->dev->window.x=0; plogo->dev->window.y=0; plogo->dev->window.w=plogo->dev->vinfo->width; plogo->dev->window.h=plogo->dev->vinfo->height; plogo->dev->output_dev.osd.mem_start=plogo->platform_res[LOGO_DEV_OSD1].mem_start; plogo->dev->output_dev.osd.mem_end=plogo->platform_res[LOGO_DEV_OSD1].mem_end; plogo->dev->output_dev.osd.color_depth=get_curr_color_depth(P_VIU_OSD2_BLK0_CFG_W0);//setup by uboot return OUTPUT_DEV_FOUND; } return OUTPUT_DEV_UNFOUND; }
static void set_vout_mode(char * name) { #ifdef CONFIG_AML_HDMI_TX extern void hdmi_pre_set_change_mode(void); #endif vmode_t mode; amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"tvmode set to %s\r\n",name); mode=validate_vmode(name); if(VMODE_MAX==mode) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"no matched vout mode\n"); return ; } if(mode==get_current_vmode()) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"don't set the same mode as current.\r\n"); return ; } #ifdef CONFIG_AML_HDMI_TX if(mode < VMODE_LCD) hdmi_pre_set_change_mode(); #endif set_current_vmode(mode); amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"new mode %s set ok\r\n",name); vout_notifier_call_chain(VOUT_EVENT_MODE_CHANGE,&mode) ; printk("%s[%d]\n", __func__, __LINE__); }
void set_vout_mode_fr_auto(char* name) { vmode_t vmode; amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"tvmode set to %s\n",name); vmode=validate_vmode(name); if(VMODE_MAX==vmode) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"no matched vout mode\n"); return ; } if(vmode==get_current_vmode()) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"don't set the same mode as current.\n"); return ; } update_vmode_status(name); set_current_vmode(vmode); amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"new mode %s set ok\n",name); vout_notifier_call_chain(VOUT_EVENT_MODE_CHANGE,&vmode) ; printk("%s[%d]\n", __func__, __LINE__); }
static void set_vout_mode(char * name) { vmode_t mode; amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"tvmode set to %s\n",name); mode=validate_vmode(name); if(VMODE_MAX==mode) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"no matched vout mode\n"); return ; } #ifdef CONFIG_AML_VOUT_FRAMERATE_AUTOMATION mode_by_user = mode; #endif if(mode==get_current_vmode()) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"don't set the same mode as current.\n"); return ; } #ifdef CONFIG_AML_VOUT_FRAMERATE_AUTOMATION //if plug hdmi during fps (stream is playing), then adjust mode to fps vmode fps_auto_adjust_mode(&mode); printk("%s[%d]fps_target_mode=%d\n",__func__,__LINE__,mode); update_vmode_status(get_name_from_vmode(mode)); #endif set_current_vmode(mode); #ifdef CONFIG_AML_VOUT_FRAMERATE_AUTOMATION amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"new mode =%s set ok\n",get_name_from_vmode(mode)); #endif vout_notifier_call_chain(VOUT_EVENT_MODE_CHANGE,&mode) ; printk("%s[%d]\n", __func__, __LINE__); }
// change tv mode and show logo immediatly when hdmi pluged int set_mode_and_show_logo(int hpd_state) { int value; logo_object_t* plogo = get_current_logo_obj(); if((plogo->para.vout_mode & VMODE_MODE_BIT_MASK) > VMODE_4K2K_SMPTE) { return 0; // MID } printk("hdmi detect: %s.\n", (hpd_state==1)?"plug":"unplug"); // osd2 freescale enable, the logo is shown on osd2, reset freescale. value = aml_read_reg32(P_VPP_OSD_SC_CTRL0) & 0xb; if(value == 0x9) { vmode_t cur_mode; if (hpd_state == 0){ cur_mode = cvbsmode_hdmionly; } else{ cur_mode = hdmimode_hdmionly; } if(tvmode != cur_mode) { tvmode = cur_mode; osd_enable_hw(0, plogo->para.output_dev_type); set_current_vmode(cur_mode); vout_notifier_call_chain(VOUT_EVENT_MODE_CHANGE,&cur_mode) ; set_osd_freescaler(plogo->para.output_dev_type, plogo, cur_mode); } } return 1; }
static int vid_init(logo_object_t *plogo) { if(plogo->para.output_dev_type==output_vid.idx) { set_current_vmode(plogo->para.vout_mode); output_vid.vinfo=get_current_vinfo(); plogo->dev=&output_vid; plogo->dev->window.x=0; plogo->dev->window.y=0; plogo->dev->window.w=plogo->dev->vinfo->width; plogo->dev->window.h=plogo->dev->vinfo->height; plogo->dev->output_dev.vid.mem_start=plogo->platform_res[LOGO_DEV_VID].mem_start; plogo->dev->output_dev.vid.mem_end=plogo->platform_res[LOGO_DEV_VID].mem_end; amlog_mask_level(LOG_MASK_DEVICE,LOG_LEVEL_LOW,"display on video layer\n"); return OUTPUT_DEV_FOUND; } return OUTPUT_DEV_UNFOUND; }
static void set_vout_mode(char * name) { vmode_t mode; amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_LOW,"tvmode set to %s\r\n",name); mode=validate_vmode(name); if(VMODE_MAX==mode) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"no matched vout mode\n"); return ; } if(mode==get_current_vmode()) { amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_HIGH,"don't set the same mode as current.\r\n"); return ; } set_current_vmode(mode); amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_LOW,"new mode %s set ok\r\n",name); vout_notifier_call_chain(VOUT_EVENT_MODE_CHANGE,&mode) ; }
static int osd_probe(struct platform_device *pdev) { int r; struct fb_info *fbi=NULL; const vinfo_t *vinfo; struct fb_var_screeninfo *var; struct fb_fix_screeninfo *fix; struct resource *mem; int index,Bpp; logo_object_t *init_logo_obj=NULL; int logo_osd_index=0,i; myfb_dev_t *fbdev = NULL; vout_register_client(&osd_notifier_nb); #ifdef CONFIG_AM_LOGO init_logo_obj = get_current_logo_obj(); if( init_logo_obj ) { if(init_logo_obj->para.output_dev_type<LOGO_DEV_VID) //osd0 or osd1 { logo_osd_index= init_logo_obj->para.output_dev_type; }else{ if(init_logo_obj->para.output_dev_type==LOGO_DEV_VID) init_logo_obj=NULL; //if logo device on video layer , } //we cant use it . } #endif if (NULL==init_logo_obj ) { #ifdef CONFIG_AM_LCD_OUTPUT set_current_vmode(VMODE_LCD); #else set_current_vmode(VMODE_720P); #endif osddev_init(); } vinfo = get_current_vinfo(); for (index=0;index<OSD_COUNT;index++) { //platform resource if (!(mem = platform_get_resource(pdev, IORESOURCE_MEM, index))) { amlog_level(LOG_LEVEL_HIGH,"No frame buffer memory define.\n"); r = -EFAULT; goto failed2; } //if we have no resource then no need to create this device. amlog_level(LOG_LEVEL_HIGH,"[osd%d] 0x%x-0x%x\n",index,mem->start,mem->end); if (!mem || mem->start== 0 || mem->end==0 || mem->start==mem->end) { continue ; } fbi = framebuffer_alloc(sizeof(struct myfb_dev), &pdev->dev); if(!fbi) { r = -ENOMEM; goto failed1; } fbdev = (struct myfb_dev *)fbi->par; fbdev->fb_info = fbi; fbdev->dev = pdev; mutex_init(&fbdev->lock); var = &fbi->var; fix = &fbi->fix; gp_fbdev_list[index]=fbdev; fbdev->fb_mem_paddr = mem->start; fbdev->fb_len = mem->end - mem->start + 1; fbdev->fb_mem_vaddr = ioremap_wc(fbdev->fb_mem_paddr, fbdev->fb_len); if (!fbdev->fb_mem_vaddr) { amlog_level(LOG_LEVEL_HIGH,"failed to ioremap framebuffer\n"); r = -ENOMEM; goto failed1; } //clear framebuffer memory amlog_level(LOG_LEVEL_HIGH,"Frame buffer memory assigned at phy:0x%08x, vir:0x%p, size=%dK\n", fbdev->fb_mem_paddr, fbdev->fb_mem_vaddr, fbdev->fb_len >> 10); if(init_logo_obj && index==logo_osd_index ) //adjust default var info { int bpp=init_logo_obj->dev->output_dev.osd.color_depth;//bytes per pixel mydef_var[index].xres=init_logo_obj->dev->vinfo->width; mydef_var[index].yres=init_logo_obj->dev->vinfo->height; mydef_var[index].xres_virtual=init_logo_obj->dev->vinfo->width; mydef_var[index].yres_virtual=init_logo_obj->dev->vinfo->height<<1;//logo always use double buffer mydef_var[index].bits_per_pixel=bpp ; amlog_level(LOG_LEVEL_HIGH,"init fbdev bpp is :%d\r\n",mydef_var[index].bits_per_pixel); if(mydef_var[index].bits_per_pixel>32) { mydef_var[index].bits_per_pixel=32; } } else { amlog_level(LOG_LEVEL_HIGH,"---------------clear framebuffer%d memory \r\n",index); memset((char*)fbdev->fb_mem_vaddr, 0x80, fbdev->fb_len); } _fbdev_set_default(fbdev,index); if(NULL==fbdev->color) { r = -ENOENT; goto failed1; } Bpp=(fbdev->color->color_index >8?(fbdev->color->color_index>16?(fbdev->color->color_index>24?4:3):2):1); fix->line_length=var->xres_virtual*Bpp; fix->smem_start = fbdev->fb_mem_paddr; fix->smem_len = fbdev->fb_len; if (fb_alloc_cmap(&fbi->cmap, 16, 0) != 0) { amlog_level(LOG_LEVEL_HIGH,"unable to allocate color map memory\n"); r = -ENOMEM; goto failed2; } if (!(fbi->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL))) { amlog_level(LOG_LEVEL_HIGH,"unable to allocate pseudo palette memory\n"); r = -ENOMEM; goto failed2; } memset(fbi->pseudo_palette, 0, sizeof(u32) * 16); fbi->fbops = &osd_ops; fbi->screen_base = (char __iomem *)fbdev->fb_mem_vaddr ; fbi->screen_size = fix->smem_len; set_default_display_axis(&fbdev->fb_info->var,&fbdev->osd_ctl,vinfo); osd_check_var(var, fbi); register_framebuffer(fbi); if(NULL==init_logo_obj )//if we have init a logo object ,then no need to setup hardware . { osddev_set(fbdev); } for(i=0;i<ARRAY_SIZE(osd_attrs);i++) r=device_create_file(fbi->dev, &osd_attrs[i]); } index=0; #ifdef CONFIG_HAS_EARLYSUSPEND early_suspend.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING; early_suspend.suspend = osd_early_suspend; early_suspend.resume = osd_late_resume; register_early_suspend(&early_suspend); #endif amlog_level(LOG_LEVEL_HIGH,"osd probe ok \r\n"); return 0; failed2: fb_dealloc_cmap(&fbi->cmap); failed1: amlog_level(LOG_LEVEL_HIGH,"Driver module insert failed.\n"); return r; }
static int osd1_init(logo_object_t *plogo) { #if defined(CONFIG_AM_HDMI_ONLY) int hpd_state = 0; #endif #if defined(CONFIG_AM_HDMI_ONLY) || (MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8) vmode_t cur_mode = plogo->para.vout_mode; #endif if(plogo->para.output_dev_type==output_osd1.idx) { DisableVideoLayer(); if((plogo->platform_res[output_osd1.idx].mem_end - plogo->platform_res[output_osd1.idx].mem_start) ==0) { return OUTPUT_DEV_UNFOUND; } if(plogo->para.loaded) { osd_init_hw(plogo->para.loaded); if(plogo->para.vout_mode > VMODE_4K2K_SMPTE){ plogo->para.vout_mode|=VMODE_LOGO_BIT_MASK; } } #ifdef CONFIG_AM_HDMI_ONLY if(plogo->para.vout_mode > VMODE_4K2K_SMPTE) { set_current_vmode(plogo->para.vout_mode); }else{ extern int read_hpd_gpio(void); hpd_state = read_hpd_gpio(); if (hpd_state == 0){ cur_mode = cvbsmode_hdmionly; } else{ cur_mode = hdmimode_hdmionly; } set_current_vmode(cur_mode); } #else set_current_vmode(plogo->para.vout_mode); #endif #if MESON_CPU_TYPE < MESON_CPU_TYPE_MESON8 osd_init_scan_mode(); #endif output_osd1.vinfo=get_current_vinfo(); plogo->dev=&output_osd1; plogo->dev->window.x=0; plogo->dev->window.y=0; plogo->dev->window.w=plogo->dev->vinfo->width; plogo->dev->window.h=plogo->dev->vinfo->height; plogo->dev->output_dev.osd.mem_start=plogo->platform_res[LOGO_DEV_OSD1].mem_start; plogo->dev->output_dev.osd.mem_end=plogo->platform_res[LOGO_DEV_OSD1].mem_end; plogo->dev->output_dev.osd.color_depth=get_curr_color_depth(P_VIU_OSD2_BLK0_CFG_W0);//setup by uboot #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 if((cur_mode != (plogo->para.vout_mode & VMODE_MODE_BIT_MASK)) && (cur_mode <= VMODE_4K2K_SMPTE)) { set_osd_freescaler(LOGO_DEV_OSD1, plogo, cur_mode); } #endif return OUTPUT_DEV_FOUND; } return OUTPUT_DEV_UNFOUND; }