stk-webcam.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * stk-webcam.h : Driver for Syntek 1125 USB webcam controller
  3. *
  4. * Copyright (C) 2006 Nicolas VIVIEN
  5. * Copyright 2007-2008 Jaime Velasco Juan <jsagarribay@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #ifndef STKWEBCAM_H
  18. #define STKWEBCAM_H
  19. #include <linux/usb.h>
  20. #include <media/v4l2-device.h>
  21. #include <media/v4l2-ctrls.h>
  22. #include <media/v4l2-common.h>
  23. #define DRIVER_VERSION "v0.0.1"
  24. #define DRIVER_VERSION_NUM 0x000001
  25. #define MAX_ISO_BUFS 3
  26. #define ISO_FRAMES_PER_DESC 16
  27. #define ISO_MAX_FRAME_SIZE 3 * 1024
  28. #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
  29. struct stk_iso_buf {
  30. void *data;
  31. int length;
  32. int read;
  33. struct urb *urb;
  34. };
  35. /* Streaming IO buffers */
  36. struct stk_sio_buffer {
  37. struct v4l2_buffer v4lbuf;
  38. char *buffer;
  39. int mapcount;
  40. struct stk_camera *dev;
  41. struct list_head list;
  42. };
  43. enum stk_mode {MODE_VGA, MODE_SXGA, MODE_CIF, MODE_QVGA, MODE_QCIF};
  44. struct stk_video {
  45. enum stk_mode mode;
  46. __u32 palette;
  47. int hflip;
  48. int vflip;
  49. };
  50. enum stk_status {
  51. S_PRESENT = 1,
  52. S_INITIALISED = 2,
  53. S_MEMALLOCD = 4,
  54. S_STREAMING = 8,
  55. };
  56. #define is_present(dev) ((dev)->status & S_PRESENT)
  57. #define is_initialised(dev) ((dev)->status & S_INITIALISED)
  58. #define is_streaming(dev) ((dev)->status & S_STREAMING)
  59. #define is_memallocd(dev) ((dev)->status & S_MEMALLOCD)
  60. #define set_present(dev) ((dev)->status = S_PRESENT)
  61. #define unset_present(dev) ((dev)->status &= \
  62. ~(S_PRESENT|S_INITIALISED|S_STREAMING))
  63. #define set_initialised(dev) ((dev)->status |= S_INITIALISED)
  64. #define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED)
  65. #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD)
  66. #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD)
  67. #define set_streaming(dev) ((dev)->status |= S_STREAMING)
  68. #define unset_streaming(dev) ((dev)->status &= ~S_STREAMING)
  69. struct regval {
  70. unsigned reg;
  71. unsigned val;
  72. };
  73. struct stk_camera {
  74. struct v4l2_device v4l2_dev;
  75. struct v4l2_ctrl_handler hdl;
  76. struct video_device vdev;
  77. struct usb_device *udev;
  78. struct usb_interface *interface;
  79. int webcam_model;
  80. struct file *owner;
  81. struct mutex lock;
  82. int first_init;
  83. u8 isoc_ep;
  84. /* Not sure if this is right */
  85. atomic_t urbs_used;
  86. struct stk_video vsettings;
  87. enum stk_status status;
  88. spinlock_t spinlock;
  89. wait_queue_head_t wait_frame;
  90. struct stk_iso_buf *isobufs;
  91. int frame_size;
  92. /* Streaming buffers */
  93. int reading;
  94. unsigned int n_sbufs;
  95. struct stk_sio_buffer *sio_bufs;
  96. struct list_head sio_avail;
  97. struct list_head sio_full;
  98. unsigned sequence;
  99. };
  100. #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
  101. int stk_camera_write_reg(struct stk_camera *, u16, u8);
  102. int stk_camera_read_reg(struct stk_camera *, u16, u8 *);
  103. int stk_sensor_init(struct stk_camera *);
  104. int stk_sensor_configure(struct stk_camera *);
  105. int stk_sensor_sleep(struct stk_camera *dev);
  106. int stk_sensor_wakeup(struct stk_camera *dev);
  107. int stk_sensor_set_brightness(struct stk_camera *dev, int br);
  108. #endif