void buttonlight_hw_off(void) { GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x80); #ifdef SANSA_C200 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */ #endif }
void _backlight_set_brightness(int val) { int oldlevel; if (current_dim < val) { do { oldlevel = disable_irq_save(); GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80); udelay(10); GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80); restore_irq(oldlevel); udelay(10); } while (++current_dim < val); } else if (current_dim > val) { do { oldlevel = disable_irq_save(); GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80); udelay(200); GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80); restore_irq(oldlevel); udelay(10); } while (--current_dim > val); } brightness = val; }
void _backlight_hw_enable(bool on) { #ifdef HAVE_LCD_SLEEP if (on) /* If the fade-out is interrupted, enabled will be true, but lcd_awake() needs to be called anyways because the LCD may be sleeping. */ lcd_awake(); #endif if (on == enabled) return; if (on) { GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80); sleep(HZ/100); current_dim = 16; _backlight_set_brightness(brightness); } else { GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80); GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08); sleep(HZ/20); } enabled = on; }
void button_init_device(void) { /* Enable all buttons */ GPIO_CLEAR_BITWISE(GPIOF_OUTPUT_EN, 0xff); GPIO_SET_BITWISE(GPIOF_ENABLE, 0xff); /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ GPIO_SET_BITWISE(GPIOG_OUTPUT_EN, 0x80); GPIO_SET_BITWISE(GPIOG_ENABLE, 0x80); #ifndef BOOTLOADER /* Mask these before performing init ... because init has possibly occurred before */ GPIO_CLEAR_BITWISE(GPIOF_INT_EN, 0xff); GPIO_CLEAR_BITWISE(GPIOH_INT_EN, 0xc0); GPIO_CLEAR_BITWISE(GPIOH_OUTPUT_EN, 0xc0); GPIO_SET_BITWISE(GPIOH_ENABLE, 0xc0); /* Read initial buttons */ button_int(); /* Read initial wheel value (bit 6-7 of GPIOH) */ read_wheel_keycode(); /* Enable button interrupts */ GPIO_SET_BITWISE(GPIOF_INT_EN, 0xff); GPIO_SET_BITWISE(GPIOH_INT_EN, 0xc0); CPU_INT_EN = HI_MASK; CPU_HI_INT_EN = GPIO1_MASK; #endif /* BOOTLOADER */ }
void usb_charging_maxcurrent_change(int maxcurrent) { bool suspend_charging = (maxcurrent < 100); bool fast_charging = (maxcurrent >= 500); /* This GPIO is connected to the LTC4066's SUSP pin */ /* Setting it high prevents any power being drawn over USB */ /* which supports USB suspend */ #if defined(IPOD_VIDEO) || defined(IPOD_NANO) if (suspend_charging) GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 4); else GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 4); #elif defined(IPOD_MINI2G) if (suspend_charging) GPIO_SET_BITWISE(GPIOJ_OUTPUT_VAL, 2); else GPIO_CLEAR_BITWISE(GPIOJ_OUTPUT_VAL, 2); #else /* Color, 4G, Mini G1 */ if (suspend_charging) GPO32_VAL |= 0x8000000; else GPO32_VAL &= ~0x8000000; #endif /* This GPIO is connected to the LTC4066's HPWR pin */ /* Setting it low limits current to 100mA, setting it high allows 500mA */ #if defined(IPOD_VIDEO) || defined(IPOD_NANO) if (fast_charging) GPIO_SET_BITWISE(GPIOA_OUTPUT_VAL, 4); else GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 4); #else if (fast_charging) GPO32_VAL |= 0x40; else GPO32_VAL &= ~0x40; #endif /* This GPIO is connected to the LTC4066's CLDIS pin */ /* Setting it high allows up to 1.5A of current to be drawn */ /* This doesn't appear to actually be safe even with an AC charger */ /* so for now it is disabled. It's not known (or maybe doesn't exist) */ /* on all models. */ #if 0 #if defined(IPOD_VIDEO) if (unlimited_charging) GPO32_VAL |= 0x10000000; else GPO32_VAL &= ~0x10000000; #elif defined(IPOD_4G) || defined(IPOD_COLOR) if (unlimited_charging) GPO32_VAL |= 0x200; else GPO32_VAL &= ~0x200; #endif /* This might be GPIOD & 40 on 2G */ #endif }
void backlight_hw_off(void) { GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x2); #ifdef HAVE_LCD_ENABLE lcd_enable(false); /* power off visible display */ #endif }
/* Remote buttons */ void remote_int(void) { int state = 0x01 & ~GPIOD_INPUT_VAL; GPIO_CLEAR_BITWISE(GPIOD_INT_EN, 0x01); GPIO_WRITE_BITWISE(GPIOD_INT_LEV, state, 0x01); if (state != 0) { /* necessary delay 1msec */ udelay(1000); unsigned int val = adc_scan(ADC_REMOTE); if (val > 750) int_btn = BUTTON_RC_MINUS; else if (val > 375) int_btn = BUTTON_RC_PLUS; else if (val > 100) int_btn = BUTTON_RC_REW; else int_btn = BUTTON_RC_FFWD; } else int_btn = BUTTON_NONE; GPIO_SET_BITWISE(GPIOD_INT_CLR, 0x01); GPIO_SET_BITWISE(GPIOD_INT_EN, 0x01); }
void ide_power_enable(bool on) { #if defined(IPOD_1G2G) || defined(IPOD_3G) if (on) GPIOC_OUTPUT_VAL &= ~0x40; else GPIOC_OUTPUT_VAL |= 0x40; #elif defined(IPOD_4G) || defined(IPOD_COLOR) \ || defined(IPOD_MINI) || defined(IPOD_MINI2G) if (on) { GPIO_CLEAR_BITWISE(GPIOJ_OUTPUT_VAL, 0x04); DEV_EN |= DEV_IDE0; } else { DEV_EN &= ~DEV_IDE0; GPIO_SET_BITWISE(GPIOJ_OUTPUT_VAL, 0x04); } #elif defined(IPOD_VIDEO) if (on) { GPO32_VAL &= ~0x40000000; sleep(1); /* only need 4 ms */ DEV_EN |= DEV_IDE0; GPIOG_ENABLE = 0; GPIOH_ENABLE = 0; GPIO_CLEAR_BITWISE(GPIOI_ENABLE, 0xBF); GPIO_CLEAR_BITWISE(GPIOK_ENABLE, 0x1F); udelay(10); } else { DEV_EN &= ~DEV_IDE0; udelay(10); GPIOG_ENABLE = 0xFF; GPIOH_ENABLE = 0xFF; GPIO_SET_BITWISE(GPIOI_ENABLE, 0xBF); GPIO_SET_BITWISE(GPIOK_ENABLE, 0x1F); GPO32_VAL |= 0x40000000; } #else /* Nano */ (void)on; /* Do nothing. */ #endif }
bool tuner_power(bool status) { GPIO_SET_BITWISE(GPIOL_ENABLE, 0x04); GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x04); if (status) GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x04); else GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x04); return status; }
void _backlight_off(void) { GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x2); #ifdef HAVE_LCD_ENABLE lcd_enable(false); /* power off visible display */ #endif #ifdef HAVE_LCD_SLEEP backlight_lcd_sleep_countdown(true); /* start countdown */ #endif }
void ide_power_enable(bool on) { if(on) { GPIO_CLEAR_BITWISE(GPIOC_OUTPUT_VAL, 0x08); DEV_EN |= DEV_IDE0; } else { DEV_EN &= ~DEV_IDE0; GPIO_SET_BITWISE(GPIOC_OUTPUT_VAL, 0x08); } }
/* Brightness control (iPod nano and videos only) */ static void ipod_set_brightness(int val) { int oldlevel; if (brightness_current < val) { do { oldlevel = disable_irq_save(); GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80); udelay(10); GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80); restore_irq(oldlevel); udelay(10); } while (++brightness_current < val); } else if (brightness_current > val) { do { oldlevel = disable_irq_save(); GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80); udelay(200); GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80); restore_irq(oldlevel); udelay(10); } while (--brightness_current > val); } }
void buttonlight_hw_off(void) { GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 0x02); /* vertical buttonlight */ GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 0x01); /* horizontal buttonlight */ GPIO_CLEAR_BITWISE(GPIOR_OUTPUT_VAL, 0x80); /* scrollwheel bottom led */ GPIO_CLEAR_BITWISE(GPIOR_OUTPUT_VAL, 0x40); /* scrollwheel right led */ GPIO_CLEAR_BITWISE(GPIOR_OUTPUT_VAL, 0x20); /* scrollwheel top led */ GPIO_CLEAR_BITWISE(GPIOR_OUTPUT_VAL, 0x10); /* scrollwheel left led */ }
void ide_power_enable(bool on) { #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) if (on) { GPIO_CLEAR_BITWISE(GPIOF_OUTPUT_VAL, 0x10); DEV_EN |= DEV_IDE0; } else { DEV_EN &= ~DEV_IDE0; GPIO_SET_BITWISE(GPIOF_OUTPUT_VAL, 0x10); } #else (void)on; /* We do nothing */ #endif }
void lcd_remote_init_device(void) { /* reset */ remote_dev_enable(false); rc_status |= RC_FORCE_DETECT; /* force detection at startup */ /* unknown */ GPIO_SET_BITWISE(GPIOL_ENABLE, 0x80); GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x80); GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80); /* a thread is required to poll & update the remote */ semaphore_init(&rc_thread_wakeup, 1, 0); remote_thread_id = create_thread(remote_thread, remote_stack, sizeof(remote_stack), 0, remote_thread_name IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU)); }
static void remote_dev_enable(bool enable) { if (enable) { outl(inl(0x70000018) | 0xaa000, 0x70000018); DEV_INIT2 &= ~0x800; GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x80); GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80); DEV_EN |= DEV_SER1; SER1_RBR; SER1_LCR = 0x80; SER1_DLL = 0x50; SER1_DLM = 0x00; SER1_LCR = 0x03; SER1_FCR = 0x07; rc_status |= RC_DEV_INIT; } else { outl(inl(0x70000018) & ~0xaa000, 0x70000018); DEV_INIT2 &= ~0x800; GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x80); GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80); DEV_RS |= DEV_SER1; nop; DEV_RS &= ~DEV_SER1; DEV_EN &= ~DEV_SER1; rc_status &= ~RC_DEV_INIT; } }
/* Switch the backlight off. Keeps the backlight circuit enabled. * Called in ISR context for fading, so it must be fast. */ void _backlight_led_off(void) { GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x80); }
void audio_input_mux(int source, unsigned flags) { (void)flags; /* Prevent pops from unneeded switching */ static int last_source = AUDIO_SRC_PLAYBACK; #ifdef HAVE_FMRADIO_REC bool recording = flags & SRCF_RECORDING; static bool last_recording = false; #endif #if defined(IPOD_COLOR) || defined (IPOD_4G) /* The usual magic from IPL - I'm guessing this configures the headphone socket to be input or output. */ if ((flags & SRCF_RECORDING) && source != AUDIO_SRC_PLAYBACK) { /* input */ GPIO_CLEAR_BITWISE(GPIOI_OUTPUT_VAL, 0x40); GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 0x04); } else { /* output */ GPIO_SET_BITWISE(GPIOI_OUTPUT_VAL, 0x40); GPIO_SET_BITWISE(GPIOA_OUTPUT_VAL, 0x04); } #endif /* IPOD_COLOR || IPOD_4G */ switch (source) { default: /* playback - no recording */ source = AUDIO_SRC_PLAYBACK; case AUDIO_SRC_PLAYBACK: #ifdef HAVE_RECORDING if (source != last_source) { audiohw_set_monitor(false); audiohw_disable_recording(); } #endif break; #ifdef HAVE_MIC_REC case AUDIO_SRC_MIC: /* recording only */ if (source != last_source) { audiohw_set_monitor(false); audiohw_enable_recording(true); /* source mic */ } break; #endif #ifdef HAVE_LINE_REC case AUDIO_SRC_LINEIN: /* recording only */ #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) /* Switch line in source to line-in */ GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x04); #endif if (source != last_source) { audiohw_set_monitor(false); audiohw_enable_recording(false); /* source line */ } break; #endif #ifdef HAVE_FMRADIO_REC case AUDIO_SRC_FMRADIO: /* recording and playback */ #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) /* Switch line in source to tuner */ GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x04); /* Set line-in vol to +12dB, which is proper for H10's */ if (!recording) audiohw_set_recvol(0x1f, 0x1f, AUDIO_GAIN_LINEIN); #else /* Set line-in vol to 0dB*/ if (!recording) audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN); #endif if (source == last_source && recording == last_recording) break; last_recording = recording; #if CONFIG_TUNER & IPOD_REMOTE_TUNER /* Ipod FM tuner is in the remote connected to line-in */ audiohw_enable_recording(false); /* source line */ audiohw_set_monitor(true); /* enable bypass mode */ #else if (recording) { audiohw_set_monitor(false); /* disable bypass mode */ audiohw_enable_recording(false); /* select line-in source */ } else { audiohw_disable_recording(); audiohw_set_monitor(true); /* enable bypass mode */ } #endif break; #endif } /* end switch */ last_source = source; } /* audio_input_mux */
void backlight_hw_off(void) { GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x01); }
void _buttonlight_on(void) { GPIO_CLEAR_BITWISE(GPIOA_ENABLE, 0x2); }