// probe - insert PIM int bmi_video_probe(struct bmi_device *bdev) { int err = 0; int slot; int irq; struct bmi_video *video; struct class *bmi_class; struct i2c_adapter *adap; struct omap_dss_device *dssdev; printk (KERN_INFO "bmi_video.c: probe...\n"); slot = bdev->slot->slotnum; adap = bdev->slot->adap; video = &g_bmi_video; video->dvi_monitor_edid = NULL; video->vga_monitor_edid = NULL; video->bdev = 0; dssdev = NULL; g_dvi_disp = NULL; g_vga_disp = NULL; /* disable all video devices, store vga/dvi entries */ for_each_dss_dev(dssdev) { omap_dss_get_device(dssdev); if (dssdev->state) dssdev->driver->disable(dssdev); // our dss names are from buglabs board files if (strnicmp(dssdev->name, "dvi", 3) == 0) g_dvi_disp = dssdev; else if (strnicmp(dssdev->name, "vga", 3) == 0) g_vga_disp = dssdev; } // bind driver and bmi_device video->bdev = bdev; // create class device bmi_class = bmi_get_class(); // -- grab eeprom addr if(bdev->slot->eeprom) { video->swap_eeprom = bdev->slot->eeprom; video->swap_eeprom_state = OFF; //set to read bmi board eeprom //printk(KERN_ERR "swizzling slot eeprom, addr %x", // (unsigned int)video->swap_eeprom->addr); } else { printk(KERN_ERR "module eeprom is null. Module type is impossible"); video->swap_eeprom = 0x00; video->swap_eeprom_state = OFF; } // -- grap i2c expander switch video->eeprom_switch = i2c_new_device(adap, &i2cswitch_info); if(video->eeprom_switch == NULL) { printk(KERN_ERR "i2c addr %x fail", i2cswitch_info.addr); err = -ENOTTY; goto probe_fail1; } // -- grab i2c gpio chip and set it up if (gpio_is_valid(VIDEO_GPIO_BASE)) video->gpio_controller = i2c_new_device(adap,&gpio_controller_info); else { printk(KERN_ERR "i2c addr %x in use", VIDEO_GPIO_BASE); err = -ENOTTY; goto probe_fail2; } if(video->gpio_controller == NULL) { printk(KERN_ERR "i2c addr %x fail", gpio_controller_info.addr); err = -ENOTTY; goto probe_fail2; } err = gpio_request_array(vid_gpios, ARRAY_SIZE(vid_gpios)); if (err) { printk(KERN_ERR "GPIO's not requestable. Damm"); err = -ENOTTY; goto probe_fail3; } //dbg_export_gpios_to_sysfs(); //we have gpio's now, turn the LED to red since we are not initalized bmi_video_ledset(VIDEO_LED_RED); // -- grab i2c for the dvi controller video->dvi_controller = i2c_new_device(adap, &tfp_info); if (video->dvi_controller == NULL){ printk(KERN_ERR "DVI monitor controller not found\n"); err = -ENOTTY; goto probe_fail4; } video->vga_controller = i2c_new_device(adap, &ths_info); if (video->vga_controller == NULL) { printk(KERN_ERR "VGA monitor controller not found\n"); err = -ENOTTY; goto probe_fail5; } //FUTURE: enable pulg event interrupt for GPIO //ths_info.irq = gpio_to_irq(DVI_MONITOR_SENSE_GPIO); // -- to get ths8201 on the bus OK, we need to do a reset cycle ths8200_disable(video->vga_controller);//TRICKY: does some setup -> //didn't have time to debug why this works and 'init' doesn't ths8200_standby(VGA_RESET_GPIO); err = device_create_file(&bdev->dev, &dev_attr_vmode); if (err < 0) printk(KERN_ERR "Error creating SYSFS entries...\n"); //TRCIKY: don't exit on this error, tolerate it err = scan_for_monitors(AUTO, video); //based on monitor's found, choose the best' if(video->dvi_monitor_edid) { printk(KERN_INFO "dvi monitor detected"); enable_dvi(video); } else if(video->vga_monitor_edid) { printk(KERN_INFO "vga monitor detected"); enable_vga(video); } else { printk(KERN_ERR "no monitor detected"); monitors_off(video); } err = device_create_file(&bdev->dev, &dev_attr_vga_edid); if (err < 0) printk(KERN_ERR "Error creating SYSFS entries...\n"); //TRCIKY: don't exit on this error, tolerate it err = device_create_file(&bdev->dev, &dev_attr_dvi_edid); if (err < 0) printk(KERN_ERR "Error creating SYSFS entries...\n"); //TRCIKY: don't exit on this error, tolerate it //request PIM interrupt irq = bdev->slot->status_irq; sprintf (video->int_name, "bmi_video%d", slot); bmi_device_set_drvdata (bdev, video); // -- successfuly loaded, even if not everyting is perfect return 0; // -- failure/error cleanup probe_fail5: if(video->dvi_controller) { i2c_unregister_device(video->dvi_controller); video->dvi_controller = NULL; } probe_fail4: //dbg_unexport_gpios_to_sysfs(); probe_fail3: if(video->gpio_controller) { i2c_unregister_device(video->gpio_controller); video->gpio_controller = NULL; } probe_fail2: if(video->eeprom_switch) { i2c_unregister_device(video->eeprom_switch); video->eeprom_switch = NULL; } probe_fail1: video->swap_eeprom = 0x00; video->swap_eeprom_state = OFF; return err; }
int main(int argc, char *argv[]) { /* Don't bother checking for privilege if they only want usage() */ if (argc < 2) goto usage; vbetool_init(); if (!strcmp(argv[1], "vbestate")) { /* VBE save/restore tends to break when done underneath X */ int err = check_console(); if (err) { return err; } if (!strcmp(argv[2], "save")) { save_state(); } else if (!strcmp(argv[2], "restore")) { restore_state(); } else { goto usage; } } else if (!strcmp(argv[1], "dpms")) { if (!strcmp(argv[2], "on")) { return do_blank(DPMS_STATE_ON); } else if (!strcmp(argv[2], "suspend")) { return do_blank(DPMS_STATE_SUSPEND); } else if (!strcmp(argv[2], "standby")) { return do_blank(DPMS_STATE_STANDBY); } else if (!strcmp(argv[2], "off")) { return do_blank(DPMS_STATE_OFF); } else if (!strcmp(argv[2], "reduced")) { return do_blank(DPMS_STATE_LOW); } else { goto usage; } } else if (!strcmp(argv[1], "vbemode")) { if (!strcmp(argv[2], "set")) { return do_set_mode(atoi(argv[3]),0); } else if (!strcmp(argv[2], "get")) { return do_get_mode(); } else { goto usage; } } else if (!strcmp(argv[1], "vgamode")) { if (!strcmp(argv[2], "set")) { return do_set_mode(atoi(argv[3]),1); } else { return do_set_mode(atoi(argv[2]),1); } } else if (!strcmp(argv[1], "post")) { /* Again, we don't really want to do this while X is in control */ int err = check_console(); if (err) { return err; } return do_post(); } else if (!strcmp(argv[1], "vgastate")) { if (!strcmp(argv[2], "on")) { return enable_vga(); } else { return disable_vga(); } } else if (!strcmp(argv[1], "vbefp")) { if (!strcmp(argv[2], "id") || !strcmp(argv[2], "panelid")) { return do_get_panel_id(0); } else if (!strcmp(argv[2], "panelsize")) { return do_get_panel_id(1); } else if (!strcmp(argv[2], "getbrightness")) { return do_get_panel_brightness(); } else if (!strcmp(argv[2], "setbrightness")) { return do_set_panel_brightness(atoi(argv[3])); } else if (!strcmp(argv[2], "invert")) { return do_invert_panel(); } else { return 1; } } else { usage: fprintf(stderr, "%s: Usage %s [[vbestate save|restore]|[vbemode set|get]|[vgamode]|[dpms on|off|standby|suspend|reduced]|[post]|[vgastate on|off]|[vbefp panelid|panelsize|getbrightness|setbrightness|invert]]\n", argv[0], argv[0]); return 1; } return 0; }
/* sysfs input, to set the current videomode */ static ssize_t bmi_video_vmode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct bmi_video *video = dev_get_drvdata(dev); int err = 0; if (strstr(buf, "dvi") != NULL || strstr(buf, "DVI") != NULL){ err = scan_for_monitors(DVI, video); if(err) { printk(KERN_ERR "scan_for_monitors DVI err %d",err); return len; } enable_dvi(video); } else if (strstr(buf, "vga") != NULL || strstr(buf, "VGA") != NULL){ err = scan_for_monitors(VGA, video); if(err) { printk(KERN_ERR "scan_for_monitors VGA err %d",err); return len; } enable_vga(video); } else if (strstr(buf, "auto") != NULL || strstr(buf, "AUTO") != NULL){ err = scan_for_monitors(AUTO, video); if(err) { printk(KERN_ERR "scan_for_monitors err %d",err); return len; } if(video->dvi_monitor_edid) { //printk(KERN_INFO "dvi monitor detected"); enable_dvi(video); } else if(video->vga_monitor_edid) { //printk(KERN_INFO "vga monitor detected"); enable_vga(video); } else { printk(KERN_INFO "no monitor detected"); monitors_off(video); } } //test functions else if (strstr(buf, "t1") != NULL){ ths8200_reset(VGA_RESET_GPIO,video->vga_controller); tfp410_disable(video->dvi_controller); } else if (strstr(buf, "t2") != NULL){ ths8200_reset(VGA_RESET_GPIO,video->vga_controller); tfp410_enable(video->dvi_controller); } else if (strstr(buf, "t3") != NULL){ ths8200_enable(video->vga_controller); } else if (strstr(buf, "t4") != NULL){ ths8200_disable(video->vga_controller); } else if (strstr(buf, "t5") != NULL){ ths8200_init(video->vga_controller); } else if (strstr(buf, "off") != NULL || strstr(buf, "OFF") != NULL){ ths8200_reset(VGA_RESET_GPIO,video->vga_controller); tfp410_disable(video->dvi_controller); ths8200_disable(video->vga_controller); } return len; }