117c117 < .default_value = 0x9b, // (decimal: 155) --- > .default_value = 155,//0x9b, // (decimal: 155) 118a119 > .flags = V4L2_CTRL_FLAG_SLIDER, 126c127 < .default_value = 0x5e, // (decimal: 94) --- > .default_value = 94, //0x5e, // (decimal: 94) 127a129 > .flags = V4L2_CTRL_FLAG_SLIDER, 130a133,146 > //formats supported by the driver > static const struct hrt_format formats[] = { > { > .name = "GREYSCALE", > .fourcc = V4L2_PIX_FMT_GREY, > .depth = 8, > },{ > .name = "COLOR", > .fourcc = V4L2_PIX_FMT_RGB565, > .depth = 16, > } > }; > > static const unsigned int FORMATS = ARRAY_SIZE(formats); 187a204,206 > //variables to keep track of the brightness and contrast manipulated by the vidioc > int brightness, contrast; > 188a208 > int index; 269a290,294 > /* > #ifdef VIDIOC_G_PRIORITY > struct v4l2_prio_state prio; > #endif > */ 298,299d322 < int hrt_ioctl (struct inode *inode, struct file *filp, < unsigned int cmd, unsigned long arg); 302,303d324 < static int hrt_do_private_ioctl(hrt_t *hrtdev, unsigned int cmd, < unsigned long arg); 312c333 < .ioctl = hrt_ioctl, --- > .ioctl = video_ioctl2, 328,336d348 < /********************************************************************/ < static struct video_device videodev_template = { < .owner = THIS_MODULE, < .name = "HRT Pixelsmart (PS512-8-PCI)", < .type = HRT_VID_TYPE, < .hardware = VID_HARDWARE_HRT, < .fops = &hrt_fops, < .release = grabber_release, < }; 343c355,356 < * but also the subwindow structure that represents the subwindow --- > * but also the > structure that represents the subwindow 356c369 < static unsigned int disable_streaming = 0; --- > static unsigned int disable_streaming = 1; 365c378 < MODULE_LICENSE("GPL"); --- > MODULE_LICENSE("Dual BSD/GPL"); 419,430d431 < /* Veena and Arthi's streaming functions */ < int mmap_request_buffers(hrt_t *dev, < struct v4l2_requestbuffers *req); < int hrt_streamon(hrt_t *hrtdev, __u32 type); < void hrt_streamoff(hrt_t *hrtdev, __u32 type); < int hrt_dequeuebuffer(hrt_t *hrtdev, < struct v4l2_buffer *buf); < int hrt_queuebuffer(hrt_t *hrtdev, < struct v4l2_buffer *buf); < < < 529a532,1210 > > /* Veena and Arthi's streaming functions */ > int mmap_request_buffers(hrt_t *dev, > struct v4l2_requestbuffers *req); > int hrt_streamon(hrt_t *hrtdev, __u32 type); > void hrt_streamoff(hrt_t *hrtdev, __u32 type); > int hrt_dequeuebuffer(hrt_t *hrtdev, > struct v4l2_buffer *buf); > int hrt_queuebuffer(hrt_t *hrtdev, > struct v4l2_buffer *buf); > > > /******************************************************************** > ******** timer/tasklet related functions declared here *********** > */ > > void hrt_tasklet(unsigned long); > void hrt_timer_init(hrt_t* dev); > void hrt_timer_cleanup(hrt_t* dev); > int hrt_timer_activate(hrt_t* dev); > void hrt_timer_deactivate(hrt_t* dev); > > > /*********************** VIDIOC **********************************/ > static int hrt_vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i); > static int hrt_vidioc_querycap(struct file *file, void *priv, > struct v4l2_capability *b); > static int hrt_vidioc_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *req); > static int hrt_vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *buf); > static int hrt_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf); > static int hrt_vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf); > > static int hrt_vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type type); > static int hrt_vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type type); > > static int hrt_vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f); > static int hrt_vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f); > static int hrt_vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f); > static int hrt_vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f); > > static int hrt_vidioc_g_input(struct file *, void *, unsigned int *); > static int hrt_vidioc_s_input(struct file *, void *, unsigned int); > static int hrt_vidioc_g_std(struct file *, void *, v4l2_std_id*); > static int hrt_vidioc_s_std(struct file *, void *, v4l2_std_id*); > > static int hrt_vidioc_queryctrl(struct file *, void *, struct v4l2_queryctrl *); > static int hrt_vidioc_s_ctrl(struct file *, void *, struct v4l2_control *); > static int hrt_vidioc_g_ctrl(struct file *, void *, struct v4l2_control *); > > /* > static int hrt_vidioc_s_priority(struct file *, void *, enum v4l2_priority); > static int hrt_vidioc_g_priority(struct file *, void *, enum v4l2_priority *); > */ > > static int hrt_vidioc_overlay(struct file*, void*, unsigned int); > > > /********************************** V4L2 IOCTLS *************************************/ > > static const struct hrt_format* format_by_fourcc(int fourcc) { > unsigned int i; > > for (i = 0; i < FORMATS; i++) { > if (-1 == formats[i].fourcc) > continue; > if (formats[i].fourcc == fourcc) > return formats+i; > } > > return NULL; > } > > static int hrt_vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f){ > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > hrtdev->win = &per_file->win; > > hrt_printk("VIDIOC_S_FMT: BEFORE SETTING THE FORMAT\n"); > hrt_printk("VIDIOC_S_FMT: fmt.type = %u\n", (unsigned int)f->type); > hrt_printk("VIDIOC_S_FMT: pix.width = %u\n", (unsigned int)f->fmt.pix.width); > hrt_printk("VIDIOC_S_FMT: pix.height = %u\n", (unsigned int)f->fmt.pix.height); > hrt_printk("VIDIOC_S_FMT: pix.field = %u\n", (unsigned int)f->fmt.pix.field); > hrt_printk("VIDIOC_S_FMT: pix.pixelformat = %u\n", (unsigned int)f->fmt.pix.pixelformat); > hrt_printk("VIDIOC_S_FMT: fourcc: %c, %c, %c, %c \n", > (char)f->fmt.pix.pixelformat & 0xFF, > (char)((f->fmt.pix.pixelformat >> 8) & 0xFF), > (char)((f->fmt.pix.pixelformat >> 16) & 0xFF), > (char)((f->fmt.pix.pixelformat >> 24) & 0xFF)); > hrt_printk("VIDIOC_S_FMT: pix.colorspace = %u\n", (unsigned int)f->fmt.pix.colorspace); > hrt_printk("VIDIOC_S_FMT: pix.bytesperline = %u\n", (unsigned int)f->fmt.pix.bytesperline); > hrt_printk("VIDIOC_S_FMT: pix.sizeimage = %u\n", (unsigned int)f->fmt.pix.sizeimage); > hrt_printk("VIDIOC_S_FMT: pix.priv = %u\n", (unsigned int)f->fmt.pix.priv); > > if (0 != hrt_vidioc_try_fmt(file, priv, f)){ > hrt_printk("VIDIOC_S_FMT: try_fmt failed\n"); > return -EINVAL; > } > > hrtdev->win->width = f->fmt.pix.width; > hrtdev->win->height = f->fmt.pix.height; > > hrt_printk("---VIDIOC_S_FMT: AFTER SETTING THE FORMAT\n"); > hrt_printk("---VIDIOC_S_FMT: fmt.type = %u\n", (unsigned int)f->type); > hrt_printk("---VIDIOC_S_FMT: pix.width = %u\n", (unsigned int)f->fmt.pix.width); > hrt_printk("---VIDIOC_S_FMT: pix.height = %u\n", (unsigned int)f->fmt.pix.height); > hrt_printk("---VIDIOC_S_FMT: pix.field = %u\n", (unsigned int)f->fmt.pix.field); > hrt_printk("---VIDIOC_S_FMT: pix.pixelformat = %u\n", (unsigned int)f->fmt.pix.pixelformat); > hrt_printk("---VIDIOC_S_FMT: pix.bytesperline = %u\n", (unsigned int)f->fmt.pix.bytesperline); > hrt_printk("---VIDIOC_S_FMT: pix.sizeimage = %u\n", (unsigned int)f->fmt.pix.sizeimage); > hrt_printk("---VIDIOC_S_FMT: pix.priv = %u\n", (unsigned int)f->fmt.pix.priv); > > return 0; > } > > static int hrt_vidioc_g_fmt(struct file *file, void *priv, > struct v4l2_format *f){ > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > hrtdev->win = &per_file->win; > > hrt_printk("VIDIOC_G_FMT: entry\n"); > > if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { > > f->fmt.pix.width = hrtdev->win->width; > f->fmt.pix.height = hrtdev->win->height; > > if(hrtdev->mode & HRT_COLOR_MODE) > f->fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565; > else > f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY; > > > f->fmt.pix.field = V4L2_FIELD_INTERLACED; > f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; > > f->fmt.pix.bytesperline = hrtdev->bytesperline; > f->fmt.pix.sizeimage = hrtdev->framesize; > > hrt_printk("VIDIOC_G_FMT: exit successful\n"); > > return 0; > } > else{ > hrt_printk("VIDIOC_G_FMT: exit fail\n"); > return -EINVAL; > } > } > > static int hrt_vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) { > const struct hrt_format *fmt; > enum v4l2_field field; > __s32 width, height; > > printk(KERN_NOTICE "htr_vidioc_try_frm: starting\n"); > > fmt = format_by_fourcc(f->fmt.pix.pixelformat); > if (NULL == fmt) { > printk(KERN_NOTICE "htr_vidioc_try_frm: invalid format; returning -EINVAL\n"); > return -EINVAL; > } > > field = f->fmt.pix.field; > if (V4L2_FIELD_ANY == field) { > printk(KERN_NOTICE "htr_vidioc_try_frm: field was ANY; setting field to INTERLACED.\n"); > field = V4L2_FIELD_INTERLACED; > > } > > if (V4L2_FIELD_INTERLACED != field) { > printk(KERN_NOTICE "htr_vidioc_try_frm: field is not INTERLACED; returning -EINVAL.\n"); > return -EINVAL; > } > > width = f->fmt.pix.width; > height = f->fmt.pix.width; > > f->fmt.pix.field = field; > f->fmt.pix.width = width; > f->fmt.pix.height = height; > f->fmt.pix.bytesperline = width; > f->fmt.pix.sizeimage = (width * height * fmt->depth); > > return 0; > } > > /*static int hrt_vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f){ > struct hrt_per_file *per_file = file->private_data; > hrt_t *dev = per_file->hrtdev; > > hrt_printk("VIDIOC_TRY_FMT: entry\n"); > > if(f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { > hrt_printk("VIDIOC_TRY_FMT: type != capture\n"); > return -EINVAL; > } > > if(f->fmt.pix.height > 480 || f->fmt.pix.height <= 0){ > hrt_printk("VIDIOC_TRY_FMT: incorrect height\n"); > return -EINVAL; > } > > if (f->fmt.pix.field == V4L2_FIELD_ANY) > f->fmt.pix.field = V4L2_FIELD_INTERLACED; > else if (f->fmt.pix.field != V4L2_FIELD_INTERLACED){ > hrt_printk("VIDIOC_TRY_FMT: incorrect field\n"); > return -EINVAL; > } > > f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; > > if(dev->mode & HRT_COLOR_MODE) { > if(f->fmt.pix.width > 640 || f->fmt.pix.width <= 0){ > hrt_printk("VIDIOC_TRY_FMT: incorrect width: %d\n", > (int)f->fmt.pix.width); > return -EINVAL; > } > f->fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565; > f->fmt.pix.bytesperline = f->fmt.pix.width * 2; > f->fmt.pix.sizeimage = f->fmt.pix.width * 2 * f->fmt.pix.height; > } else { > if(f->fmt.pix.width > 512 || f->fmt.pix.width <= 0){ > hrt_printk("VIDIOC_TRY_FMT: incorrect width: %d\n", > (int)f->fmt.pix.width); > return -EINVAL; > } > f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY; > f->fmt.pix.bytesperline = f->fmt.pix.width; > f->fmt.pix.sizeimage = f->fmt.pix.width * f->fmt.pix.height; > } > > return 0; > } > */ > > static int hrt_vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f) { > int index = -1, i; > > for (i = 0; i < FORMATS; i++) { > if (formats[i].fourcc != -1) > index++; > if ((unsigned int)index == f->index) > break; > } > if (FORMATS == i) { > return -EINVAL; > } > > f->pixelformat = formats[i].fourcc; > strlcpy(f->description, formats[i].name, sizeof(f->description)); > > return 0; > } > > /*static int hrt_vidioc_enum_fmt(struct file *file, void *priv, > struct v4l2_fmtdesc *f){ > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > int index = f->index; > > hrt_printk("VIDIOC_ENUM_FMT: entry\n"); > > //There's only one format > if (index > 0){ > hrt_printk("VIDIOC_ENUM_FMT: exit fail: index out of range\n"); > return -EINVAL; > } > > if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && f->type != 0) { > memset(f, 0, sizeof(*f)); > f->index = 0; > f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > > if(hrtdev->mode & HRT_COLOR_MODE){ > f->pixelformat = V4L2_PIX_FMT_RGB565X; > strcpy(f->description, "RGBR"); > } else { > f->pixelformat = V4L2_PIX_FMT_GREY; > strcpy(f->description, "Grey"); > } > > return 0; > } else { > hrt_printk("VIDIOC_ENUM_FMT: exit fail: invalid type\n"); > return -EINVAL; > } > } > > static int hrt_vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f){ > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > int index = f->index; > > hrt_printk("VIDIOC_ENUM_FMT: entry\n"); > > //There's only one format > if (index > 0){ > hrt_printk("VIDIOC_ENUM_FMT: exit fail: index out of range\n"); > return -EINVAL; > } > > if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && f->type != 0) { > memset(f, 0, sizeof(*f)); > f->index = 0; > f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > > if(hrtdev->mode & HRT_COLOR_MODE){ > f->pixelformat = V4L2_PIX_FMT_RGB565X; > strcpy(f->description, "RGBR"); > } else { > f->pixelformat = V4L2_PIX_FMT_GREY; > strcpy(f->description, "Grey"); > } > > return 0; > } else { > hrt_printk("VIDIOC_ENUM_FMT: exit fail: invalid type\n"); > return -EINVAL; > } > } > */ > > static int hrt_vidioc_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *req){ > > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_REQBUFS: entry\n"); > > if (hrtdev->stream_buffers_mapped) { > hrt_printk("VIDIOC: REQBUFS - Can't request buffers if " > " buffers are already mapped\n"); > return -EPERM; > } > if (!mmap_request_buffers(hrtdev, req)) { > hrt_printk("VIDIOC: REQBUFS - Request of buffers failed\n"); > return -EINVAL; > } > return 0; > } > > static int hrt_vidioc_querybuf(struct file *file, void *priv, > struct v4l2_buffer *buf){ > > int i; > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_QUERYBUF: entry\n"); > > i = buf->index; > > if (i < 0 || i >= MAX_CAPTURE_BUFFERS || > !hrtdev->stream_buf[i].requested || > (buf->type & V4L2_BUF_TYPE_VIDEO_CAPTURE) != > (hrtdev->stream_buf[i].vidbuf.type & V4L2_BUF_TYPE_VIDEO_CAPTURE)) { > hrt_printk("VIDIOC_QUERYBUF: QUERYBUF - bad parameter\n"); > return -EINVAL; > } > > *buf = hrtdev->stream_buf[i].vidbuf; > return 0; > } > > static int hrt_vidioc_qbuf(struct file *file, void *priv, > struct v4l2_buffer *buf){ > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_QBUF: entry\n"); > > > if (!hrtdev->stream_buffers_mapped) { > hrt_printk("VIDIOC: QBUF: FAIL: buffers unmapped\n"); > return -EINVAL; > } > > if (!hrt_queuebuffer(hrtdev, buf)) { > hrt_printk("VIDIOC: QBUF: FAIL: queuebuffer failed\n"); > return -EINVAL; > } > return 0; > } > > static int hrt_vidioc_dqbuf(struct file *file, void *priv, > struct v4l2_buffer *buf){ > > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_DQBUF: entry\n"); > > > if (!hrt_dequeuebuffer(hrtdev, buf)) { > hrt_printk("VIDIOC: DQBUF: FAIL: dequeuebuffer failed\n"); > return -EINVAL; > } > return 0; > } > > static int hrt_vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type type){ > > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_STREAMON: entry\n"); > > if (!hrt_streamon(hrtdev, type)){ > hrt_printk("VIDIOC_STREAMON: exit fail: streamon failed\n"); > return -EINVAL; > } > > return 0; > } > > static int hrt_vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type type){ > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_STREAMOFF: entry\n"); > > hrt_streamoff(hrtdev, type); > > return 0; > } > > static int hrt_vidioc_querycap(struct file *file, void *priv, > struct v4l2_capability *b){ > > struct hrt_per_file *per_file = file->private_data; > hrt_t *hrtdev = per_file->hrtdev; > > hrt_printk("VIDIOC_QUERYCAP: entry\n"); > > strcpy(b->driver, "hrt"); > > if(hrtdev->mode & HRT_COLOR_MODE) > strncpy(b->card, "Video Gala", sizeof(b->card)); > else > strncpy(b->card, "PS 512-8-PCI", sizeof(b->card)); > > b->version = KERNEL_VERSION(0, 0, 3); > > if (disable_streaming) { > b->capabilities = V4L2_CAP_VIDEO_CAPTURE; > } > else { > b->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; > } > return 0; > } > > static int hrt_vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i){ > unsigned int n = i->index; > > > hrt_printk("VIDIOC_ENUM_INPUT: entry\n"); > > > //both of the cards we're dealing with have only one input, > //so we just check against that instead of allocating variables to hold that. > if (n >= 1){ > hrt_printk("VIDIOC_ENUM_INPUT: invalid index\n"); > return -EINVAL; > } > > //clear all memory in the v4l2_input struct passed in by the user. > memset(i, 0, sizeof(*i)); > > //reset the data in the v4l2_input struct > > i->index = 0; //index 0 for the first and only input option that we have... > > i->type = V4L2_INPUT_TYPE_CAMERA; > > //we don't support audio; just pick a source. also, we don't need > //to enumerate the audio inputs, since there are no choices anyway. > i->audioset = 0; > > sprintf(i->name, "Camera"); > > i->std = V4L2_STD_NTSC; //set to ntsc; it's the only tv norm we're supporting. > > return 0; > } > > static int hrt_vidioc_g_input(struct file* file, void *priv, unsigned int *index) { > //Nothing to do here, really. Both cards we support only have one input each, > //i.e. index must be 0 at all times. > > hrt_printk("VIDIOC_G_INPUT: entry\n"); > > *index = 0; > return 0; > } > > static int hrt_vidioc_s_input(struct file* file, void *priv, unsigned int index) { > //Nothing to do here, really. Both cards we support only have one input each, > //i.e. index must be 0 at all times. > > hrt_printk("VIDIOC_G_INPUT: entry\n"); > > if (index != 0){ > hrt_printk("VIDIOC_G_INPUT: exit fail: invalid index\n"); > return -EINVAL; > } > > return 0; > } > > /* > static int hrt_vidioc_s_priority(struct file *file, void *priv, enum v4l2_priority prio) { > > hrt_t *hrtdev = priv; > return v4l2_prio_change(&hrtdev->prio, &priv->prio, prio); > > return -EINVAL; > } > > static int hrt_vidioc_g_priority(struct file *file, void *priv, enum v4l2_priority *prio) { > hrt_t *hrtdev = priv; > *prio = v4l2_prio_max(&hrtdev->prio); > return 0; > } > */ > > static int hrt_vidioc_g_std(struct file *file, void *priv, v4l2_std_id *std){ > > hrt_printk("VIDIOC_G_STD: entry\n"); > > //Not much to do here; we only support NTSC, > //so just return that when the function is called. > > *std = V4L2_STD_NTSC; > return 0; > } > > static int hrt_vidioc_s_std(struct file *file, void *priv, v4l2_std_id* std){ > > hrt_printk("VIDIOC_S_STD: entry\n"); > > //Not much to do here; we only support NTSC, > //so any other value passed in by the user just return invalid. > if(*std != V4L2_STD_NTSC){ > hrt_printk("VIDIOC_S_STD: exit fail: unsupported standard\n"); > return -EINVAL; > } > > return 0; > } > > static int hrt_vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c) { > /* > if ((c->id < V4L2_CID_BASE || c->id >= V4L2_CID_LASTP1) > && (c->id < V4L2_CID_PRIVATE_BASE || c->id >= V4L2_CID_PRIVATE_LASTP1)) > return -EINVAL; > */ > > hrt_printk("VIDIOC_QUERYCTRL: entry\n"); > > if (c->id != V4L2_CID_BRIGHTNESS && c->id != V4L2_CID_CONTRAST){ > hrt_printk("VIDIOC_QUERYCTRL: exit fail: unavailable control\n"); > return -EINVAL; > } > > if (c->id == V4L2_CID_BRIGHTNESS) { > *c = hrt_ctls[0]; > } else if (c->id == V4L2_CID_CONTRAST) { > *c = hrt_ctls[1]; > } > > return 0; > } > > static int hrt_vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *c) { > struct hrt_per_file *per_file = file->private_data; > hrt_t *dev = per_file->hrtdev; > > hrt_printk("VIDIOC_S_CTRL: entry\n"); > > > /* FIX: reporting bad access port in log */ > switch (c->id) { > case V4L2_CID_BRIGHTNESS: > dev->brightness = c->value; > iowrite8(c->value, (void *)(HRT_CONTROL(HRT_BRIGHTNESS_REG) + dev->virt_addr)); > break; > > case V4L2_CID_CONTRAST: > dev->contrast = c->value; > iowrite8(c->value, (void *)(HRT_CONTROL(HRT_CONTRAST_REG) + dev->virt_addr)); > break; > > default: > hrt_printk("VIDIOC_QUERYCTRL: exit fail: unavailable control\n"); > return -EINVAL; > } > return 0; > } > > static int hrt_vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *c) { > > struct hrt_per_file *per_file = file->private_data; > hrt_t *dev = per_file->hrtdev; > > hrt_printk("VIDIOC_G_CTRL: entry\n"); > > switch (c->id) { > case V4L2_CID_BRIGHTNESS: > c->value = dev->brightness; > break; > > case V4L2_CID_CONTRAST: > c->value = dev->contrast; > break; > > default: > hrt_printk("VIDIOC_QUERYCTRL: exit fail: unavailable control\n"); > return -EINVAL; > } > > return 0; > } > > static int hrt_vidioc_overlay(struct file *file, void *f, unsigned int on){ > > hrt_printk("VIDIOC_OVERLAY: exit fail: video overlay unsupported\n"); > > return -EINVAL; > } > > static struct video_device hrt_video_template = { > .name = "HRT", > .type = HRT_VID_TYPE, > .minor = -1, > .fops = &hrt_fops, > .release = grabber_release, > .vidioc_querycap = hrt_vidioc_querycap, > .vidioc_reqbufs = hrt_vidioc_reqbufs, > .vidioc_querybuf = hrt_vidioc_querybuf, > .vidioc_qbuf = hrt_vidioc_qbuf, > .vidioc_dqbuf = hrt_vidioc_dqbuf, > .vidioc_querystd = hrt_vidioc_g_std, > .vidioc_s_std = hrt_vidioc_s_std, > .vidioc_g_input = hrt_vidioc_g_input, > .vidioc_s_input = hrt_vidioc_s_input, > .vidioc_queryctrl = hrt_vidioc_queryctrl, > .vidioc_g_ctrl = hrt_vidioc_g_ctrl, > .vidioc_s_ctrl = hrt_vidioc_s_ctrl, > .vidioc_streamon = hrt_vidioc_streamon, > .vidioc_streamoff = hrt_vidioc_streamoff, > > .vidioc_s_fmt_cap = hrt_vidioc_s_fmt, > .vidioc_g_fmt_cap = hrt_vidioc_g_fmt, > .vidioc_try_fmt_cap = hrt_vidioc_try_fmt, > .vidioc_enum_fmt_cap = hrt_vidioc_enum_fmt, > > .vidioc_enum_input = hrt_vidioc_enum_input, > // .vidioc_s_priority = hrt_vidioc_s_priority, > // .vidioc_g_priority = hrt_vidioc_g_priority, > .vidioc_overlay = hrt_vidioc_overlay, > .tvnorms = V4L2_STD_NTSC, > .current_norm = V4L2_STD_NTSC, > }; > > > 739,832d1419 < * hrt_do_private_ioctl - handle private ioctl's on device < */ < static int hrt_do_private_ioctl(hrt_t *hrtdev, unsigned int cmd, < unsigned long arg) < { < if (cmd == IOC_HRT_NEXT_MMAP_IS_DIRECT) { < /* The next mmap() that's called on /dev/video < will map the device's memory directly- this is < for userspace drivers */ < next_mmap_is_direct = 1; < return 0; < } < /*else if (cmd == IOC_HRT_SET_I2CREG) { < struct i2c_regval r; < < if (copy_from_user(&r, (void *) arg, sizeof(r))) { < return -EFAULT; < } < i2c_set_reg(hrtdev, r.reg, r.val); < return 0; < } else if (cmd == IOC_HRT_GET_I2CREG) { < struct i2c_regval r; < < r.val = hrtdev->regvals[r.reg]; < if (copy_to_user((void *) arg, &r, sizeof(r))) { < return -EFAULT; < } < return 0; < } < */ < /* Set the region of interest - subwindow */ < else if (cmd == IOC_HRT_SET_ROI) { < struct subwindow win; < < if (copy_from_user(&win, (void *) arg, sizeof(win))) { < hrt_printk("ioctl IOC_HRT_SET_ROI failed\n"); < return -EFAULT; < } < /* Check if the specified height and width are valid values */ < if (win.height > HRT_HEIGHT || win.height < 0) return -EINVAL; < if(hrtdev->mode & HRT_COLOR_MODE){ < if (win.width > HRT_COLOR_WIDTH || win.width < 0) return -EINVAL; < } < else{ < if (win.width > HRT_GRAY_WIDTH || win.width < 0) return -EINVAL; < } < if (win.startx > win.width || win.startx < 0) return -EINVAL; < if (win.starty > win.height || win.starty < 0) return -EINVAL; < hrt_printk ("setting hrtdev->win\n"); < *hrtdev->win = win; < return 0; < /* Return the current region of interest parameters to the user */ < } else if (cmd == IOC_HRT_GET_ROI) { < if (copy_to_user((void *) arg, hrtdev->win, < sizeof(*hrtdev->win))) { < hrt_printk("ioctl IOC_HRT_GET_ROI failed\n"); < return -EFAULT; < } < return 0; < } < /* else if (cmd == IOC_HRT_SET_I2CREGS) { */ < /* unsigned char len; */ < /* int retval; */ < /* unsigned char *buf; */ < < /* /\* Stop the timer first *\/ */ < /* del_timer_sync(&timer); */ < /* timer_running = 0; */ < < /* /\* First byte is the length of the array *\/ */ < /* if (copy_from_user(&len, (void *) arg, 1)) */ < /* return -EFAULT; */ < /* dprintk("size of array = %d\n", len); */ < < /* buf = vmalloc(len + 1); */ < /* if (copy_from_user(buf, (void *) arg, len)) { */ < /* vfree(buf); */ < /* return -EFAULT; */ < /* } */ < /* retval = i2c_init(hrtdev, buf); */ < /* vfree(buf); */ < < /* /\* Start the timer again *\/ */ < /* timer.expires = jiffies + (HZ/100); */ < /* add_timer(&timer); */ < /* timer_running = 1; */ < /* return retval; */ < < return -EINVAL; < } < < < /********************************************************************/ < /** 1096,1097c1683,1684 < * This function is implemented differantly for color and gray scale devices < * since they are stored differantly inside the device's memory --- > * This function is implemented differently for color and gray scale devices > * since they are stored differently inside the device's memory 1117,1119c1704 < void grab_field( hrt_t *hrtdev, unsigned char *framedata, < int parity) < { --- > void grab_field( hrt_t *hrtdev, unsigned char *framedata, int parity) { 1201c1786 < * However the destination for the copy is differant for the case of streaming I/O --- > * However the destination for the copy is different for the case of streaming I/O 1261c1846 < printk(KERN_ALERT "\nDAN---------------> I AM GREY SCALE MODE <-----------------\n"); --- > printk(KERN_ALERT "\n---------------> GREY SCALE MODE <-----------------\n"); 1264a1849 > 1269a1855 > 1279c1865,1866 < for (i = (!parity) + hrtdev->win->starty; i < hrtdev->win->height; i += 2) { --- > for (i = (!parity) + hrtdev->win->starty; i< hrtdev->win->height; i++) { > //for (i = (!parity) + hrtdev->win->starty; i < hrtdev->win->height; i += 2) { 1284a1872,1876 > > printk(KERN_NOTICE "NOT IN CURIOUS GEORGE STYLE\n"); > printk(KERN_NOTICE "linelen = %i\n", linelen); > printk(KERN_NOTICE "i = %i\n", i); > printk(KERN_NOTICE "offset = %i\n", i * linelen); 1314,1325c1906,1907 < iowrite8(val, (void *) (dev->virt_addr + HRT_IRQ_ENABLE)); < } < < /******************************************************************** < ******** timer/tasklet related functions declared here *********** < */ < < void hrt_tasklet(unsigned long); < void hrt_timer_init(hrt_t* dev); < void hrt_timer_cleanup(hrt_t* dev); < int hrt_timer_activate(hrt_t* dev); < void hrt_timer_deactivate(hrt_t* dev); --- > iowrite8(val, (void *) (dev->virt_addr + HRT_IRQ_ENABLE)); > } 1741a2326 > 1771c2355 < dev->video_dev = videodev_template; --- > dev->video_dev = hrt_video_template; 1820c2404 < //video_unregister_device(&dev->video_dev); --- > video_unregister_device(&dev->video_dev); 1834c2418 < //video_unregister_device(&dev->video_dev); --- > video_unregister_device(&dev->video_dev); 1855c2439 < printk(KERN_ALERT "RYAN: Returning from HRT_INIT w 0 \n"); --- > printk(KERN_ALERT "RYAN: Returning from HRT_INIT\n"); 1892c2476 < irqreturn_t hrt_irq_handler(int irq, void* dev_id, struct pt_regs* regs) --- > irqreturn_t hrt_irq_handler(int irq, void* dev_id) 2158c2741 < SA_SHIRQ, "hrt", (void*)dev)) { --- > IRQF_SHARED, "hrt", (void*)dev)) { 2249a2833,2834 > printk(KERN_NOTICE "hrt_timer_deactivate: stopped timer.\n"); > 2253a2839 > printk(KERN_NOTICE "hrt_timer_deactivate: stopped tasklet.\n"); 2255a2842 > printk(KERN_NOTICE "hrt_timer_deactivate: all done\n"); 2565,2567c3152,3153 < /* video device structure required to provide video4linux support */ < struct video_device *vfl = video_devdata(file); < hrt_t *dev = vfl->priv; --- > > hrt_t *dev; 2573a3160 > dev->index = minor; 2630a3218 > if(file->private_data) 2728a3317,3320 > > > hrt_printk( "Wait time: %d of %d\n", (int)(jiffies - starttime), (int)HZ); > 2737a3330,3331 > > starttime = jiffies; 2738a3333 > hrt_printk( "Grab field #1 time: %d of %d\n", (int)(jiffies - starttime), (int)HZ); 2742a3338 > starttime = jiffies; 2743a3340,3342 > > hrt_printk( "Grab field #2 time: %d of %d\n", (int)(jiffies - starttime), (int)HZ); > 2843,3241d3441 < /******************************************************************** < * < * v4l1_ioctls - used for printing out ioctl codes in hrt_do_ioctl < */ < static const char *v4l1_ioctls[] = { < "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", < "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ", < "SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT", < "GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", < "SMICROCODE", "GVBIFMT", "SVBIFMT" < }; < < < /******************************************************************** < * < * hrt_do_ioctl - handles ioctl's on /dev/video < */ < static int hrt_do_ioctl(struct inode *inode, struct file *file, < unsigned int cmd, void *arg) < { < struct hrt_per_file *per_file = file->private_data; < hrt_t *hrtdev = per_file->hrtdev; < hrtdev->win = &per_file->win; < < /* This nice code copied from xawtv's libng. < It prints out the ioctl's that are done. < */ < switch (_IOC_TYPE(cmd)) { < case 'v': < dprintk("ioctl 0x%x (v4l1, VIDIOC%s)\n", < cmd, (_IOC_NR(cmd) < ARRAY_SIZE(v4l1_ioctls)) ? < v4l1_ioctls[_IOC_NR(cmd)] : "???"); < break; < case 'V': < /*dprintk("ioctl 0x%x (v4l2, %s)\n", < cmd, v4l2_ioctl_names[_IOC_NR(cmd)]); */ < break; < default: < dprintk("ioctl 0x%x (?)\n", cmd); < } < < switch (cmd) { < case IOC_HRT_FREEZE_FRAME: < HRT_DEBUG_MSG(2, "IOC_HRT_FREEZE_FRAME: called"); < hrt_freeze_next(hrtdev); < break; < < case IOC_HRT_GO_LIVE: < HRT_DEBUG_MSG(2, "IOC_HRT_GO_LIVE: called"); < hrt_go_live(hrtdev); < break; < case IOC_HRT_UPSIDE_DOWN: < HRT_DEBUG_MSG(2, "IOC_HRT_UPSIDE_DOWN: called"); < if (hrtdev->upside_down) < hrtdev->upside_down = 0; < else < hrtdev->upside_down = 1; < break; < < /* Streaming ioctl's */ < case VIDIOC_REQBUFS: { < struct v4l2_requestbuffers *req = arg; < < if (hrtdev->stream_buffers_mapped) { < hrt_printk("REQBUFS - Can't request buffers if " < " buffers are already mapped\n"); < return -EPERM; < } < if (!mmap_request_buffers(hrtdev, req)) { < hrt_printk("REQBUFS - Request of buffers failed\n"); < return -EINVAL; < } < return 0; < } < case VIDIOC_QUERYBUF: { < struct v4l2_buffer *buf = < (struct v4l2_buffer *) arg; < int i; < i = buf->index; < < < if (i < 0 || i >= MAX_CAPTURE_BUFFERS || < !hrtdev->stream_buf[i].requested || < (buf->type & V4L2_BUF_TYPE_VIDEO_CAPTURE) != < (hrtdev->stream_buf[i].vidbuf.type & V4L2_BUF_TYPE_VIDEO_CAPTURE)) { < hrt_printk("QUERYBUF - bad parameter\n"); < return -EINVAL; < } < < *buf = hrtdev->stream_buf[i].vidbuf; < return 0; < } < case VIDIOC_QBUF: { < struct v4l2_buffer *buf = < (struct v4l2_buffer *) arg; < < if (!hrtdev->stream_buffers_mapped) { < return -EINVAL; < } < < if (!hrt_queuebuffer(hrtdev, buf)) { < return -EINVAL; < } < return 0; < } < case VIDIOC_DQBUF: { < struct v4l2_buffer *buf = < (struct v4l2_buffer *) arg; < < if (!hrt_dequeuebuffer(hrtdev, buf)) { < return -EINVAL; < } < return 0; < } < case VIDIOC_STREAMON: { < __u32 *type = (__u32 *) arg; < if (!hrt_streamon(hrtdev, *type)) < return -EINVAL; < return 0; < } < case VIDIOC_STREAMOFF: { < __u32 *type = (__u32 *) arg; < hrt_streamoff(hrtdev, *type); < return 0; < } < < /* Non-streaming ioctl's */ < case VIDIOC_QUERYCAP: { < struct v4l2_capability *b = < (struct v4l2_capability *) arg; < < strcpy(b->driver, "hrt"); < strncpy(b->card, "PS 512-8-PCI", sizeof(b->card)); < /*sprintf(b->bus_info,"PCI:%s", hrtdev->pci_dev->slot_name);*/ < b->version = KERNEL_VERSION(0, 0, 2); < < if (disable_streaming) { < b->capabilities = < V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; < } else { < < < b->capabilities = < V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | < V4L2_CAP_STREAMING; < } < return 0; < } < case VIDIOC_ENUM_FMT: { < struct v4l2_fmtdesc *f = arg; < enum v4l2_buf_type type = f->type; < int index = f->index; < < /* There's only one format */ < if (index > 0) < return -EINVAL; < < if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { < memset(f, 0, sizeof(*f)); < f->index = index; < f->type = type; < if(hrtdev->mode & HRT_COLOR_MODE){ < f->pixelformat = V4L2_PIX_FMT_RGB555; //check this one < strcpy(f->description, "Color"); < } < else{ < f->pixelformat = V4L2_PIX_FMT_GREY; < strcpy(f->description, "Grey"); < } < < return 0; < } else { < return -EINVAL; < } < } < case VIDIOC_TRY_FMT: < case VIDIOC_S_FMT: < < case VIDIOC_G_FMT: { < struct v4l2_format *f = arg; < < if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { < < /* memset(&f->fmt.pix, 0, < sizeof(struct v4l2_pix_format));*/ < f->fmt.pix.width = hrtdev->win->width; < f->fmt.pix.height = hrtdev->win->height; < < if(hrtdev->mode & HRT_COLOR_MODE) < f->fmt.pix.pixelformat = V4L2_PIX_FMT_RGB555; < else < f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY; < < < //f->fmt.pix.pixelformat = V4L2_FIELD_ANY; < < f->fmt.pix.bytesperline = hrtdev->bytesperline; < f->fmt.pix.sizeimage = hrtdev->framesize; < hrt_printk("pix.width (%d), pic.height (%d)", < f->fmt.pix.width, f->fmt.pix.height); < hrt_printk("pix.bytesperline (%d), pic.sizeimage (%d)", < f->fmt.pix.bytesperline, f->fmt.pix.sizeimage); < return 0; < } else { < return -EINVAL; < } < } < < case VIDIOC_G_CROP: { < struct v4l2_crop * win = arg; < < win->c.height = hrtdev->win->height; < win->c.width = hrtdev->win->width; < win->c.top = hrtdev->win->starty; < win->c.left = hrtdev->win->startx; < < return 0; < } < < case VIDIOC_S_CROP: { < struct v4l2_crop *win = arg; < < hrtdev->win->height = win->c.height; < hrtdev->win->width = win->c.width; < hrtdev->win->starty = win->c.top; < hrtdev->win->startx = win->c.left; < < return 0; < < } < < case VIDIOC_G_STD: { < v4l2_std_id *id = arg; < < *id = V4L2_STD_NTSC; < return 0; < } < case VIDIOC_S_STD: { < /* There's only one standard that we support, NTSC */ < return 0; < } < case VIDIOC_QUERYCTRL: { < struct v4l2_queryctrl *c = arg; < int i; < < for (i = 0; i < ARRAY_SIZE(hrt_ctls); i++) < if (hrt_ctls[i].id == c->id) < break; < < /* Didn't find the id */ < if (i == ARRAY_SIZE(hrt_ctls)) { < return -EINVAL; < } < < *c = hrt_ctls[i]; < return 0; < } < case VIDIOC_G_CTRL: { < struct v4l2_control *c = arg; < int i; < < for (i = 0; i < ARRAY_SIZE(hrt_ctls); i++) < if (hrt_ctls[i].id == c->id) < break; < < if (i == sizeof(hrt_ctls)) < return -EINVAL; < < if (c->id == V4L2_CID_BRIGHTNESS) { < /* < c->value = hrtdev->regvals[HRT_BRIGHTNESS_REG]; < */ < c->value = hrtdev->saa7110_registers[HRT_BRIGHTNESS_REG]; < } else if (c->id == V4L2_CID_CONTRAST) { < /* < c->value = hrtdev->regvals[HRT_CONTRAST_REG]; < */ < c->value = hrtdev->saa7110_registers[HRT_BRIGHTNESS_REG]; < < } else { < return -EINVAL; < } < < return 0; < } < case VIDIOC_S_CTRL: { < /* < struct v4l2_control *c = arg; < int i; < < for (i = 0; i < sizeof(hrt_ctls); i++) < if (hrt_ctls[i].id == c->id) < break; < if (i == sizeof(hrt_ctls)) < return -EINVAL; < < if (c->id == V4L2_CID_BRIGHTNESS) { < if (c->value > 255) < return -EINVAL; < c->value = i2c_set_reg(hrtdev, HRT_BRIGHTNESS_REG, < c->value); < } else if (c->id == V4L2_CID_CONTRAST) { < if (c->value > 255) < return -EINVAL; < c->value = i2c_set_reg(hrtdev, HRT_CONTRAST_REG, < c->value); < } else { < return -EINVAL; < } < */ < return 0; < } < case VIDIOC_ENUMINPUT: { < struct v4l2_input *i = arg; < unsigned int n; < < /* Only one input */ < if (i->index > 0) < return -EINVAL; < < n = i->index; < memset(i, 0, sizeof(*i)); < i->index = n; < i->type = V4L2_INPUT_TYPE_CAMERA; < sprintf(i->name, "NTSC Camera"); < < return 0; < } < case VIDIOC_ENUMSTD: { < struct v4l2_standard *e = arg; < struct v4l2_fract fract = { 1001, 30000 }; < unsigned int index = e->index; < < /* One standard (NTSC) */ < if (index > 0) < return -EINVAL; < < e->id = V4L2_STD_NTSC_M; < e->index = index; < strcpy(e->name, "NTSC"); < e->frameperiod = fract; < e->framelines = hrtdev->win->height; < < return 0; < } < case VIDIOC_G_PARM: { < struct v4l2_streamparm *parm = arg; < struct v4l2_standard s; < < if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) < return -EINVAL; < memset(parm, 0, sizeof(*parm)); < < v4l2_video_std_construct(&s, V4L2_STD_NTSC, < "NTSC"); < parm->parm.capture.timeperframe = s.frameperiod; < return 0; < } < case VIDIOC_G_INPUT: { < return 0; < } < case VIDIOC_S_INPUT: { < return 0; < } < default: < return -ENOIOCTLCMD; < } < < return 0; < } < < /******************************************************************** < * hrt_ioctl < * < * handler for ioctl's on /dev/video. Tries the private < * ioctl's first, via hrt_do_private_ioctl(). < */ < int hrt_ioctl(struct inode *inode, struct file *file, < unsigned int cmd, unsigned long arg) < { < struct hrt_per_file *per_file = file->private_data; < hrt_t *hrtdev = per_file->hrtdev; < int ret; < hrtdev->win = &per_file->win; < < dprintk("ioctl arg = %lx\n", arg); < < down(&hrtdev->sem); < < ret = hrt_do_private_ioctl(hrtdev, cmd, arg); < if (ret != -EINVAL) { < up(&hrtdev->sem); < return ret; < } < ret = video_usercopy(inode, file, cmd, arg, hrt_do_ioctl); < up(&hrtdev->sem); < return ret; < } < 3316c3516 < void hrt_pci_init(void) --- > int hrt_pci_init(void) 3319c3519 < pci_register_driver(&hrt_pci_driver); --- > return pci_register_driver(&hrt_pci_driver); 3610a3811 > 3614a3816,3817 > hrt_printk("PAGE_SIZE: (%d)\n", (int)PAGE_SIZE); > hrt_printk("FRAMESIZE: (%d)\n", dev->framesize);