static irqreturn_t s3c_fimc_irq(int irq, void *dev_id) { struct s3c_fimc_control *ctrl = (struct s3c_fimc_control *) dev_id; s3c_fimc_clear_irq(ctrl); s3c_fimc_check_fifo(ctrl); if (IS_CAPTURE(ctrl)) { dev_dbg(ctrl->dev, "irq is in capture state\n"); if (s3c_fimc_frame_handler(ctrl) == S3C_FIMC_FRAME_SKIP) return IRQ_HANDLED; wake_up_interruptible(&ctrl->waitq); } return IRQ_HANDLED; }
static ssize_t s3c_fimc_read(struct file *filp, char *buf, size_t count, loff_t *pos) { struct s3c_fimc_control *ctrl = filp->private_data; size_t end; if (IS_CAPTURE(ctrl)) { if (wait_event_interruptible(ctrl->waitq, IS_IRQ_HANDLING(ctrl))) return -ERESTARTSYS; FSET_STOP(ctrl); } //printk("[CAM]ctrl->out_frame.buf_size=%d,count=%d.\n",ctrl->out_frame.buf_size,count); end = min_t(size_t, ctrl->out_frame.buf_size, count); if (copy_to_user(buf, s3c_fimc_get_current_frame(ctrl), end)) return -EFAULT; return end; }
/* Types of moves: 1) King normal move 2) King captures 3) King castles 4) */ int playMove(const position * const pos, position *newPosition, const move * const m, const int player) { int opponent; opponent = OPPONENT(player); /* assert consistency of position */ assertPosition(pos); /* opponent cannot be check, this should be handled elsewhere */ assert(!inCheck(pos, opponent, pos->kingSquare[opponent])); /* init new position to old position */ *newPosition = *pos; /* opponent has to play in the new position */ newPosition->toPlay = opponent; movePiece(newPosition, m, player); if(IS_CAPTURE(m)) { /* clear bitmask for captured piece */ clearCapturedPiece(newPosition, m); } /* ep is disabled after any move played */ DISABLE_EP(newPosition); /* assert consistency of new position */ assertPosition(newPosition); return 0; }