/* * Configure coefficients using Ry, RCr, RCb, Gy, GCr, GCb, By, BCr, BCb * Normally used for custom yuv coefficients, maybe from configuration file */ void set_custom_color_coefficients(disp_adapter_t *adapter, int layer, short ry, short rcr, short rcb, short gy, short gcr, short gcb, short by, short bcr, short bcb) { omap_ctx_t *o_ctx= adapter->ms_ctx; TRACE; if (layer > 1) { DEBUG_MSG("layer out of range"); return; } *OMAP_DISPC_VID_CONV_COEF(layer,0) = (ry&0x7FF) | ((rcr &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF0 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,0) )); *OMAP_DISPC_VID_CONV_COEF(layer,1) = (rcb&0x7FF) | ((gy &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF1 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,1) )); *OMAP_DISPC_VID_CONV_COEF(layer,2) = (gcr&0x7FF) | ((gcb &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF2 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,2) )); *OMAP_DISPC_VID_CONV_COEF(layer,3) = (by&0x7FF) | ((bcr &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF3 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,3) )); *OMAP_DISPC_VID_CONV_COEF(layer,3) = (bcb&0x7FF) ; DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF4 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,4) )); }
/* * Private function to * Configure coefficients using array. */ static void set_color_coefficients(disp_adapter_t *adapter, int layer, short coef[]) { omap_ctx_t *o_ctx= adapter->ms_ctx; TRACE; if (layer > 1) { DEBUG_MSG("layer out of range"); return; } *OMAP_DISPC_VID_CONV_COEF(layer,0) = (coef[0]&0x7FF) | ((coef[1] &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF0 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,0) )); *OMAP_DISPC_VID_CONV_COEF(layer,1) = (coef[2]&0x7FF) | ((coef[3] &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF1 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,1) )); *OMAP_DISPC_VID_CONV_COEF(layer,2) = (coef[4]&0x7FF) | ((coef[5] &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF2 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,2) )); *OMAP_DISPC_VID_CONV_COEF(layer,3) = (coef[6]&0x7FF) | ((coef[7] &0x7FF) << 16); DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF3 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,3) )); *OMAP_DISPC_VID_CONV_COEF(layer,4) = (coef[8]&0x7FF) ; DEBUG_CMD(disp_printf(adapter, "OMAP_DISPC_VID_CONV_COEF4 layer %d %x", layer, *OMAP_DISPC_VID_CONV_COEF(layer,4) )); }
/* * Set up color conversions coefficients table for YUV to RGB * Returns * 0x0: Limited range selected: 16 subtracted from Y before color space conversion * 0x1: Full range selected: Y is not modified before the color space conversion * Note: Constistent with Bit 11 in DISPC_VIDn_ATTRIBUTES */ int set_yuv_to_rgb_conversion(disp_adapter_t *adapter, int layer, int entry) { omap_ctx_t *o_ctx= adapter->ms_ctx; TRACE; if (layer > 1) { DEBUG_MSG("layer out of range"); return -1; } DEBUG_CMD(disp_printf(adapter, "Set YUV conversion coefficients table %s ", color_coefficients_table[entry].name)); set_color_coefficients(adapter, layer, color_coefficients_table[entry].coefficients); return color_coefficients_table[entry].range; }
/* * TWL4030 function definitions */ static int twl4030_i2c_write (disp_adapter_t *adapter, uint8_t addr, uint8_t reg, uint8_t val) { iov_t siov[3]; i2c_send_t hdr; hdr.slave.addr = addr; hdr.slave.fmt = I2C_ADDRFMT_7BIT; hdr.len = 2; hdr.stop = 1; SETIOV(&siov[0], &hdr, sizeof(hdr)); SETIOV(&siov[1], ®, sizeof(reg)); SETIOV(&siov[2], &val, 1); if (devctlv(fd, DCMD_I2C_SEND, 3, 0, siov, NULL, NULL) != EOK) { disp_printf(adapter, "twl4030_i2c_write fail"); return -1; } return 0; }
/* Display coefficients for debug */ void omap_coef_display(disp_adapter_t *adapter, int layer) { omap_ctx_t *o_ctx = adapter->ms_ctx; int phase; TRACE; if (layer > 1) { DEBUG_MSG("layer out of range"); return; } disp_printf(adapter, "Sampling coefficients Layer %d", layer); disp_printf(adapter, "OMAP_DISPC_VID_FIR_COEF_H"); for (phase = 0; phase < 8; ++phase) { disp_printf(adapter, "OMAP_DISPC_VID_FIR_COEF_H(%d) value %x", phase, *OMAP_DISPC_VID_FIR_COEF_H(layer,phase)); } disp_printf(adapter, "OMAP_DISPC_VID_FIR_COEF_HV"); for (phase = 0; phase < 8; ++phase) { disp_printf(adapter, "OMAP_DISPC_VID_FIR_COEF_HV(%d) value %x", phase, *OMAP_DISPC_VID_FIR_COEF_HV(layer,phase)); } disp_printf(adapter, "OMAP_DISPC_VID_FIR_COEF_V"); for (phase = 0; phase < 8; ++phase) { disp_printf(adapter, "OMAP_DISPC_VID_FIR_COEF_V(%d) value %x", phase, *OMAP_DISPC_VID_FIR_COEF_V(layer,phase)); } }
int get_config_data(omapl1xx_context_t *omapl1xx, const char *filename) { FILE *fin = NULL; char buf[512], *c, *opt, *value; if (filename == NULL) { disp_printf(omapl1xx->adapter, "No config file specified, using default parameters\n"); } else if ((fin = fopen(filename, "r")) == NULL) { disp_printf(omapl1xx->adapter, "Could not open config file \"%s\": %s\n", filename, strerror(errno)); } /* Default settings for OMAPL1xx reference boards, Override them if a configuration file is specified */ omapl1xx->hsw = 22; omapl1xx->hfp = 54; omapl1xx->hbp = 2; omapl1xx->vsw = 2; omapl1xx->vfp = 17; omapl1xx->vbp = 4; omapl1xx->lpp = 273; omapl1xx->sync_ctrl = 0; omapl1xx->sync_edge = 0; omapl1xx->ivs = 1; omapl1xx->ihs = 1; omapl1xx->ipc = 0; omapl1xx->bias = 0; omapl1xx->acb = 0; omapl1xx->acbi = 0; omapl1xx->pcd = 20; omapl1xx->type = 1; omapl1xx->lr = 0; omapl1xx->tb = 0; omapl1xx->mode3 = 0; omapl1xx->dith = 0; omapl1xx->display = 0; omapl1xx->refresh = 60; omapl1xx->lcd_xres = OMAPL1xx_LCD_XRES; omapl1xx->lcd_yres = OMAPL1xx_LCD_YRES; omapl1xx->irq = OMAPL1xx_LCD_IRQ; omapl1xx->pixel_format = DISP_LAYER_FORMAT_RGB565; if (fin == NULL) { return 0; } while (fgets(buf, sizeof (buf), fin) != NULL) { c = buf; while (*c == ' ' || *c == '\t') c++; if (*c == '\015' || *c== '\032' || *c == '\0' || *c == '\n' || *c == '#') continue; opt = c; while (*c != '\015' && *c != '\032' && *c != '\0' && *c != '\n' && *c != '#') c++; *c = '\0'; break; } while (*opt != '\0') { c = opt; switch (getsubopt(&opt, omapl1xx_opts, &value)) { case O_HSW: omapl1xx->hsw = strtol(value, NULL, 0); break; case O_HFP: omapl1xx->hfp = strtol(value, NULL, 0); break; case O_HBP: omapl1xx->hbp = strtol(value, NULL, 0); break; case O_VSW: omapl1xx->vsw = strtol(value, NULL, 0); break; case O_VFP: omapl1xx->vfp = strtol(value, NULL, 0); break; case O_VBP: omapl1xx->vbp = strtol(value, NULL, 0); break; case O_LPP: omapl1xx->lpp = strtol(value, NULL, 0); break; case O_SYNCC: omapl1xx->sync_ctrl = strtol(value, NULL, 0); break; case O_SYNCE: omapl1xx->sync_edge = strtol(value, NULL, 0); break; case O_IVS: omapl1xx->ivs = strtol(value, NULL, 0); break; case O_IHS: omapl1xx->ihs = strtol(value, NULL, 0); break; case O_IPC: omapl1xx->ipc = strtol(value, NULL, 0); break; case O_BIAS: omapl1xx->bias = strtol(value, NULL, 0); break; case O_ACB: omapl1xx->acb = strtol(value, NULL, 0); break; case O_ACBI: omapl1xx->acbi = strtol(value, NULL, 0); break; case O_PCD: omapl1xx->pcd = strtol(value, NULL, 0); break; case O_TYPE: omapl1xx->type = strtol(value, NULL, 0); break; case O_LR: omapl1xx->lr = strtol(value, NULL, 0); break; case O_TB: omapl1xx->tb = strtol(value, NULL, 0); break; case O_MODE3: omapl1xx->mode3 = strtol(value, NULL, 0); break; case O_DITH: omapl1xx->dith = strtol(value, NULL, 0); break; case O_DISPLAY: if (stricmp(value, "lcd")==0) omapl1xx->display = 0; else if (stricmp(value, "hdmi")==0) omapl1xx->display = 1; else disp_printf(omapl1xx->adapter, "Unknown value %s for 'display' option\n", value); break; case O_REFRESH: omapl1xx->refresh = strtol(value, NULL, 0); break; case O_LCDX: omapl1xx->lcd_xres = strtol(value, NULL, 0); break; case O_LCDY: omapl1xx->lcd_yres = strtol(value, NULL, 0); break; case O_IRQ: omapl1xx->irq = strtol(value, NULL, 0); break; default: disp_printf(omapl1xx->adapter, "Unknown option %s\n", c); break; } } fclose(fin); return 0; }