static int rotation_thread_function(void *data) { struct sd *sd = (struct sd *) data; struct s5k83a_priv *sens_priv = sd->sensor_priv; u8 reg, previous_rotation = 0; __s32 vflip, hflip; set_current_state(TASK_INTERRUPTIBLE); while (!schedule_timeout(100)) { if (mutex_lock_interruptible(&sd->gspca_dev.usb_lock)) break; s5k83a_get_rotation(sd, ®); if (previous_rotation != reg) { previous_rotation = reg; info("Camera was flipped"); s5k83a_get_vflip((struct gspca_dev *) sd, &vflip); s5k83a_get_hflip((struct gspca_dev *) sd, &hflip); if (reg) { vflip = !vflip; hflip = !hflip; } s5k83a_set_flip_real((struct gspca_dev *) sd, vflip, hflip); } mutex_unlock(&sd->gspca_dev.usb_lock); set_current_state(TASK_INTERRUPTIBLE); } /* return to "front" flip */ if (previous_rotation) { s5k83a_get_vflip((struct gspca_dev *) sd, &vflip); s5k83a_get_hflip((struct gspca_dev *) sd, &hflip); s5k83a_set_flip_real((struct gspca_dev *) sd, vflip, hflip); } sens_priv->rotation_thread = NULL; return 0; }
static int rotation_thread_function(void *data) { struct sd *sd = (struct sd *) data; u8 reg, previous_rotation = 0; __s32 vflip, hflip; set_current_state(TASK_INTERRUPTIBLE); while (!schedule_timeout(msecs_to_jiffies(100))) { if (mutex_lock_interruptible(&sd->gspca_dev.usb_lock)) break; s5k83a_get_rotation(sd, ®); if (previous_rotation != reg) { previous_rotation = reg; pr_info("Camera was flipped\n"); hflip = sd->hflip->val; vflip = sd->vflip->val; if (reg) { vflip = !vflip; hflip = !hflip; } s5k83a_set_flip_real((struct gspca_dev *) sd, vflip, hflip); } mutex_unlock(&sd->gspca_dev.usb_lock); set_current_state(TASK_INTERRUPTIBLE); } /* return to "front" flip */ if (previous_rotation) { hflip = sd->hflip->val; vflip = sd->vflip->val; s5k83a_set_flip_real((struct gspca_dev *) sd, vflip, hflip); } sd->rotation_thread = NULL; return 0; }
static int s5k83a_set_hvflip(struct gspca_dev *gspca_dev) { int err; u8 reg; struct sd *sd = (struct sd *) gspca_dev; int hflip = sd->hflip->val; int vflip = sd->vflip->val; err = s5k83a_get_rotation(sd, ®); if (err < 0) return err; if (reg) { hflip = !hflip; vflip = !vflip; } err = s5k83a_set_flip_real(gspca_dev, vflip, hflip); return err; }
static int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val) { int err; u8 reg; __s32 vflip; struct sd *sd = (struct sd *) gspca_dev; struct s5k83a_priv *sens_priv = sd->sensor_priv; sens_priv->settings[HFLIP_IDX] = val; s5k83a_get_vflip(gspca_dev, &vflip); err = s5k83a_get_rotation(sd, ®); if (err < 0) return err; if (reg) { val = !val; vflip = !vflip; } err = s5k83a_set_flip_real(gspca_dev, vflip, val); return err; }