r5u870

Ricoh R5U870 Linux Driver
git clone https://logand.com/git/r5u870.git/
Log | Files | Refs | README | LICENSE

usbcam_skel.c (3240B)


      1 /*
      2  * USBCAM abstraction library for USB webcam drivers
      3  *
      4  * Copyright (c) 2007 Sam Revitch <samr7 cs washington edu>
      5  *
      6  * This driver is free software; you can redistribute it and/or modify
      7  * it under the terms of the GNU General Public License as published by
      8  * the Free Software Foundation; either version 2 of the License, or
      9  * (at your option) any later version.
     10  *
     11  * This driver is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     14  * GNU General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU General Public License
     17  * along with this driver; if not, write to the Free Software
     18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
     19  */
     20 
     21 /*
     22  * This is a usbcam skeleton driver intended to be a starting point for
     23  * minidriver development.
     24  */
     25 
     26 #define USBCAM_DEBUG_DEFAULT 0xffff
     27 
     28 #include <linux/kernel.h>
     29 #include <linux/module.h>
     30 #include <linux/init.h>
     31 #include <linux/usb.h>
     32 #include "usbcam.h"
     33 
     34 
     35 #define USBCAM_DBG_SKEL_INIT	(USBCAM_DBGBIT_MD_START + 0)
     36 #define USBCAM_DBG_SKEL_FRAME	(USBCAM_DBGBIT_MD_START + 1)
     37 #define USBCAM_DBG_SKEL_MDINTF	(USBCAM_DBGBIT_MD_START + 2)
     38 #define USBCAM_DBG_SKEL_CTRL	(USBCAM_DBGBIT_MD_START + 3)
     39 
     40 
     41 #define skel_info(RV, FMT...) usbcam_info((RV)->cs_parent, FMT)
     42 #define skel_err(RV, FMT...) usbcam_err((RV)->cs_parent, FMT)
     43 #define skel_dbg(RV, SUBSYS, FMT...) usbcam_dbg((RV)->cs_parent, SUBSYS, FMT)
     44 
     45 #define SKEL_VERSION KERNEL_VERSION(1,0,0)
     46 #define SKEL_VERSION_EXTRA ""
     47 
     48 
     49 /*
     50  * struct skel_dev is the per-device private structure for this
     51  * minidriver.  We store all the details of the current state of the
     52  * camera in here, other than those explicitly shared with usbcam.
     53  */
     54 struct skel_dev {
     55 	struct usbcam_dev *cs_parent;
     56 };
     57 
     58 #define udp_skel(UDP) ((struct skel_dev *)((UDP)->ud_minidrv_data))
     59 
     60 static int skel_usbcam_init(struct usbcam_dev *udp,
     61 			    const struct usb_device_id *devid)
     62 {
     63 	struct skel_dev *cdp = 	udp_skel(udp);
     64 	cdp->cs_parent = udp;
     65 
     66 	/* Probe/initialize the device */
     67 
     68 	return 0;
     69 }
     70 
     71 static void skel_usbcam_disconnect(struct usbcam_dev *udp)
     72 {
     73 }
     74 
     75 static int skel_usbcam_try_format(struct usbcam_dev *udp,
     76 				  struct v4l2_pix_format *f)
     77 {
     78 	return -EINVAL;
     79 }
     80 
     81 static int skel_usbcam_set_format(struct usbcam_dev *udp,
     82 				  struct v4l2_pix_format *f)
     83 {
     84 	return -EINVAL;
     85 }
     86 
     87 static int skel_usbcam_cap_start(struct usbcam_dev *udp)
     88 {
     89 	return -EINVAL;
     90 }
     91 
     92 static void skel_usbcam_cap_stop(struct usbcam_dev *udp)
     93 {
     94 }
     95 
     96 
     97 static struct usbcam_dev_ops skel_usbcam_dev_ops = {
     98 	.init		= skel_usbcam_init,
     99 	.disconnect	= skel_usbcam_disconnect,
    100 	.try_format	= skel_usbcam_try_format,
    101 	.set_format	= skel_usbcam_set_format,
    102 	.cap_start	= skel_usbcam_cap_start,
    103 	.cap_stop	= skel_usbcam_cap_stop,
    104 };
    105 
    106 static const struct usb_device_id id_table[] = {
    107 	{ USB_DEVICE(0xfff0, 0xfff0), .driver_info = 0 },
    108 	{ }
    109 };
    110 
    111 DEFINE_USBCAM_MINIDRV_MODULE(SKEL_VERSION,
    112 			     SKEL_VERSION_EXTRA,
    113 			     &skel_usbcam_dev_ops,
    114 			     sizeof(struct skel_dev),
    115 			     id_table)
    116 
    117 MODULE_DESCRIPTION("Driver for Skeleton Webcam");
    118 MODULE_AUTHOR("You <you yourdomain com>");
    119 MODULE_LICENSE("GPL");