int main ( int argc, char **argv ) { int period, half_period; int btn0, btn1; int count; /* Retreive the mapped GPIO memory. */ if(gpio_setup()==-1){ return -1; } period = 1000; /* default = 1Hz */ if ( argc > 1 ) { period = atoi ( argv[1] ); } half_period = period / 2; /* Setup GPIO of LED0 to output. */ if(gpio_config(GPIO_LED0,GPIO_OUTPUT_PIN)==-1 || gpio_config(GPIO_LED1,GPIO_OUTPUT_PIN)==-1 || gpio_config(GPIO_LED2,GPIO_OUTPUT_PIN)==-1 || gpio_config(GPIO_LED3,GPIO_OUTPUT_PIN)==-1 ){ return -1; } printf ( "-- info: start blinking @ %f Hz.\n", ( 1000.0f / period ) ); /* Blink led at frequency of 1Hz. */ count = 20; while ( --count > 0 ) { gpio_update(GPIO_LED0,count%2); delay(100); gpio_update(GPIO_LED1,count%2); delay(100); gpio_update(GPIO_LED2,count%2); delay(100); gpio_update(GPIO_LED3,count%2); delay(100); } /* Reset state of GPIO. */ gpio_update(GPIO_LED0,0); gpio_update(GPIO_LED1,0); gpio_update(GPIO_LED2,0); gpio_update(GPIO_LED3,0); gpio_config(GPIO_LED0,GPIO_INPUT_PIN); gpio_config(GPIO_LED1,GPIO_INPUT_PIN); gpio_config(GPIO_LED2,GPIO_INPUT_PIN); gpio_config(GPIO_LED3,GPIO_INPUT_PIN); /* Release the GPIO memory mapping. */ gpio_teardown(); return 0; }
static int gpiomux_s_radio(struct v4l2_subdev *sd) { struct cx18 *cx = v4l2_get_subdevdata(sd); /* * FIXME - work out the cx->active/audio_input mess - this is * intended to handle the switch to radio mode and set the * audio routing, but we need to update the state in cx */ gpio_update(cx, cx->card->gpio_audio_input.mask, cx->card->gpio_audio_input.radio); return 0; }
static void gpio_reset_seq(struct cx18 *cx, u32 active_lo, u32 active_hi, unsigned int assert_msecs, unsigned int recovery_msecs) { u32 mask; mask = active_lo | active_hi; if (mask == 0) return; /* * Assuming that active_hi and active_lo are a subsets of the bits in * gpio_dir. Also assumes that active_lo and active_hi don't overlap * in any bit position */ /* Assert */ gpio_update(cx, mask, ~active_lo); schedule_timeout_uninterruptible(msecs_to_jiffies(assert_msecs)); /* Deassert */ gpio_update(cx, mask, ~active_hi); schedule_timeout_uninterruptible(msecs_to_jiffies(recovery_msecs)); }
static int gpiomux_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) { struct cx18 *cx = v4l2_get_subdevdata(sd); u32 data; switch (route->input) { case 0: data = cx->card->gpio_audio_input.tuner; break; case 1: data = cx->card->gpio_audio_input.linein; break; case 2: data = cx->card->gpio_audio_input.radio; break; default: return -EINVAL; } gpio_update(cx, cx->card->gpio_audio_input.mask, data); return 0; }
static int gpiomux_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) { struct cx18 *cx = v4l2_get_subdevdata(sd); u32 data; switch (cx->card->audio_inputs[cx->audio_input].muxer_input) { case 1: data = cx->card->gpio_audio_input.linein; break; case 0: data = cx->card->gpio_audio_input.tuner; break; default: /* * FIXME - work out the cx->active/audio_input mess - this is * intended to handle the switch from radio mode and set the * audio routing, but we need to update the state in cx */ data = cx->card->gpio_audio_input.tuner; break; } gpio_update(cx, cx->card->gpio_audio_input.mask, data); return 0; }