diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2011-02-03 06:42:51 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-04 15:44:34 -0500 |
commit | 7dcef374d17fd20ecd96b1aeccafe8a4a8c15740 (patch) | |
tree | 44fb9f242e40c0655ae0e43a13e6cae9fe86f9aa /drivers | |
parent | 30a2cb350fcc34f36f86ecf4a5505f02e6810727 (diff) |
staging/easycap: add level 1 tabs in usb_probe/disconnect function
Add first level indentation before revamping the functions
This of course breaks 80 characters limit but it will be
fixed through the revamp
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/easycap/easycap_main.c | 2318 |
1 files changed, 1159 insertions, 1159 deletions
diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index 58cfa409e91..396f56b1e41 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c | |||
@@ -3145,139 +3145,139 @@ static const struct v4l2_file_operations v4l2_fops = { | |||
3145 | static int easycap_usb_probe(struct usb_interface *pusb_interface, | 3145 | static int easycap_usb_probe(struct usb_interface *pusb_interface, |
3146 | const struct usb_device_id *pusb_device_id) | 3146 | const struct usb_device_id *pusb_device_id) |
3147 | { | 3147 | { |
3148 | struct usb_device *pusb_device, *pusb_device1; | 3148 | struct usb_device *pusb_device, *pusb_device1; |
3149 | struct usb_host_interface *pusb_host_interface; | 3149 | struct usb_host_interface *pusb_host_interface; |
3150 | struct usb_endpoint_descriptor *pepd; | 3150 | struct usb_endpoint_descriptor *pepd; |
3151 | struct usb_interface_descriptor *pusb_interface_descriptor; | 3151 | struct usb_interface_descriptor *pusb_interface_descriptor; |
3152 | struct usb_interface_assoc_descriptor *pusb_interface_assoc_descriptor; | 3152 | struct usb_interface_assoc_descriptor *pusb_interface_assoc_descriptor; |
3153 | struct urb *purb; | 3153 | struct urb *purb; |
3154 | struct easycap *peasycap; | 3154 | struct easycap *peasycap; |
3155 | int ndong; | 3155 | int ndong; |
3156 | struct data_urb *pdata_urb; | 3156 | struct data_urb *pdata_urb; |
3157 | size_t wMaxPacketSize; | 3157 | size_t wMaxPacketSize; |
3158 | int ISOCwMaxPacketSize; | 3158 | int ISOCwMaxPacketSize; |
3159 | int BULKwMaxPacketSize; | 3159 | int BULKwMaxPacketSize; |
3160 | int INTwMaxPacketSize; | 3160 | int INTwMaxPacketSize; |
3161 | int CTRLwMaxPacketSize; | 3161 | int CTRLwMaxPacketSize; |
3162 | u8 bEndpointAddress; | 3162 | u8 bEndpointAddress; |
3163 | u8 ISOCbEndpointAddress; | 3163 | u8 ISOCbEndpointAddress; |
3164 | u8 INTbEndpointAddress; | 3164 | u8 INTbEndpointAddress; |
3165 | int isin, i, j, k, m, rc; | 3165 | int isin, i, j, k, m, rc; |
3166 | u8 bInterfaceNumber; | 3166 | u8 bInterfaceNumber; |
3167 | u8 bInterfaceClass; | 3167 | u8 bInterfaceClass; |
3168 | u8 bInterfaceSubClass; | 3168 | u8 bInterfaceSubClass; |
3169 | void *pbuf; | 3169 | void *pbuf; |
3170 | int okalt[8], isokalt; | 3170 | int okalt[8], isokalt; |
3171 | int okepn[8]; | 3171 | int okepn[8]; |
3172 | int okmps[8]; | 3172 | int okmps[8]; |
3173 | int maxpacketsize; | 3173 | int maxpacketsize; |
3174 | u16 mask; | 3174 | u16 mask; |
3175 | s32 value; | 3175 | s32 value; |
3176 | struct easycap_format *peasycap_format; | 3176 | struct easycap_format *peasycap_format; |
3177 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | 3177 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ |
3178 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT | 3178 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT |
3179 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H | 3179 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H |
3180 | struct v4l2_device *pv4l2_device; | 3180 | struct v4l2_device *pv4l2_device; |
3181 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ | 3181 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ |
3182 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ | 3182 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ |
3183 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | 3183 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
3184 | 3184 | ||
3185 | /* setup modules params */ | 3185 | /* setup modules params */ |
3186 | 3186 | ||
3187 | if (NULL == pusb_interface) { | 3187 | if (NULL == pusb_interface) { |
3188 | SAY("ERROR: pusb_interface is NULL\n"); | 3188 | SAY("ERROR: pusb_interface is NULL\n"); |
3189 | return -EFAULT; | 3189 | return -EFAULT; |
3190 | } | 3190 | } |
3191 | /*---------------------------------------------------------------------------*/ | 3191 | /*---------------------------------------------------------------------------*/ |
3192 | /* | 3192 | /* |
3193 | * GET POINTER TO STRUCTURE usb_device | 3193 | * GET POINTER TO STRUCTURE usb_device |
3194 | */ | 3194 | */ |
3195 | /*---------------------------------------------------------------------------*/ | 3195 | /*---------------------------------------------------------------------------*/ |
3196 | pusb_device1 = container_of(pusb_interface->dev.parent, | 3196 | pusb_device1 = container_of(pusb_interface->dev.parent, |
3197 | struct usb_device, dev); | 3197 | struct usb_device, dev); |
3198 | if (NULL == pusb_device1) { | 3198 | if (NULL == pusb_device1) { |
3199 | SAY("ERROR: pusb_device1 is NULL\n"); | 3199 | SAY("ERROR: pusb_device1 is NULL\n"); |
3200 | return -EFAULT; | 3200 | return -EFAULT; |
3201 | } | 3201 | } |
3202 | pusb_device = usb_get_dev(pusb_device1); | 3202 | pusb_device = usb_get_dev(pusb_device1); |
3203 | if (NULL == pusb_device) { | 3203 | if (NULL == pusb_device) { |
3204 | SAY("ERROR: pusb_device is NULL\n"); | 3204 | SAY("ERROR: pusb_device is NULL\n"); |
3205 | return -EFAULT; | 3205 | return -EFAULT; |
3206 | } | 3206 | } |
3207 | if ((unsigned long int)pusb_device1 != (unsigned long int)pusb_device) { | 3207 | if ((unsigned long int)pusb_device1 != (unsigned long int)pusb_device) { |
3208 | JOT(4, "ERROR: pusb_device1 != pusb_device\n"); | 3208 | JOT(4, "ERROR: pusb_device1 != pusb_device\n"); |
3209 | return -EFAULT; | 3209 | return -EFAULT; |
3210 | } | 3210 | } |
3211 | JOT(4, "bNumConfigurations=%i\n", pusb_device->descriptor.bNumConfigurations); | 3211 | JOT(4, "bNumConfigurations=%i\n", pusb_device->descriptor.bNumConfigurations); |
3212 | /*---------------------------------------------------------------------------*/ | 3212 | /*---------------------------------------------------------------------------*/ |
3213 | pusb_host_interface = pusb_interface->cur_altsetting; | 3213 | pusb_host_interface = pusb_interface->cur_altsetting; |
3214 | if (NULL == pusb_host_interface) { | 3214 | if (NULL == pusb_host_interface) { |
3215 | SAY("ERROR: pusb_host_interface is NULL\n"); | 3215 | SAY("ERROR: pusb_host_interface is NULL\n"); |
3216 | return -EFAULT; | 3216 | return -EFAULT; |
3217 | } | 3217 | } |
3218 | pusb_interface_descriptor = &(pusb_host_interface->desc); | 3218 | pusb_interface_descriptor = &(pusb_host_interface->desc); |
3219 | if (NULL == pusb_interface_descriptor) { | 3219 | if (NULL == pusb_interface_descriptor) { |
3220 | SAY("ERROR: pusb_interface_descriptor is NULL\n"); | 3220 | SAY("ERROR: pusb_interface_descriptor is NULL\n"); |
3221 | return -EFAULT; | 3221 | return -EFAULT; |
3222 | } | 3222 | } |
3223 | /*---------------------------------------------------------------------------*/ | 3223 | /*---------------------------------------------------------------------------*/ |
3224 | /* | 3224 | /* |
3225 | * GET PROPERTIES OF PROBED INTERFACE | 3225 | * GET PROPERTIES OF PROBED INTERFACE |
3226 | */ | 3226 | */ |
3227 | /*---------------------------------------------------------------------------*/ | 3227 | /*---------------------------------------------------------------------------*/ |
3228 | bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; | 3228 | bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; |
3229 | bInterfaceClass = pusb_interface_descriptor->bInterfaceClass; | 3229 | bInterfaceClass = pusb_interface_descriptor->bInterfaceClass; |
3230 | bInterfaceSubClass = pusb_interface_descriptor->bInterfaceSubClass; | 3230 | bInterfaceSubClass = pusb_interface_descriptor->bInterfaceSubClass; |
3231 | 3231 | ||
3232 | JOT(4, "intf[%i]: pusb_interface->num_altsetting=%i\n", | 3232 | JOT(4, "intf[%i]: pusb_interface->num_altsetting=%i\n", |
3233 | bInterfaceNumber, pusb_interface->num_altsetting); | 3233 | bInterfaceNumber, pusb_interface->num_altsetting); |
3234 | JOT(4, "intf[%i]: pusb_interface->cur_altsetting - " | 3234 | JOT(4, "intf[%i]: pusb_interface->cur_altsetting - " |
3235 | "pusb_interface->altsetting=%li\n", bInterfaceNumber, | 3235 | "pusb_interface->altsetting=%li\n", bInterfaceNumber, |
3236 | (long int)(pusb_interface->cur_altsetting - | 3236 | (long int)(pusb_interface->cur_altsetting - |
3237 | pusb_interface->altsetting)); | 3237 | pusb_interface->altsetting)); |
3238 | switch (bInterfaceClass) { | 3238 | switch (bInterfaceClass) { |
3239 | case USB_CLASS_AUDIO: { | 3239 | case USB_CLASS_AUDIO: { |
3240 | JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_AUDIO\n", | 3240 | JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_AUDIO\n", |
3241 | bInterfaceNumber, bInterfaceClass); break; | 3241 | bInterfaceNumber, bInterfaceClass); break; |
3242 | } | ||
3243 | case USB_CLASS_VIDEO: { | ||
3244 | JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_VIDEO\n", | ||
3245 | bInterfaceNumber, bInterfaceClass); break; | ||
3246 | } | ||
3247 | case USB_CLASS_VENDOR_SPEC: { | ||
3248 | JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_VENDOR_SPEC\n", | ||
3249 | bInterfaceNumber, bInterfaceClass); break; | ||
3250 | } | ||
3251 | default: | ||
3252 | break; | ||
3242 | } | 3253 | } |
3243 | case USB_CLASS_VIDEO: { | 3254 | switch (bInterfaceSubClass) { |
3244 | JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_VIDEO\n", | 3255 | case 0x01: { |
3245 | bInterfaceNumber, bInterfaceClass); break; | 3256 | JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=AUDIOCONTROL\n", |
3257 | bInterfaceNumber, bInterfaceSubClass); break; | ||
3246 | } | 3258 | } |
3247 | case USB_CLASS_VENDOR_SPEC: { | 3259 | case 0x02: { |
3248 | JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_VENDOR_SPEC\n", | 3260 | JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=AUDIOSTREAMING\n", |
3249 | bInterfaceNumber, bInterfaceClass); break; | 3261 | bInterfaceNumber, bInterfaceSubClass); break; |
3262 | } | ||
3263 | case 0x03: { | ||
3264 | JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=MIDISTREAMING\n", | ||
3265 | bInterfaceNumber, bInterfaceSubClass); break; | ||
3266 | } | ||
3267 | default: | ||
3268 | break; | ||
3250 | } | 3269 | } |
3251 | default: | ||
3252 | break; | ||
3253 | } | ||
3254 | switch (bInterfaceSubClass) { | ||
3255 | case 0x01: { | ||
3256 | JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=AUDIOCONTROL\n", | ||
3257 | bInterfaceNumber, bInterfaceSubClass); break; | ||
3258 | } | ||
3259 | case 0x02: { | ||
3260 | JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=AUDIOSTREAMING\n", | ||
3261 | bInterfaceNumber, bInterfaceSubClass); break; | ||
3262 | } | ||
3263 | case 0x03: { | ||
3264 | JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=MIDISTREAMING\n", | ||
3265 | bInterfaceNumber, bInterfaceSubClass); break; | ||
3266 | } | ||
3267 | default: | ||
3268 | break; | ||
3269 | } | ||
3270 | /*---------------------------------------------------------------------------*/ | 3270 | /*---------------------------------------------------------------------------*/ |
3271 | pusb_interface_assoc_descriptor = pusb_interface->intf_assoc; | 3271 | pusb_interface_assoc_descriptor = pusb_interface->intf_assoc; |
3272 | if (NULL != pusb_interface_assoc_descriptor) { | 3272 | if (NULL != pusb_interface_assoc_descriptor) { |
3273 | JOT(4, "intf[%i]: bFirstInterface=0x%02X bInterfaceCount=0x%02X\n", | 3273 | JOT(4, "intf[%i]: bFirstInterface=0x%02X bInterfaceCount=0x%02X\n", |
3274 | bInterfaceNumber, | 3274 | bInterfaceNumber, |
3275 | pusb_interface_assoc_descriptor->bFirstInterface, | 3275 | pusb_interface_assoc_descriptor->bFirstInterface, |
3276 | pusb_interface_assoc_descriptor->bInterfaceCount); | 3276 | pusb_interface_assoc_descriptor->bInterfaceCount); |
3277 | } else { | 3277 | } else { |
3278 | JOT(4, "intf[%i]: pusb_interface_assoc_descriptor is NULL\n", | 3278 | JOT(4, "intf[%i]: pusb_interface_assoc_descriptor is NULL\n", |
3279 | bInterfaceNumber); | 3279 | bInterfaceNumber); |
3280 | } | 3280 | } |
3281 | /*---------------------------------------------------------------------------*/ | 3281 | /*---------------------------------------------------------------------------*/ |
3282 | /* | 3282 | /* |
3283 | * A NEW struct easycap IS ALWAYS ALLOCATED WHEN INTERFACE 0 IS PROBED. | 3283 | * A NEW struct easycap IS ALWAYS ALLOCATED WHEN INTERFACE 0 IS PROBED. |
@@ -3289,19 +3289,19 @@ JOT(4, "intf[%i]: pusb_interface_assoc_descriptor is NULL\n", | |||
3289 | * INTERFACES 1 AND 2 ARE PROBED. | 3289 | * INTERFACES 1 AND 2 ARE PROBED. |
3290 | */ | 3290 | */ |
3291 | /*---------------------------------------------------------------------------*/ | 3291 | /*---------------------------------------------------------------------------*/ |
3292 | if (0 == bInterfaceNumber) { | 3292 | if (0 == bInterfaceNumber) { |
3293 | peasycap = kzalloc(sizeof(struct easycap), GFP_KERNEL); | 3293 | peasycap = kzalloc(sizeof(struct easycap), GFP_KERNEL); |
3294 | if (NULL == peasycap) { | 3294 | if (NULL == peasycap) { |
3295 | SAY("ERROR: Could not allocate peasycap\n"); | 3295 | SAY("ERROR: Could not allocate peasycap\n"); |
3296 | return -ENOMEM; | 3296 | return -ENOMEM; |
3297 | } | 3297 | } |
3298 | SAM("allocated 0x%08lX=peasycap\n", (unsigned long int) peasycap); | 3298 | SAM("allocated 0x%08lX=peasycap\n", (unsigned long int) peasycap); |
3299 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | 3299 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ |
3300 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT | 3300 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT |
3301 | SAM("where 0x%08lX=&peasycap->video_device\n", | 3301 | SAM("where 0x%08lX=&peasycap->video_device\n", |
3302 | (unsigned long int) &peasycap->video_device); | 3302 | (unsigned long int) &peasycap->video_device); |
3303 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H | 3303 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H |
3304 | SAM("and 0x%08lX=&peasycap->v4l2_device\n", | 3304 | SAM("and 0x%08lX=&peasycap->v4l2_device\n", |
3305 | (unsigned long int) &peasycap->v4l2_device); | 3305 | (unsigned long int) &peasycap->v4l2_device); |
3306 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ | 3306 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ |
3307 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ | 3307 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ |
@@ -3311,24 +3311,24 @@ if (0 == bInterfaceNumber) { | |||
3311 | * PERFORM URGENT INTIALIZATIONS ... | 3311 | * PERFORM URGENT INTIALIZATIONS ... |
3312 | */ | 3312 | */ |
3313 | /*---------------------------------------------------------------------------*/ | 3313 | /*---------------------------------------------------------------------------*/ |
3314 | peasycap->minor = -1; | 3314 | peasycap->minor = -1; |
3315 | strcpy(&peasycap->telltale[0], TELLTALE); | 3315 | strcpy(&peasycap->telltale[0], TELLTALE); |
3316 | kref_init(&peasycap->kref); | 3316 | kref_init(&peasycap->kref); |
3317 | JOM(8, "intf[%i]: after kref_init(..._video) " | 3317 | JOM(8, "intf[%i]: after kref_init(..._video) " |
3318 | "%i=peasycap->kref.refcount.counter\n", | 3318 | "%i=peasycap->kref.refcount.counter\n", |
3319 | bInterfaceNumber, peasycap->kref.refcount.counter); | 3319 | bInterfaceNumber, peasycap->kref.refcount.counter); |
3320 | 3320 | ||
3321 | /* module params */ | 3321 | /* module params */ |
3322 | peasycap->gain = (s8)clamp(easycap_gain, 0, 31); | 3322 | peasycap->gain = (s8)clamp(easycap_gain, 0, 31); |
3323 | 3323 | ||
3324 | init_waitqueue_head(&peasycap->wq_video); | 3324 | init_waitqueue_head(&peasycap->wq_video); |
3325 | init_waitqueue_head(&peasycap->wq_audio); | 3325 | init_waitqueue_head(&peasycap->wq_audio); |
3326 | init_waitqueue_head(&peasycap->wq_trigger); | 3326 | init_waitqueue_head(&peasycap->wq_trigger); |
3327 | 3327 | ||
3328 | if (mutex_lock_interruptible(&mutex_dongle)) { | 3328 | if (mutex_lock_interruptible(&mutex_dongle)) { |
3329 | SAY("ERROR: cannot down mutex_dongle\n"); | 3329 | SAY("ERROR: cannot down mutex_dongle\n"); |
3330 | return -ERESTARTSYS; | 3330 | return -ERESTARTSYS; |
3331 | } else { | 3331 | } else { |
3332 | /*---------------------------------------------------------------------------*/ | 3332 | /*---------------------------------------------------------------------------*/ |
3333 | /* | 3333 | /* |
3334 | * FOR INTERFACES 1 AND 2 THE POINTER peasycap WILL NEED TO | 3334 | * FOR INTERFACES 1 AND 2 THE POINTER peasycap WILL NEED TO |
@@ -3339,193 +3339,193 @@ if (0 == bInterfaceNumber) { | |||
3339 | * EASYCAPs ARE PLUGGED IN SIMULTANEOUSLY. | 3339 | * EASYCAPs ARE PLUGGED IN SIMULTANEOUSLY. |
3340 | */ | 3340 | */ |
3341 | /*---------------------------------------------------------------------------*/ | 3341 | /*---------------------------------------------------------------------------*/ |
3342 | for (ndong = 0; ndong < DONGLE_MANY; ndong++) { | 3342 | for (ndong = 0; ndong < DONGLE_MANY; ndong++) { |
3343 | if ((NULL == easycapdc60_dongle[ndong].peasycap) && | 3343 | if ((NULL == easycapdc60_dongle[ndong].peasycap) && |
3344 | (!mutex_is_locked(&easycapdc60_dongle | 3344 | (!mutex_is_locked(&easycapdc60_dongle |
3345 | [ndong].mutex_video)) && | 3345 | [ndong].mutex_video)) && |
3346 | (!mutex_is_locked(&easycapdc60_dongle | 3346 | (!mutex_is_locked(&easycapdc60_dongle |
3347 | [ndong].mutex_audio))) { | 3347 | [ndong].mutex_audio))) { |
3348 | easycapdc60_dongle[ndong].peasycap = peasycap; | 3348 | easycapdc60_dongle[ndong].peasycap = peasycap; |
3349 | peasycap->isdongle = ndong; | 3349 | peasycap->isdongle = ndong; |
3350 | JOM(8, "intf[%i]: peasycap-->easycap" | 3350 | JOM(8, "intf[%i]: peasycap-->easycap" |
3351 | "_dongle[%i].peasycap\n", | 3351 | "_dongle[%i].peasycap\n", |
3352 | bInterfaceNumber, ndong); | 3352 | bInterfaceNumber, ndong); |
3353 | break; | 3353 | break; |
3354 | } | ||
3355 | } | ||
3356 | if (DONGLE_MANY <= ndong) { | ||
3357 | SAM("ERROR: too many dongles\n"); | ||
3358 | mutex_unlock(&mutex_dongle); | ||
3359 | return -ENOMEM; | ||
3354 | } | 3360 | } |
3355 | } | ||
3356 | if (DONGLE_MANY <= ndong) { | ||
3357 | SAM("ERROR: too many dongles\n"); | ||
3358 | mutex_unlock(&mutex_dongle); | 3361 | mutex_unlock(&mutex_dongle); |
3359 | return -ENOMEM; | ||
3360 | } | 3362 | } |
3361 | mutex_unlock(&mutex_dongle); | 3363 | peasycap->allocation_video_struct = sizeof(struct easycap); |
3362 | } | 3364 | peasycap->allocation_video_page = 0; |
3363 | peasycap->allocation_video_struct = sizeof(struct easycap); | 3365 | peasycap->allocation_video_urb = 0; |
3364 | peasycap->allocation_video_page = 0; | 3366 | peasycap->allocation_audio_struct = 0; |
3365 | peasycap->allocation_video_urb = 0; | 3367 | peasycap->allocation_audio_page = 0; |
3366 | peasycap->allocation_audio_struct = 0; | 3368 | peasycap->allocation_audio_urb = 0; |
3367 | peasycap->allocation_audio_page = 0; | ||
3368 | peasycap->allocation_audio_urb = 0; | ||
3369 | 3369 | ||
3370 | /*---------------------------------------------------------------------------*/ | 3370 | /*---------------------------------------------------------------------------*/ |
3371 | /* | 3371 | /* |
3372 | * ... AND FURTHER INITIALIZE THE STRUCTURE | 3372 | * ... AND FURTHER INITIALIZE THE STRUCTURE |
3373 | */ | 3373 | */ |
3374 | /*---------------------------------------------------------------------------*/ | 3374 | /*---------------------------------------------------------------------------*/ |
3375 | peasycap->pusb_device = pusb_device; | 3375 | peasycap->pusb_device = pusb_device; |
3376 | peasycap->pusb_interface = pusb_interface; | 3376 | peasycap->pusb_interface = pusb_interface; |
3377 | 3377 | ||
3378 | peasycap->ilk = 0; | 3378 | peasycap->ilk = 0; |
3379 | peasycap->microphone = false; | 3379 | peasycap->microphone = false; |
3380 | 3380 | ||
3381 | peasycap->video_interface = -1; | 3381 | peasycap->video_interface = -1; |
3382 | peasycap->video_altsetting_on = -1; | 3382 | peasycap->video_altsetting_on = -1; |
3383 | peasycap->video_altsetting_off = -1; | 3383 | peasycap->video_altsetting_off = -1; |
3384 | peasycap->video_endpointnumber = -1; | 3384 | peasycap->video_endpointnumber = -1; |
3385 | peasycap->video_isoc_maxframesize = -1; | 3385 | peasycap->video_isoc_maxframesize = -1; |
3386 | peasycap->video_isoc_buffer_size = -1; | 3386 | peasycap->video_isoc_buffer_size = -1; |
3387 | 3387 | ||
3388 | peasycap->audio_interface = -1; | 3388 | peasycap->audio_interface = -1; |
3389 | peasycap->audio_altsetting_on = -1; | 3389 | peasycap->audio_altsetting_on = -1; |
3390 | peasycap->audio_altsetting_off = -1; | 3390 | peasycap->audio_altsetting_off = -1; |
3391 | peasycap->audio_endpointnumber = -1; | 3391 | peasycap->audio_endpointnumber = -1; |
3392 | peasycap->audio_isoc_maxframesize = -1; | 3392 | peasycap->audio_isoc_maxframesize = -1; |
3393 | peasycap->audio_isoc_buffer_size = -1; | 3393 | peasycap->audio_isoc_buffer_size = -1; |
3394 | 3394 | ||
3395 | peasycap->frame_buffer_many = FRAME_BUFFER_MANY; | 3395 | peasycap->frame_buffer_many = FRAME_BUFFER_MANY; |
3396 | 3396 | ||
3397 | for (k = 0; k < INPUT_MANY; k++) | 3397 | for (k = 0; k < INPUT_MANY; k++) |
3398 | peasycap->lost[k] = 0; | 3398 | peasycap->lost[k] = 0; |
3399 | peasycap->skip = 0; | 3399 | peasycap->skip = 0; |
3400 | peasycap->skipped = 0; | 3400 | peasycap->skipped = 0; |
3401 | peasycap->offerfields = 0; | 3401 | peasycap->offerfields = 0; |
3402 | /*---------------------------------------------------------------------------*/ | 3402 | /*---------------------------------------------------------------------------*/ |
3403 | /* | 3403 | /* |
3404 | * DYNAMICALLY FILL IN THE AVAILABLE FORMATS ... | 3404 | * DYNAMICALLY FILL IN THE AVAILABLE FORMATS ... |
3405 | */ | 3405 | */ |
3406 | /*---------------------------------------------------------------------------*/ | 3406 | /*---------------------------------------------------------------------------*/ |
3407 | rc = fillin_formats(); | 3407 | rc = fillin_formats(); |
3408 | if (0 > rc) { | 3408 | if (0 > rc) { |
3409 | SAM("ERROR: fillin_formats() returned %i\n", rc); | 3409 | SAM("ERROR: fillin_formats() returned %i\n", rc); |
3410 | return -EFAULT; | 3410 | return -EFAULT; |
3411 | } | 3411 | } |
3412 | JOM(4, "%i formats available\n", rc); | 3412 | JOM(4, "%i formats available\n", rc); |
3413 | /*---------------------------------------------------------------------------*/ | 3413 | /*---------------------------------------------------------------------------*/ |
3414 | /* | 3414 | /* |
3415 | * ... AND POPULATE easycap.inputset[] | 3415 | * ... AND POPULATE easycap.inputset[] |
3416 | */ | 3416 | */ |
3417 | /*---------------------------------------------------------------------------*/ | 3417 | /*---------------------------------------------------------------------------*/ |
3418 | for (k = 0; k < INPUT_MANY; k++) { | 3418 | for (k = 0; k < INPUT_MANY; k++) { |
3419 | peasycap->inputset[k].input_ok = 0; | 3419 | peasycap->inputset[k].input_ok = 0; |
3420 | peasycap->inputset[k].standard_offset_ok = 0; | 3420 | peasycap->inputset[k].standard_offset_ok = 0; |
3421 | peasycap->inputset[k].format_offset_ok = 0; | 3421 | peasycap->inputset[k].format_offset_ok = 0; |
3422 | peasycap->inputset[k].brightness_ok = 0; | 3422 | peasycap->inputset[k].brightness_ok = 0; |
3423 | peasycap->inputset[k].contrast_ok = 0; | 3423 | peasycap->inputset[k].contrast_ok = 0; |
3424 | peasycap->inputset[k].saturation_ok = 0; | 3424 | peasycap->inputset[k].saturation_ok = 0; |
3425 | peasycap->inputset[k].hue_ok = 0; | 3425 | peasycap->inputset[k].hue_ok = 0; |
3426 | } | 3426 | } |
3427 | if (true == peasycap->ntsc) { | 3427 | if (true == peasycap->ntsc) { |
3428 | i = 0; | 3428 | i = 0; |
3429 | m = 0; | 3429 | m = 0; |
3430 | mask = 0; | 3430 | mask = 0; |
3431 | while (0xFFFF != easycap_standard[i].mask) { | 3431 | while (0xFFFF != easycap_standard[i].mask) { |
3432 | if (NTSC_M == easycap_standard[i]. | 3432 | if (NTSC_M == easycap_standard[i]. |
3433 | v4l2_standard.index) { | 3433 | v4l2_standard.index) { |
3434 | m++; | 3434 | m++; |
3435 | for (k = 0; k < INPUT_MANY; k++) { | 3435 | for (k = 0; k < INPUT_MANY; k++) { |
3436 | peasycap->inputset[k]. | 3436 | peasycap->inputset[k]. |
3437 | standard_offset = i; | 3437 | standard_offset = i; |
3438 | } | ||
3439 | mask = easycap_standard[i].mask; | ||
3438 | } | 3440 | } |
3439 | mask = easycap_standard[i].mask; | 3441 | i++; |
3442 | } | ||
3443 | } else { | ||
3444 | i = 0; | ||
3445 | m = 0; | ||
3446 | mask = 0; | ||
3447 | while (0xFFFF != easycap_standard[i].mask) { | ||
3448 | if (PAL_BGHIN == easycap_standard[i]. | ||
3449 | v4l2_standard.index) { | ||
3450 | m++; | ||
3451 | for (k = 0; k < INPUT_MANY; k++) { | ||
3452 | peasycap->inputset[k]. | ||
3453 | standard_offset = i; | ||
3454 | } | ||
3455 | mask = easycap_standard[i].mask; | ||
3456 | } | ||
3457 | i++; | ||
3440 | } | 3458 | } |
3441 | i++; | ||
3442 | } | 3459 | } |
3443 | } else { | 3460 | |
3461 | if (1 != m) { | ||
3462 | SAM("MISTAKE: easycap.inputset[].standard_offset " | ||
3463 | "unpopulated, %i=m\n", m); | ||
3464 | return -ENOENT; | ||
3465 | } | ||
3466 | |||
3467 | peasycap_format = &easycap_format[0]; | ||
3444 | i = 0; | 3468 | i = 0; |
3445 | m = 0; | 3469 | m = 0; |
3446 | mask = 0; | 3470 | while (0 != peasycap_format->v4l2_format.fmt.pix.width) { |
3447 | while (0xFFFF != easycap_standard[i].mask) { | 3471 | if (((peasycap_format->mask & 0x0F) == (mask & 0x0F)) && |
3448 | if (PAL_BGHIN == easycap_standard[i]. | 3472 | (peasycap_format-> |
3449 | v4l2_standard.index) { | 3473 | v4l2_format.fmt.pix.field == |
3474 | V4L2_FIELD_NONE) && | ||
3475 | (peasycap_format-> | ||
3476 | v4l2_format.fmt.pix.pixelformat == | ||
3477 | V4L2_PIX_FMT_UYVY) && | ||
3478 | (peasycap_format-> | ||
3479 | v4l2_format.fmt.pix.width == | ||
3480 | 640) && | ||
3481 | (peasycap_format-> | ||
3482 | v4l2_format.fmt.pix.height == 480)) { | ||
3450 | m++; | 3483 | m++; |
3451 | for (k = 0; k < INPUT_MANY; k++) { | 3484 | for (k = 0; k < INPUT_MANY; k++) |
3452 | peasycap->inputset[k]. | 3485 | peasycap->inputset[k].format_offset = i; |
3453 | standard_offset = i; | 3486 | break; |
3454 | } | ||
3455 | mask = easycap_standard[i].mask; | ||
3456 | } | 3487 | } |
3457 | i++; | 3488 | peasycap_format++; |
3489 | i++; | ||
3458 | } | 3490 | } |
3459 | } | 3491 | if (1 != m) { |
3460 | 3492 | SAM("MISTAKE: easycap.inputset[].format_offset unpopulated\n"); | |
3461 | if (1 != m) { | ||
3462 | SAM("MISTAKE: easycap.inputset[].standard_offset " | ||
3463 | "unpopulated, %i=m\n", m); | ||
3464 | return -ENOENT; | 3493 | return -ENOENT; |
3465 | } | ||
3466 | |||
3467 | peasycap_format = &easycap_format[0]; | ||
3468 | i = 0; | ||
3469 | m = 0; | ||
3470 | while (0 != peasycap_format->v4l2_format.fmt.pix.width) { | ||
3471 | if (((peasycap_format->mask & 0x0F) == (mask & 0x0F)) && | ||
3472 | (peasycap_format-> | ||
3473 | v4l2_format.fmt.pix.field == | ||
3474 | V4L2_FIELD_NONE) && | ||
3475 | (peasycap_format-> | ||
3476 | v4l2_format.fmt.pix.pixelformat == | ||
3477 | V4L2_PIX_FMT_UYVY) && | ||
3478 | (peasycap_format-> | ||
3479 | v4l2_format.fmt.pix.width == | ||
3480 | 640) && | ||
3481 | (peasycap_format-> | ||
3482 | v4l2_format.fmt.pix.height == 480)) { | ||
3483 | m++; | ||
3484 | for (k = 0; k < INPUT_MANY; k++) | ||
3485 | peasycap->inputset[k].format_offset = i; | ||
3486 | break; | ||
3487 | } | 3494 | } |
3488 | peasycap_format++; | ||
3489 | i++; | ||
3490 | } | ||
3491 | if (1 != m) { | ||
3492 | SAM("MISTAKE: easycap.inputset[].format_offset unpopulated\n"); | ||
3493 | return -ENOENT; | ||
3494 | } | ||
3495 | 3495 | ||
3496 | i = 0; | 3496 | i = 0; |
3497 | m = 0; | 3497 | m = 0; |
3498 | while (0xFFFFFFFF != easycap_control[i].id) { | 3498 | while (0xFFFFFFFF != easycap_control[i].id) { |
3499 | value = easycap_control[i].default_value; | 3499 | value = easycap_control[i].default_value; |
3500 | if (V4L2_CID_BRIGHTNESS == easycap_control[i].id) { | 3500 | if (V4L2_CID_BRIGHTNESS == easycap_control[i].id) { |
3501 | m++; | 3501 | m++; |
3502 | for (k = 0; k < INPUT_MANY; k++) | 3502 | for (k = 0; k < INPUT_MANY; k++) |
3503 | peasycap->inputset[k].brightness = value; | 3503 | peasycap->inputset[k].brightness = value; |
3504 | } else if (V4L2_CID_CONTRAST == easycap_control[i].id) { | 3504 | } else if (V4L2_CID_CONTRAST == easycap_control[i].id) { |
3505 | m++; | 3505 | m++; |
3506 | for (k = 0; k < INPUT_MANY; k++) | 3506 | for (k = 0; k < INPUT_MANY; k++) |
3507 | peasycap->inputset[k].contrast = value; | 3507 | peasycap->inputset[k].contrast = value; |
3508 | } else if (V4L2_CID_SATURATION == easycap_control[i].id) { | 3508 | } else if (V4L2_CID_SATURATION == easycap_control[i].id) { |
3509 | m++; | 3509 | m++; |
3510 | for (k = 0; k < INPUT_MANY; k++) | 3510 | for (k = 0; k < INPUT_MANY; k++) |
3511 | peasycap->inputset[k].saturation = value; | 3511 | peasycap->inputset[k].saturation = value; |
3512 | } else if (V4L2_CID_HUE == easycap_control[i].id) { | 3512 | } else if (V4L2_CID_HUE == easycap_control[i].id) { |
3513 | m++; | 3513 | m++; |
3514 | for (k = 0; k < INPUT_MANY; k++) | 3514 | for (k = 0; k < INPUT_MANY; k++) |
3515 | peasycap->inputset[k].hue = value; | 3515 | peasycap->inputset[k].hue = value; |
3516 | } | ||
3517 | i++; | ||
3516 | } | 3518 | } |
3517 | i++; | 3519 | if (4 != m) { |
3518 | } | 3520 | SAM("MISTAKE: easycap.inputset[].brightness,... " |
3519 | if (4 != m) { | 3521 | "underpopulated\n"); |
3520 | SAM("MISTAKE: easycap.inputset[].brightness,... " | 3522 | return -ENOENT; |
3521 | "underpopulated\n"); | 3523 | } |
3522 | return -ENOENT; | 3524 | for (k = 0; k < INPUT_MANY; k++) |
3523 | } | 3525 | peasycap->inputset[k].input = k; |
3524 | for (k = 0; k < INPUT_MANY; k++) | 3526 | JOM(4, "populated easycap.inputset[]\n"); |
3525 | peasycap->inputset[k].input = k; | 3527 | JOM(4, "finished initialization\n"); |
3526 | JOM(4, "populated easycap.inputset[]\n"); | 3528 | } else { |
3527 | JOM(4, "finished initialization\n"); | ||
3528 | } else { | ||
3529 | /*---------------------------------------------------------------------------*/ | 3529 | /*---------------------------------------------------------------------------*/ |
3530 | /* | 3530 | /* |
3531 | * FIXME | 3531 | * FIXME |
@@ -3534,25 +3534,25 @@ if (0 == bInterfaceNumber) { | |||
3534 | * THE ADDRESS OF peasycap->pusb_device IS RELUCTANTLY USED FOR THIS PURPOSE. | 3534 | * THE ADDRESS OF peasycap->pusb_device IS RELUCTANTLY USED FOR THIS PURPOSE. |
3535 | */ | 3535 | */ |
3536 | /*---------------------------------------------------------------------------*/ | 3536 | /*---------------------------------------------------------------------------*/ |
3537 | for (ndong = 0; ndong < DONGLE_MANY; ndong++) { | 3537 | for (ndong = 0; ndong < DONGLE_MANY; ndong++) { |
3538 | if (pusb_device == easycapdc60_dongle[ndong].peasycap-> | 3538 | if (pusb_device == easycapdc60_dongle[ndong].peasycap-> |
3539 | pusb_device) { | 3539 | pusb_device) { |
3540 | peasycap = easycapdc60_dongle[ndong].peasycap; | 3540 | peasycap = easycapdc60_dongle[ndong].peasycap; |
3541 | JOT(8, "intf[%i]: easycapdc60_dongle[%i].peasycap-->" | 3541 | JOT(8, "intf[%i]: easycapdc60_dongle[%i].peasycap-->" |
3542 | "peasycap\n", bInterfaceNumber, ndong); | 3542 | "peasycap\n", bInterfaceNumber, ndong); |
3543 | break; | 3543 | break; |
3544 | } | ||
3545 | } | ||
3546 | if (DONGLE_MANY <= ndong) { | ||
3547 | SAY("ERROR: peasycap is unknown when probing interface %i\n", | ||
3548 | bInterfaceNumber); | ||
3549 | return -ENODEV; | ||
3550 | } | ||
3551 | if (NULL == peasycap) { | ||
3552 | SAY("ERROR: peasycap is NULL when probing interface %i\n", | ||
3553 | bInterfaceNumber); | ||
3554 | return -ENODEV; | ||
3544 | } | 3555 | } |
3545 | } | ||
3546 | if (DONGLE_MANY <= ndong) { | ||
3547 | SAY("ERROR: peasycap is unknown when probing interface %i\n", | ||
3548 | bInterfaceNumber); | ||
3549 | return -ENODEV; | ||
3550 | } | ||
3551 | if (NULL == peasycap) { | ||
3552 | SAY("ERROR: peasycap is NULL when probing interface %i\n", | ||
3553 | bInterfaceNumber); | ||
3554 | return -ENODEV; | ||
3555 | } | ||
3556 | #ifndef EASYCAP_IS_VIDEODEV_CLIENT | 3556 | #ifndef EASYCAP_IS_VIDEODEV_CLIENT |
3557 | # | 3557 | # |
3558 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | 3558 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ |
@@ -3566,553 +3566,553 @@ if (0 == bInterfaceNumber) { | |||
3566 | * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED. | 3566 | * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED. |
3567 | */ | 3567 | */ |
3568 | /*---------------------------------------------------------------------------*/ | 3568 | /*---------------------------------------------------------------------------*/ |
3569 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 3569 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
3570 | pv4l2_device = usb_get_intfdata(pusb_interface); | 3570 | pv4l2_device = usb_get_intfdata(pusb_interface); |
3571 | if (NULL == pv4l2_device) { | 3571 | if (NULL == pv4l2_device) { |
3572 | SAY("ERROR: pv4l2_device is NULL\n"); | 3572 | SAY("ERROR: pv4l2_device is NULL\n"); |
3573 | return -ENODEV; | 3573 | return -ENODEV; |
3574 | } | ||
3575 | peasycap = (struct easycap *) | ||
3576 | container_of(pv4l2_device, struct easycap, v4l2_device); | ||
3574 | } | 3577 | } |
3575 | peasycap = (struct easycap *) | ||
3576 | container_of(pv4l2_device, struct easycap, v4l2_device); | ||
3577 | } | ||
3578 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ | 3578 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ |
3579 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ | 3579 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ |
3580 | } | 3580 | } |
3581 | /*---------------------------------------------------------------------------*/ | 3581 | /*---------------------------------------------------------------------------*/ |
3582 | if ((USB_CLASS_VIDEO == bInterfaceClass) || | 3582 | if ((USB_CLASS_VIDEO == bInterfaceClass) || |
3583 | (USB_CLASS_VENDOR_SPEC == bInterfaceClass)) { | 3583 | (USB_CLASS_VENDOR_SPEC == bInterfaceClass)) { |
3584 | if (-1 == peasycap->video_interface) { | 3584 | if (-1 == peasycap->video_interface) { |
3585 | peasycap->video_interface = bInterfaceNumber; | 3585 | peasycap->video_interface = bInterfaceNumber; |
3586 | JOM(4, "setting peasycap->video_interface=%i\n", | 3586 | JOM(4, "setting peasycap->video_interface=%i\n", |
3587 | peasycap->video_interface); | ||
3588 | } else { | ||
3589 | if (peasycap->video_interface != bInterfaceNumber) { | ||
3590 | SAM("ERROR: attempting to reset " | ||
3591 | "peasycap->video_interface\n"); | ||
3592 | SAM("...... continuing with " | ||
3593 | "%i=peasycap->video_interface\n", | ||
3587 | peasycap->video_interface); | 3594 | peasycap->video_interface); |
3588 | } else { | 3595 | } |
3589 | if (peasycap->video_interface != bInterfaceNumber) { | ||
3590 | SAM("ERROR: attempting to reset " | ||
3591 | "peasycap->video_interface\n"); | ||
3592 | SAM("...... continuing with " | ||
3593 | "%i=peasycap->video_interface\n", | ||
3594 | peasycap->video_interface); | ||
3595 | } | 3596 | } |
3596 | } | 3597 | } else if ((USB_CLASS_AUDIO == bInterfaceClass) && |
3597 | } else if ((USB_CLASS_AUDIO == bInterfaceClass) && | 3598 | (0x02 == bInterfaceSubClass)) { |
3598 | (0x02 == bInterfaceSubClass)) { | 3599 | if (-1 == peasycap->audio_interface) { |
3599 | if (-1 == peasycap->audio_interface) { | 3600 | peasycap->audio_interface = bInterfaceNumber; |
3600 | peasycap->audio_interface = bInterfaceNumber; | 3601 | JOM(4, "setting peasycap->audio_interface=%i\n", |
3601 | JOM(4, "setting peasycap->audio_interface=%i\n", | 3602 | peasycap->audio_interface); |
3602 | peasycap->audio_interface); | 3603 | } else { |
3603 | } else { | 3604 | if (peasycap->audio_interface != bInterfaceNumber) { |
3604 | if (peasycap->audio_interface != bInterfaceNumber) { | 3605 | SAM("ERROR: attempting to reset " |
3605 | SAM("ERROR: attempting to reset " | 3606 | "peasycap->audio_interface\n"); |
3606 | "peasycap->audio_interface\n"); | 3607 | SAM("...... continuing with " |
3607 | SAM("...... continuing with " | 3608 | "%i=peasycap->audio_interface\n", |
3608 | "%i=peasycap->audio_interface\n", | 3609 | peasycap->audio_interface); |
3609 | peasycap->audio_interface); | 3610 | } |
3610 | } | 3611 | } |
3611 | } | 3612 | } |
3612 | } | ||
3613 | /*---------------------------------------------------------------------------*/ | 3613 | /*---------------------------------------------------------------------------*/ |
3614 | /* | 3614 | /* |
3615 | * INVESTIGATE ALL ALTSETTINGS. | 3615 | * INVESTIGATE ALL ALTSETTINGS. |
3616 | * DONE IN DETAIL BECAUSE USB DEVICE 05e1:0408 HAS DISPARATE INCARNATIONS. | 3616 | * DONE IN DETAIL BECAUSE USB DEVICE 05e1:0408 HAS DISPARATE INCARNATIONS. |
3617 | */ | 3617 | */ |
3618 | /*---------------------------------------------------------------------------*/ | 3618 | /*---------------------------------------------------------------------------*/ |
3619 | isokalt = 0; | 3619 | isokalt = 0; |
3620 | 3620 | ||
3621 | for (i = 0; i < pusb_interface->num_altsetting; i++) { | 3621 | for (i = 0; i < pusb_interface->num_altsetting; i++) { |
3622 | pusb_host_interface = &(pusb_interface->altsetting[i]); | 3622 | pusb_host_interface = &(pusb_interface->altsetting[i]); |
3623 | if (NULL == pusb_host_interface) { | 3623 | if (NULL == pusb_host_interface) { |
3624 | SAM("ERROR: pusb_host_interface is NULL\n"); | 3624 | SAM("ERROR: pusb_host_interface is NULL\n"); |
3625 | return -EFAULT; | 3625 | return -EFAULT; |
3626 | } | ||
3627 | pusb_interface_descriptor = &(pusb_host_interface->desc); | ||
3628 | if (NULL == pusb_interface_descriptor) { | ||
3629 | SAM("ERROR: pusb_interface_descriptor is NULL\n"); | ||
3630 | return -EFAULT; | ||
3631 | } | ||
3632 | |||
3633 | JOM(4, "intf[%i]alt[%i]: desc.bDescriptorType=0x%02X\n", | ||
3634 | bInterfaceNumber, i, pusb_interface_descriptor->bDescriptorType); | ||
3635 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceNumber=0x%02X\n", | ||
3636 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceNumber); | ||
3637 | JOM(4, "intf[%i]alt[%i]: desc.bAlternateSetting=0x%02X\n", | ||
3638 | bInterfaceNumber, i, pusb_interface_descriptor->bAlternateSetting); | ||
3639 | JOM(4, "intf[%i]alt[%i]: desc.bNumEndpoints=0x%02X\n", | ||
3640 | bInterfaceNumber, i, pusb_interface_descriptor->bNumEndpoints); | ||
3641 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceClass=0x%02X\n", | ||
3642 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceClass); | ||
3643 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceSubClass=0x%02X\n", | ||
3644 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceSubClass); | ||
3645 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceProtocol=0x%02X\n", | ||
3646 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceProtocol); | ||
3647 | JOM(4, "intf[%i]alt[%i]: desc.iInterface=0x%02X\n", | ||
3648 | bInterfaceNumber, i, pusb_interface_descriptor->iInterface); | ||
3649 | |||
3650 | ISOCwMaxPacketSize = -1; | ||
3651 | BULKwMaxPacketSize = -1; | ||
3652 | INTwMaxPacketSize = -1; | ||
3653 | CTRLwMaxPacketSize = -1; | ||
3654 | ISOCbEndpointAddress = 0; | ||
3655 | INTbEndpointAddress = 0; | ||
3656 | |||
3657 | if (0 == pusb_interface_descriptor->bNumEndpoints) | ||
3658 | JOM(4, "intf[%i]alt[%i] has no endpoints\n", | ||
3659 | bInterfaceNumber, i); | ||
3660 | /*---------------------------------------------------------------------------*/ | ||
3661 | for (j = 0; j < pusb_interface_descriptor->bNumEndpoints; j++) { | ||
3662 | pepd = &(pusb_host_interface->endpoint[j].desc); | ||
3663 | if (NULL == pepd) { | ||
3664 | SAM("ERROR: pepd is NULL.\n"); | ||
3665 | SAM("...... skipping\n"); | ||
3666 | continue; | ||
3667 | } | 3626 | } |
3668 | wMaxPacketSize = le16_to_cpu(pepd->wMaxPacketSize); | 3627 | pusb_interface_descriptor = &(pusb_host_interface->desc); |
3669 | bEndpointAddress = pepd->bEndpointAddress; | 3628 | if (NULL == pusb_interface_descriptor) { |
3670 | 3629 | SAM("ERROR: pusb_interface_descriptor is NULL\n"); | |
3671 | JOM(4, "intf[%i]alt[%i]end[%i]: bEndpointAddress=0x%X\n", | 3630 | return -EFAULT; |
3672 | bInterfaceNumber, i, j, | ||
3673 | pepd->bEndpointAddress); | ||
3674 | JOM(4, "intf[%i]alt[%i]end[%i]: bmAttributes=0x%X\n", | ||
3675 | bInterfaceNumber, i, j, | ||
3676 | pepd->bmAttributes); | ||
3677 | JOM(4, "intf[%i]alt[%i]end[%i]: wMaxPacketSize=%i\n", | ||
3678 | bInterfaceNumber, i, j, | ||
3679 | pepd->wMaxPacketSize); | ||
3680 | JOM(4, "intf[%i]alt[%i]end[%i]: bInterval=%i\n", | ||
3681 | bInterfaceNumber, i, j, | ||
3682 | pepd->bInterval); | ||
3683 | |||
3684 | if (pepd->bEndpointAddress & USB_DIR_IN) { | ||
3685 | JOM(4, "intf[%i]alt[%i]end[%i] is an IN endpoint\n", | ||
3686 | bInterfaceNumber, i, j); | ||
3687 | isin = 1; | ||
3688 | } else { | ||
3689 | JOM(4, "intf[%i]alt[%i]end[%i] is an OUT endpoint\n", | ||
3690 | bInterfaceNumber, i, j); | ||
3691 | SAM("ERROR: OUT endpoint unexpected\n"); | ||
3692 | SAM("...... continuing\n"); | ||
3693 | isin = 0; | ||
3694 | } | 3631 | } |
3695 | if ((pepd->bmAttributes & | 3632 | |
3696 | USB_ENDPOINT_XFERTYPE_MASK) == | 3633 | JOM(4, "intf[%i]alt[%i]: desc.bDescriptorType=0x%02X\n", |
3697 | USB_ENDPOINT_XFER_ISOC) { | 3634 | bInterfaceNumber, i, pusb_interface_descriptor->bDescriptorType); |
3698 | JOM(4, "intf[%i]alt[%i]end[%i] is an ISOC endpoint\n", | 3635 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceNumber=0x%02X\n", |
3699 | bInterfaceNumber, i, j); | 3636 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceNumber); |
3700 | if (isin) { | 3637 | JOM(4, "intf[%i]alt[%i]: desc.bAlternateSetting=0x%02X\n", |
3701 | switch (bInterfaceClass) { | 3638 | bInterfaceNumber, i, pusb_interface_descriptor->bAlternateSetting); |
3702 | case USB_CLASS_VIDEO: | 3639 | JOM(4, "intf[%i]alt[%i]: desc.bNumEndpoints=0x%02X\n", |
3703 | case USB_CLASS_VENDOR_SPEC: { | 3640 | bInterfaceNumber, i, pusb_interface_descriptor->bNumEndpoints); |
3704 | if (!peasycap) { | 3641 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceClass=0x%02X\n", |
3705 | SAM("MISTAKE: " | 3642 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceClass); |
3706 | "peasycap is NULL\n"); | 3643 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceSubClass=0x%02X\n", |
3707 | return -EFAULT; | 3644 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceSubClass); |
3708 | } | 3645 | JOM(4, "intf[%i]alt[%i]: desc.bInterfaceProtocol=0x%02X\n", |
3709 | if (pepd->wMaxPacketSize) { | 3646 | bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceProtocol); |
3710 | if (8 > isokalt) { | 3647 | JOM(4, "intf[%i]alt[%i]: desc.iInterface=0x%02X\n", |
3711 | okalt[isokalt] = i; | 3648 | bInterfaceNumber, i, pusb_interface_descriptor->iInterface); |
3712 | JOM(4, | 3649 | |
3713 | "%i=okalt[%i]\n", | 3650 | ISOCwMaxPacketSize = -1; |
3714 | okalt[isokalt], | 3651 | BULKwMaxPacketSize = -1; |
3715 | isokalt); | 3652 | INTwMaxPacketSize = -1; |
3716 | okepn[isokalt] = | 3653 | CTRLwMaxPacketSize = -1; |
3717 | pepd-> | 3654 | ISOCbEndpointAddress = 0; |
3718 | bEndpointAddress & | 3655 | INTbEndpointAddress = 0; |
3719 | 0x0F; | 3656 | |
3720 | JOM(4, | 3657 | if (0 == pusb_interface_descriptor->bNumEndpoints) |
3721 | "%i=okepn[%i]\n", | 3658 | JOM(4, "intf[%i]alt[%i] has no endpoints\n", |
3722 | okepn[isokalt], | 3659 | bInterfaceNumber, i); |
3723 | isokalt); | 3660 | /*---------------------------------------------------------------------------*/ |
3724 | okmps[isokalt] = | 3661 | for (j = 0; j < pusb_interface_descriptor->bNumEndpoints; j++) { |
3725 | le16_to_cpu(pepd-> | 3662 | pepd = &(pusb_host_interface->endpoint[j].desc); |
3726 | wMaxPacketSize); | 3663 | if (NULL == pepd) { |
3727 | JOM(4, | 3664 | SAM("ERROR: pepd is NULL.\n"); |
3728 | "%i=okmps[%i]\n", | 3665 | SAM("...... skipping\n"); |
3729 | okmps[isokalt], | 3666 | continue; |
3730 | isokalt); | 3667 | } |
3731 | isokalt++; | 3668 | wMaxPacketSize = le16_to_cpu(pepd->wMaxPacketSize); |
3669 | bEndpointAddress = pepd->bEndpointAddress; | ||
3670 | |||
3671 | JOM(4, "intf[%i]alt[%i]end[%i]: bEndpointAddress=0x%X\n", | ||
3672 | bInterfaceNumber, i, j, | ||
3673 | pepd->bEndpointAddress); | ||
3674 | JOM(4, "intf[%i]alt[%i]end[%i]: bmAttributes=0x%X\n", | ||
3675 | bInterfaceNumber, i, j, | ||
3676 | pepd->bmAttributes); | ||
3677 | JOM(4, "intf[%i]alt[%i]end[%i]: wMaxPacketSize=%i\n", | ||
3678 | bInterfaceNumber, i, j, | ||
3679 | pepd->wMaxPacketSize); | ||
3680 | JOM(4, "intf[%i]alt[%i]end[%i]: bInterval=%i\n", | ||
3681 | bInterfaceNumber, i, j, | ||
3682 | pepd->bInterval); | ||
3683 | |||
3684 | if (pepd->bEndpointAddress & USB_DIR_IN) { | ||
3685 | JOM(4, "intf[%i]alt[%i]end[%i] is an IN endpoint\n", | ||
3686 | bInterfaceNumber, i, j); | ||
3687 | isin = 1; | ||
3688 | } else { | ||
3689 | JOM(4, "intf[%i]alt[%i]end[%i] is an OUT endpoint\n", | ||
3690 | bInterfaceNumber, i, j); | ||
3691 | SAM("ERROR: OUT endpoint unexpected\n"); | ||
3692 | SAM("...... continuing\n"); | ||
3693 | isin = 0; | ||
3694 | } | ||
3695 | if ((pepd->bmAttributes & | ||
3696 | USB_ENDPOINT_XFERTYPE_MASK) == | ||
3697 | USB_ENDPOINT_XFER_ISOC) { | ||
3698 | JOM(4, "intf[%i]alt[%i]end[%i] is an ISOC endpoint\n", | ||
3699 | bInterfaceNumber, i, j); | ||
3700 | if (isin) { | ||
3701 | switch (bInterfaceClass) { | ||
3702 | case USB_CLASS_VIDEO: | ||
3703 | case USB_CLASS_VENDOR_SPEC: { | ||
3704 | if (!peasycap) { | ||
3705 | SAM("MISTAKE: " | ||
3706 | "peasycap is NULL\n"); | ||
3707 | return -EFAULT; | ||
3732 | } | 3708 | } |
3733 | } else { | 3709 | if (pepd->wMaxPacketSize) { |
3734 | if (-1 == peasycap-> | 3710 | if (8 > isokalt) { |
3735 | video_altsetting_off) { | 3711 | okalt[isokalt] = i; |
3736 | peasycap-> | 3712 | JOM(4, |
3737 | video_altsetting_off = | 3713 | "%i=okalt[%i]\n", |
3738 | i; | 3714 | okalt[isokalt], |
3739 | JOM(4, "%i=video_" | 3715 | isokalt); |
3740 | "altsetting_off " | 3716 | okepn[isokalt] = |
3741 | "<====\n", | 3717 | pepd-> |
3742 | peasycap-> | 3718 | bEndpointAddress & |
3743 | video_altsetting_off); | 3719 | 0x0F; |
3720 | JOM(4, | ||
3721 | "%i=okepn[%i]\n", | ||
3722 | okepn[isokalt], | ||
3723 | isokalt); | ||
3724 | okmps[isokalt] = | ||
3725 | le16_to_cpu(pepd-> | ||
3726 | wMaxPacketSize); | ||
3727 | JOM(4, | ||
3728 | "%i=okmps[%i]\n", | ||
3729 | okmps[isokalt], | ||
3730 | isokalt); | ||
3731 | isokalt++; | ||
3732 | } | ||
3744 | } else { | 3733 | } else { |
3745 | SAM("ERROR: peasycap" | 3734 | if (-1 == peasycap-> |
3746 | "->video_altsetting_" | 3735 | video_altsetting_off) { |
3747 | "off already set\n"); | 3736 | peasycap-> |
3748 | SAM("...... " | 3737 | video_altsetting_off = |
3749 | "continuing with " | 3738 | i; |
3750 | "%i=peasycap->video_" | 3739 | JOM(4, "%i=video_" |
3751 | "altsetting_off\n", | 3740 | "altsetting_off " |
3752 | peasycap-> | 3741 | "<====\n", |
3753 | video_altsetting_off); | 3742 | peasycap-> |
3743 | video_altsetting_off); | ||
3744 | } else { | ||
3745 | SAM("ERROR: peasycap" | ||
3746 | "->video_altsetting_" | ||
3747 | "off already set\n"); | ||
3748 | SAM("...... " | ||
3749 | "continuing with " | ||
3750 | "%i=peasycap->video_" | ||
3751 | "altsetting_off\n", | ||
3752 | peasycap-> | ||
3753 | video_altsetting_off); | ||
3754 | } | ||
3754 | } | 3755 | } |
3755 | } | ||
3756 | break; | ||
3757 | } | ||
3758 | case USB_CLASS_AUDIO: { | ||
3759 | if (0x02 != bInterfaceSubClass) | ||
3760 | break; | 3756 | break; |
3761 | if (!peasycap) { | ||
3762 | SAM("MISTAKE: " | ||
3763 | "peasycap is NULL\n"); | ||
3764 | return -EFAULT; | ||
3765 | } | 3757 | } |
3766 | if (pepd->wMaxPacketSize) { | 3758 | case USB_CLASS_AUDIO: { |
3767 | if (8 > isokalt) { | 3759 | if (0x02 != bInterfaceSubClass) |
3768 | okalt[isokalt] = i ; | 3760 | break; |
3769 | JOM(4, | 3761 | if (!peasycap) { |
3770 | "%i=okalt[%i]\n", | 3762 | SAM("MISTAKE: " |
3771 | okalt[isokalt], | 3763 | "peasycap is NULL\n"); |
3772 | isokalt); | 3764 | return -EFAULT; |
3773 | okepn[isokalt] = | ||
3774 | pepd-> | ||
3775 | bEndpointAddress & | ||
3776 | 0x0F; | ||
3777 | JOM(4, | ||
3778 | "%i=okepn[%i]\n", | ||
3779 | okepn[isokalt], | ||
3780 | isokalt); | ||
3781 | okmps[isokalt] = | ||
3782 | le16_to_cpu(pepd-> | ||
3783 | wMaxPacketSize); | ||
3784 | JOM(4, | ||
3785 | "%i=okmps[%i]\n", | ||
3786 | okmps[isokalt], | ||
3787 | isokalt); | ||
3788 | isokalt++; | ||
3789 | } | 3765 | } |
3790 | } else { | 3766 | if (pepd->wMaxPacketSize) { |
3791 | if (-1 == peasycap-> | 3767 | if (8 > isokalt) { |
3792 | audio_altsetting_off) { | 3768 | okalt[isokalt] = i ; |
3793 | peasycap-> | 3769 | JOM(4, |
3794 | audio_altsetting_off = | 3770 | "%i=okalt[%i]\n", |
3795 | i; | 3771 | okalt[isokalt], |
3796 | JOM(4, "%i=audio_" | 3772 | isokalt); |
3797 | "altsetting_off " | 3773 | okepn[isokalt] = |
3798 | "<====\n", | 3774 | pepd-> |
3799 | peasycap-> | 3775 | bEndpointAddress & |
3800 | audio_altsetting_off); | 3776 | 0x0F; |
3777 | JOM(4, | ||
3778 | "%i=okepn[%i]\n", | ||
3779 | okepn[isokalt], | ||
3780 | isokalt); | ||
3781 | okmps[isokalt] = | ||
3782 | le16_to_cpu(pepd-> | ||
3783 | wMaxPacketSize); | ||
3784 | JOM(4, | ||
3785 | "%i=okmps[%i]\n", | ||
3786 | okmps[isokalt], | ||
3787 | isokalt); | ||
3788 | isokalt++; | ||
3789 | } | ||
3801 | } else { | 3790 | } else { |
3802 | SAM("ERROR: peasycap" | 3791 | if (-1 == peasycap-> |
3803 | "->audio_altsetting_" | 3792 | audio_altsetting_off) { |
3804 | "off already set\n"); | 3793 | peasycap-> |
3805 | SAM("...... " | 3794 | audio_altsetting_off = |
3806 | "continuing with " | 3795 | i; |
3807 | "%i=peasycap->" | 3796 | JOM(4, "%i=audio_" |
3808 | "audio_altsetting_" | 3797 | "altsetting_off " |
3809 | "off\n", | 3798 | "<====\n", |
3810 | peasycap-> | 3799 | peasycap-> |
3811 | audio_altsetting_off); | 3800 | audio_altsetting_off); |
3801 | } else { | ||
3802 | SAM("ERROR: peasycap" | ||
3803 | "->audio_altsetting_" | ||
3804 | "off already set\n"); | ||
3805 | SAM("...... " | ||
3806 | "continuing with " | ||
3807 | "%i=peasycap->" | ||
3808 | "audio_altsetting_" | ||
3809 | "off\n", | ||
3810 | peasycap-> | ||
3811 | audio_altsetting_off); | ||
3812 | } | ||
3812 | } | 3813 | } |
3813 | } | ||
3814 | break; | ||
3815 | } | ||
3816 | default: | ||
3817 | break; | 3814 | break; |
3815 | } | ||
3816 | default: | ||
3817 | break; | ||
3818 | } | ||
3818 | } | 3819 | } |
3820 | } else if ((pepd->bmAttributes & | ||
3821 | USB_ENDPOINT_XFERTYPE_MASK) == | ||
3822 | USB_ENDPOINT_XFER_BULK) { | ||
3823 | JOM(4, "intf[%i]alt[%i]end[%i] is a BULK endpoint\n", | ||
3824 | bInterfaceNumber, i, j); | ||
3825 | } else if ((pepd->bmAttributes & | ||
3826 | USB_ENDPOINT_XFERTYPE_MASK) == | ||
3827 | USB_ENDPOINT_XFER_INT) { | ||
3828 | JOM(4, "intf[%i]alt[%i]end[%i] is an INT endpoint\n", | ||
3829 | bInterfaceNumber, i, j); | ||
3830 | } else { | ||
3831 | JOM(4, "intf[%i]alt[%i]end[%i] is a CTRL endpoint\n", | ||
3832 | bInterfaceNumber, i, j); | ||
3833 | } | ||
3834 | if (0 == pepd->wMaxPacketSize) { | ||
3835 | JOM(4, "intf[%i]alt[%i]end[%i] " | ||
3836 | "has zero packet size\n", | ||
3837 | bInterfaceNumber, i, j); | ||
3819 | } | 3838 | } |
3820 | } else if ((pepd->bmAttributes & | ||
3821 | USB_ENDPOINT_XFERTYPE_MASK) == | ||
3822 | USB_ENDPOINT_XFER_BULK) { | ||
3823 | JOM(4, "intf[%i]alt[%i]end[%i] is a BULK endpoint\n", | ||
3824 | bInterfaceNumber, i, j); | ||
3825 | } else if ((pepd->bmAttributes & | ||
3826 | USB_ENDPOINT_XFERTYPE_MASK) == | ||
3827 | USB_ENDPOINT_XFER_INT) { | ||
3828 | JOM(4, "intf[%i]alt[%i]end[%i] is an INT endpoint\n", | ||
3829 | bInterfaceNumber, i, j); | ||
3830 | } else { | ||
3831 | JOM(4, "intf[%i]alt[%i]end[%i] is a CTRL endpoint\n", | ||
3832 | bInterfaceNumber, i, j); | ||
3833 | } | ||
3834 | if (0 == pepd->wMaxPacketSize) { | ||
3835 | JOM(4, "intf[%i]alt[%i]end[%i] " | ||
3836 | "has zero packet size\n", | ||
3837 | bInterfaceNumber, i, j); | ||
3838 | } | 3839 | } |
3839 | } | 3840 | } |
3840 | } | ||
3841 | /*---------------------------------------------------------------------------*/ | 3841 | /*---------------------------------------------------------------------------*/ |
3842 | /* | 3842 | /* |
3843 | * PERFORM INITIALIZATION OF THE PROBED INTERFACE | 3843 | * PERFORM INITIALIZATION OF THE PROBED INTERFACE |
3844 | */ | 3844 | */ |
3845 | /*---------------------------------------------------------------------------*/ | 3845 | /*---------------------------------------------------------------------------*/ |
3846 | JOM(4, "initialization begins for interface %i\n", | 3846 | JOM(4, "initialization begins for interface %i\n", |
3847 | pusb_interface_descriptor->bInterfaceNumber); | 3847 | pusb_interface_descriptor->bInterfaceNumber); |
3848 | switch (bInterfaceNumber) { | 3848 | switch (bInterfaceNumber) { |
3849 | /*---------------------------------------------------------------------------*/ | 3849 | /*---------------------------------------------------------------------------*/ |
3850 | /* | 3850 | /* |
3851 | * INTERFACE 0 IS THE VIDEO INTERFACE | 3851 | * INTERFACE 0 IS THE VIDEO INTERFACE |
3852 | */ | 3852 | */ |
3853 | /*---------------------------------------------------------------------------*/ | 3853 | /*---------------------------------------------------------------------------*/ |
3854 | case 0: { | 3854 | case 0: { |
3855 | if (!peasycap) { | 3855 | if (!peasycap) { |
3856 | SAM("MISTAKE: peasycap is NULL\n"); | 3856 | SAM("MISTAKE: peasycap is NULL\n"); |
3857 | return -EFAULT; | 3857 | return -EFAULT; |
3858 | } | 3858 | } |
3859 | if (!isokalt) { | 3859 | if (!isokalt) { |
3860 | SAM("ERROR: no viable video_altsetting_on\n"); | 3860 | SAM("ERROR: no viable video_altsetting_on\n"); |
3861 | return -ENOENT; | 3861 | return -ENOENT; |
3862 | } else { | 3862 | } else { |
3863 | peasycap->video_altsetting_on = okalt[isokalt - 1]; | 3863 | peasycap->video_altsetting_on = okalt[isokalt - 1]; |
3864 | JOM(4, "%i=video_altsetting_on <====\n", | 3864 | JOM(4, "%i=video_altsetting_on <====\n", |
3865 | peasycap->video_altsetting_on); | 3865 | peasycap->video_altsetting_on); |
3866 | } | 3866 | } |
3867 | /*---------------------------------------------------------------------------*/ | 3867 | /*---------------------------------------------------------------------------*/ |
3868 | /* | 3868 | /* |
3869 | * DECIDE THE VIDEO STREAMING PARAMETERS | 3869 | * DECIDE THE VIDEO STREAMING PARAMETERS |
3870 | */ | 3870 | */ |
3871 | /*---------------------------------------------------------------------------*/ | 3871 | /*---------------------------------------------------------------------------*/ |
3872 | peasycap->video_endpointnumber = okepn[isokalt - 1]; | 3872 | peasycap->video_endpointnumber = okepn[isokalt - 1]; |
3873 | JOM(4, "%i=video_endpointnumber\n", peasycap->video_endpointnumber); | 3873 | JOM(4, "%i=video_endpointnumber\n", peasycap->video_endpointnumber); |
3874 | maxpacketsize = okmps[isokalt - 1]; | 3874 | maxpacketsize = okmps[isokalt - 1]; |
3875 | if (USB_2_0_MAXPACKETSIZE > maxpacketsize) { | 3875 | if (USB_2_0_MAXPACKETSIZE > maxpacketsize) { |
3876 | peasycap->video_isoc_maxframesize = maxpacketsize; | 3876 | peasycap->video_isoc_maxframesize = maxpacketsize; |
3877 | } else { | 3877 | } else { |
3878 | peasycap->video_isoc_maxframesize = | 3878 | peasycap->video_isoc_maxframesize = |
3879 | USB_2_0_MAXPACKETSIZE; | 3879 | USB_2_0_MAXPACKETSIZE; |
3880 | } | 3880 | } |
3881 | JOM(4, "%i=video_isoc_maxframesize\n", | 3881 | JOM(4, "%i=video_isoc_maxframesize\n", |
3882 | peasycap->video_isoc_maxframesize); | 3882 | peasycap->video_isoc_maxframesize); |
3883 | if (0 >= peasycap->video_isoc_maxframesize) { | 3883 | if (0 >= peasycap->video_isoc_maxframesize) { |
3884 | SAM("ERROR: bad video_isoc_maxframesize\n"); | 3884 | SAM("ERROR: bad video_isoc_maxframesize\n"); |
3885 | SAM(" possibly because port is USB 1.1\n"); | 3885 | SAM(" possibly because port is USB 1.1\n"); |
3886 | return -ENOENT; | 3886 | return -ENOENT; |
3887 | } | 3887 | } |
3888 | peasycap->video_isoc_framesperdesc = VIDEO_ISOC_FRAMESPERDESC; | 3888 | peasycap->video_isoc_framesperdesc = VIDEO_ISOC_FRAMESPERDESC; |
3889 | JOM(4, "%i=video_isoc_framesperdesc\n", | 3889 | JOM(4, "%i=video_isoc_framesperdesc\n", |
3890 | peasycap->video_isoc_framesperdesc); | 3890 | peasycap->video_isoc_framesperdesc); |
3891 | if (0 >= peasycap->video_isoc_framesperdesc) { | 3891 | if (0 >= peasycap->video_isoc_framesperdesc) { |
3892 | SAM("ERROR: bad video_isoc_framesperdesc\n"); | 3892 | SAM("ERROR: bad video_isoc_framesperdesc\n"); |
3893 | return -ENOENT; | 3893 | return -ENOENT; |
3894 | } | 3894 | } |
3895 | peasycap->video_isoc_buffer_size = | 3895 | peasycap->video_isoc_buffer_size = |
3896 | peasycap->video_isoc_maxframesize * | 3896 | peasycap->video_isoc_maxframesize * |
3897 | peasycap->video_isoc_framesperdesc; | 3897 | peasycap->video_isoc_framesperdesc; |
3898 | JOM(4, "%i=video_isoc_buffer_size\n", | 3898 | JOM(4, "%i=video_isoc_buffer_size\n", |
3899 | peasycap->video_isoc_buffer_size); | 3899 | peasycap->video_isoc_buffer_size); |
3900 | if ((PAGE_SIZE << VIDEO_ISOC_ORDER) < | 3900 | if ((PAGE_SIZE << VIDEO_ISOC_ORDER) < |
3901 | peasycap->video_isoc_buffer_size) { | 3901 | peasycap->video_isoc_buffer_size) { |
3902 | SAM("MISTAKE: peasycap->video_isoc_buffer_size too big\n"); | 3902 | SAM("MISTAKE: peasycap->video_isoc_buffer_size too big\n"); |
3903 | return -EFAULT; | 3903 | return -EFAULT; |
3904 | } | 3904 | } |
3905 | /*---------------------------------------------------------------------------*/ | 3905 | /*---------------------------------------------------------------------------*/ |
3906 | if (-1 == peasycap->video_interface) { | 3906 | if (-1 == peasycap->video_interface) { |
3907 | SAM("MISTAKE: video_interface is unset\n"); | 3907 | SAM("MISTAKE: video_interface is unset\n"); |
3908 | return -EFAULT; | 3908 | return -EFAULT; |
3909 | } | 3909 | } |
3910 | if (-1 == peasycap->video_altsetting_on) { | 3910 | if (-1 == peasycap->video_altsetting_on) { |
3911 | SAM("MISTAKE: video_altsetting_on is unset\n"); | 3911 | SAM("MISTAKE: video_altsetting_on is unset\n"); |
3912 | return -EFAULT; | 3912 | return -EFAULT; |
3913 | } | 3913 | } |
3914 | if (-1 == peasycap->video_altsetting_off) { | 3914 | if (-1 == peasycap->video_altsetting_off) { |
3915 | SAM("MISTAKE: video_interface_off is unset\n"); | 3915 | SAM("MISTAKE: video_interface_off is unset\n"); |
3916 | return -EFAULT; | 3916 | return -EFAULT; |
3917 | } | 3917 | } |
3918 | if (-1 == peasycap->video_endpointnumber) { | 3918 | if (-1 == peasycap->video_endpointnumber) { |
3919 | SAM("MISTAKE: video_endpointnumber is unset\n"); | 3919 | SAM("MISTAKE: video_endpointnumber is unset\n"); |
3920 | return -EFAULT; | 3920 | return -EFAULT; |
3921 | } | 3921 | } |
3922 | if (-1 == peasycap->video_isoc_maxframesize) { | 3922 | if (-1 == peasycap->video_isoc_maxframesize) { |
3923 | SAM("MISTAKE: video_isoc_maxframesize is unset\n"); | 3923 | SAM("MISTAKE: video_isoc_maxframesize is unset\n"); |
3924 | return -EFAULT; | 3924 | return -EFAULT; |
3925 | } | 3925 | } |
3926 | if (-1 == peasycap->video_isoc_buffer_size) { | 3926 | if (-1 == peasycap->video_isoc_buffer_size) { |
3927 | SAM("MISTAKE: video_isoc_buffer_size is unset\n"); | 3927 | SAM("MISTAKE: video_isoc_buffer_size is unset\n"); |
3928 | return -EFAULT; | 3928 | return -EFAULT; |
3929 | } | 3929 | } |
3930 | /*---------------------------------------------------------------------------*/ | 3930 | /*---------------------------------------------------------------------------*/ |
3931 | /* | 3931 | /* |
3932 | * ALLOCATE MEMORY FOR VIDEO BUFFERS. LISTS MUST BE INITIALIZED FIRST. | 3932 | * ALLOCATE MEMORY FOR VIDEO BUFFERS. LISTS MUST BE INITIALIZED FIRST. |
3933 | */ | 3933 | */ |
3934 | /*---------------------------------------------------------------------------*/ | 3934 | /*---------------------------------------------------------------------------*/ |
3935 | INIT_LIST_HEAD(&(peasycap->urb_video_head)); | 3935 | INIT_LIST_HEAD(&(peasycap->urb_video_head)); |
3936 | peasycap->purb_video_head = &(peasycap->urb_video_head); | 3936 | peasycap->purb_video_head = &(peasycap->urb_video_head); |
3937 | /*---------------------------------------------------------------------------*/ | 3937 | /*---------------------------------------------------------------------------*/ |
3938 | JOM(4, "allocating %i frame buffers of size %li\n", | 3938 | JOM(4, "allocating %i frame buffers of size %li\n", |
3939 | FRAME_BUFFER_MANY, (long int)FRAME_BUFFER_SIZE); | 3939 | FRAME_BUFFER_MANY, (long int)FRAME_BUFFER_SIZE); |
3940 | JOM(4, ".... each scattered over %li pages\n", | 3940 | JOM(4, ".... each scattered over %li pages\n", |
3941 | FRAME_BUFFER_SIZE/PAGE_SIZE); | 3941 | FRAME_BUFFER_SIZE/PAGE_SIZE); |
3942 | 3942 | ||
3943 | for (k = 0; k < FRAME_BUFFER_MANY; k++) { | 3943 | for (k = 0; k < FRAME_BUFFER_MANY; k++) { |
3944 | for (m = 0; m < FRAME_BUFFER_SIZE/PAGE_SIZE; m++) { | 3944 | for (m = 0; m < FRAME_BUFFER_SIZE/PAGE_SIZE; m++) { |
3945 | if (NULL != peasycap->frame_buffer[k][m].pgo) | 3945 | if (NULL != peasycap->frame_buffer[k][m].pgo) |
3946 | SAM("attempting to reallocate frame " | 3946 | SAM("attempting to reallocate frame " |
3947 | " buffers\n"); | 3947 | " buffers\n"); |
3948 | else { | 3948 | else { |
3949 | pbuf = (void *)__get_free_page(GFP_KERNEL); | 3949 | pbuf = (void *)__get_free_page(GFP_KERNEL); |
3950 | if (NULL == pbuf) { | 3950 | if (NULL == pbuf) { |
3951 | SAM("ERROR: Could not allocate frame " | 3951 | SAM("ERROR: Could not allocate frame " |
3952 | "buffer %i page %i\n", k, m); | 3952 | "buffer %i page %i\n", k, m); |
3953 | return -ENOMEM; | 3953 | return -ENOMEM; |
3954 | } else | 3954 | } else |
3955 | peasycap->allocation_video_page += 1; | 3955 | peasycap->allocation_video_page += 1; |
3956 | peasycap->frame_buffer[k][m].pgo = pbuf; | 3956 | peasycap->frame_buffer[k][m].pgo = pbuf; |
3957 | } | ||
3958 | peasycap->frame_buffer[k][m].pto = | ||
3959 | peasycap->frame_buffer[k][m].pgo; | ||
3957 | } | 3960 | } |
3958 | peasycap->frame_buffer[k][m].pto = | ||
3959 | peasycap->frame_buffer[k][m].pgo; | ||
3960 | } | 3961 | } |
3961 | } | ||
3962 | 3962 | ||
3963 | peasycap->frame_fill = 0; | 3963 | peasycap->frame_fill = 0; |
3964 | peasycap->frame_read = 0; | 3964 | peasycap->frame_read = 0; |
3965 | JOM(4, "allocation of frame buffers done: %i pages\n", k * | 3965 | JOM(4, "allocation of frame buffers done: %i pages\n", k * |
3966 | m); | 3966 | m); |
3967 | /*---------------------------------------------------------------------------*/ | 3967 | /*---------------------------------------------------------------------------*/ |
3968 | JOM(4, "allocating %i field buffers of size %li\n", | 3968 | JOM(4, "allocating %i field buffers of size %li\n", |
3969 | FIELD_BUFFER_MANY, (long int)FIELD_BUFFER_SIZE); | 3969 | FIELD_BUFFER_MANY, (long int)FIELD_BUFFER_SIZE); |
3970 | JOM(4, ".... each scattered over %li pages\n", | 3970 | JOM(4, ".... each scattered over %li pages\n", |
3971 | FIELD_BUFFER_SIZE/PAGE_SIZE); | 3971 | FIELD_BUFFER_SIZE/PAGE_SIZE); |
3972 | 3972 | ||
3973 | for (k = 0; k < FIELD_BUFFER_MANY; k++) { | 3973 | for (k = 0; k < FIELD_BUFFER_MANY; k++) { |
3974 | for (m = 0; m < FIELD_BUFFER_SIZE/PAGE_SIZE; m++) { | 3974 | for (m = 0; m < FIELD_BUFFER_SIZE/PAGE_SIZE; m++) { |
3975 | if (NULL != peasycap->field_buffer[k][m].pgo) { | 3975 | if (NULL != peasycap->field_buffer[k][m].pgo) { |
3976 | SAM("ERROR: attempting to reallocate " | 3976 | SAM("ERROR: attempting to reallocate " |
3977 | "field buffers\n"); | 3977 | "field buffers\n"); |
3978 | } else { | 3978 | } else { |
3979 | pbuf = (void *) __get_free_page(GFP_KERNEL); | 3979 | pbuf = (void *) __get_free_page(GFP_KERNEL); |
3980 | if (NULL == pbuf) { | 3980 | if (NULL == pbuf) { |
3981 | SAM("ERROR: Could not allocate field" | 3981 | SAM("ERROR: Could not allocate field" |
3982 | " buffer %i page %i\n", k, m); | 3982 | " buffer %i page %i\n", k, m); |
3983 | return -ENOMEM; | 3983 | return -ENOMEM; |
3984 | } | ||
3985 | else | ||
3986 | peasycap->allocation_video_page += 1; | ||
3987 | peasycap->field_buffer[k][m].pgo = pbuf; | ||
3984 | } | 3988 | } |
3985 | else | 3989 | peasycap->field_buffer[k][m].pto = |
3986 | peasycap->allocation_video_page += 1; | 3990 | peasycap->field_buffer[k][m].pgo; |
3987 | peasycap->field_buffer[k][m].pgo = pbuf; | 3991 | } |
3988 | } | 3992 | peasycap->field_buffer[k][0].kount = 0x0200; |
3989 | peasycap->field_buffer[k][m].pto = | ||
3990 | peasycap->field_buffer[k][m].pgo; | ||
3991 | } | 3993 | } |
3992 | peasycap->field_buffer[k][0].kount = 0x0200; | 3994 | peasycap->field_fill = 0; |
3993 | } | 3995 | peasycap->field_page = 0; |
3994 | peasycap->field_fill = 0; | 3996 | peasycap->field_read = 0; |
3995 | peasycap->field_page = 0; | 3997 | JOM(4, "allocation of field buffers done: %i pages\n", k * |
3996 | peasycap->field_read = 0; | 3998 | m); |
3997 | JOM(4, "allocation of field buffers done: %i pages\n", k * | 3999 | /*---------------------------------------------------------------------------*/ |
3998 | m); | 4000 | JOM(4, "allocating %i isoc video buffers of size %i\n", |
3999 | /*---------------------------------------------------------------------------*/ | 4001 | VIDEO_ISOC_BUFFER_MANY, |
4000 | JOM(4, "allocating %i isoc video buffers of size %i\n", | 4002 | peasycap->video_isoc_buffer_size); |
4001 | VIDEO_ISOC_BUFFER_MANY, | 4003 | JOM(4, ".... each occupying contiguous memory pages\n"); |
4002 | peasycap->video_isoc_buffer_size); | 4004 | |
4003 | JOM(4, ".... each occupying contiguous memory pages\n"); | 4005 | for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { |
4004 | 4006 | pbuf = (void *)__get_free_pages(GFP_KERNEL, VIDEO_ISOC_ORDER); | |
4005 | for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { | 4007 | if (NULL == pbuf) { |
4006 | pbuf = (void *)__get_free_pages(GFP_KERNEL, VIDEO_ISOC_ORDER); | 4008 | SAM("ERROR: Could not allocate isoc video buffer " |
4007 | if (NULL == pbuf) { | 4009 | "%i\n", k); |
4008 | SAM("ERROR: Could not allocate isoc video buffer " | 4010 | return -ENOMEM; |
4009 | "%i\n", k); | 4011 | } else |
4010 | return -ENOMEM; | 4012 | peasycap->allocation_video_page += |
4011 | } else | 4013 | ((unsigned int)(0x01 << VIDEO_ISOC_ORDER)); |
4012 | peasycap->allocation_video_page += | ||
4013 | ((unsigned int)(0x01 << VIDEO_ISOC_ORDER)); | ||
4014 | 4014 | ||
4015 | peasycap->video_isoc_buffer[k].pgo = pbuf; | 4015 | peasycap->video_isoc_buffer[k].pgo = pbuf; |
4016 | peasycap->video_isoc_buffer[k].pto = pbuf + | 4016 | peasycap->video_isoc_buffer[k].pto = pbuf + |
4017 | peasycap->video_isoc_buffer_size; | 4017 | peasycap->video_isoc_buffer_size; |
4018 | peasycap->video_isoc_buffer[k].kount = k; | 4018 | peasycap->video_isoc_buffer[k].kount = k; |
4019 | } | 4019 | } |
4020 | JOM(4, "allocation of isoc video buffers done: %i pages\n", | 4020 | JOM(4, "allocation of isoc video buffers done: %i pages\n", |
4021 | k * (0x01 << VIDEO_ISOC_ORDER)); | 4021 | k * (0x01 << VIDEO_ISOC_ORDER)); |
4022 | /*---------------------------------------------------------------------------*/ | 4022 | /*---------------------------------------------------------------------------*/ |
4023 | /* | 4023 | /* |
4024 | * ALLOCATE AND INITIALIZE MULTIPLE struct urb ... | 4024 | * ALLOCATE AND INITIALIZE MULTIPLE struct urb ... |
4025 | */ | 4025 | */ |
4026 | /*---------------------------------------------------------------------------*/ | 4026 | /*---------------------------------------------------------------------------*/ |
4027 | JOM(4, "allocating %i struct urb.\n", VIDEO_ISOC_BUFFER_MANY); | 4027 | JOM(4, "allocating %i struct urb.\n", VIDEO_ISOC_BUFFER_MANY); |
4028 | JOM(4, "using %i=peasycap->video_isoc_framesperdesc\n", | 4028 | JOM(4, "using %i=peasycap->video_isoc_framesperdesc\n", |
4029 | peasycap->video_isoc_framesperdesc); | 4029 | peasycap->video_isoc_framesperdesc); |
4030 | JOM(4, "using %i=peasycap->video_isoc_maxframesize\n", | 4030 | JOM(4, "using %i=peasycap->video_isoc_maxframesize\n", |
4031 | peasycap->video_isoc_maxframesize); | 4031 | peasycap->video_isoc_maxframesize); |
4032 | JOM(4, "using %i=peasycap->video_isoc_buffer_sizen", | 4032 | JOM(4, "using %i=peasycap->video_isoc_buffer_sizen", |
4033 | peasycap->video_isoc_buffer_size); | 4033 | peasycap->video_isoc_buffer_size); |
4034 | 4034 | ||
4035 | for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { | 4035 | for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { |
4036 | purb = usb_alloc_urb(peasycap->video_isoc_framesperdesc, | 4036 | purb = usb_alloc_urb(peasycap->video_isoc_framesperdesc, |
4037 | GFP_KERNEL); | 4037 | GFP_KERNEL); |
4038 | if (NULL == purb) { | 4038 | if (NULL == purb) { |
4039 | SAM("ERROR: usb_alloc_urb returned NULL for buffer " | 4039 | SAM("ERROR: usb_alloc_urb returned NULL for buffer " |
4040 | "%i\n", k); | 4040 | "%i\n", k); |
4041 | return -ENOMEM; | 4041 | return -ENOMEM; |
4042 | } else | 4042 | } else |
4043 | peasycap->allocation_video_urb += 1; | 4043 | peasycap->allocation_video_urb += 1; |
4044 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | 4044 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
4045 | pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); | 4045 | pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); |
4046 | if (NULL == pdata_urb) { | 4046 | if (NULL == pdata_urb) { |
4047 | SAM("ERROR: Could not allocate struct data_urb.\n"); | 4047 | SAM("ERROR: Could not allocate struct data_urb.\n"); |
4048 | return -ENOMEM; | 4048 | return -ENOMEM; |
4049 | } else | 4049 | } else |
4050 | peasycap->allocation_video_struct += | 4050 | peasycap->allocation_video_struct += |
4051 | sizeof(struct data_urb); | 4051 | sizeof(struct data_urb); |
4052 | 4052 | ||
4053 | pdata_urb->purb = purb; | 4053 | pdata_urb->purb = purb; |
4054 | pdata_urb->isbuf = k; | 4054 | pdata_urb->isbuf = k; |
4055 | pdata_urb->length = 0; | 4055 | pdata_urb->length = 0; |
4056 | list_add_tail(&(pdata_urb->list_head), | 4056 | list_add_tail(&(pdata_urb->list_head), |
4057 | peasycap->purb_video_head); | 4057 | peasycap->purb_video_head); |
4058 | /*---------------------------------------------------------------------------*/ | 4058 | /*---------------------------------------------------------------------------*/ |
4059 | /* | 4059 | /* |
4060 | * ... AND INITIALIZE THEM | 4060 | * ... AND INITIALIZE THEM |
4061 | */ | 4061 | */ |
4062 | /*---------------------------------------------------------------------------*/ | 4062 | /*---------------------------------------------------------------------------*/ |
4063 | if (!k) { | 4063 | if (!k) { |
4064 | JOM(4, "initializing video urbs thus:\n"); | 4064 | JOM(4, "initializing video urbs thus:\n"); |
4065 | JOM(4, " purb->interval = 1;\n"); | 4065 | JOM(4, " purb->interval = 1;\n"); |
4066 | JOM(4, " purb->dev = peasycap->pusb_device;\n"); | 4066 | JOM(4, " purb->dev = peasycap->pusb_device;\n"); |
4067 | JOM(4, " purb->pipe = usb_rcvisocpipe" | 4067 | JOM(4, " purb->pipe = usb_rcvisocpipe" |
4068 | "(peasycap->pusb_device,%i);\n", | 4068 | "(peasycap->pusb_device,%i);\n", |
4069 | peasycap->video_endpointnumber); | 4069 | peasycap->video_endpointnumber); |
4070 | JOM(4, " purb->transfer_flags = URB_ISO_ASAP;\n"); | 4070 | JOM(4, " purb->transfer_flags = URB_ISO_ASAP;\n"); |
4071 | JOM(4, " purb->transfer_buffer = peasycap->" | 4071 | JOM(4, " purb->transfer_buffer = peasycap->" |
4072 | "video_isoc_buffer[.].pgo;\n"); | 4072 | "video_isoc_buffer[.].pgo;\n"); |
4073 | JOM(4, " purb->transfer_buffer_length = %i;\n", | 4073 | JOM(4, " purb->transfer_buffer_length = %i;\n", |
4074 | peasycap->video_isoc_buffer_size); | 4074 | peasycap->video_isoc_buffer_size); |
4075 | JOM(4, " purb->complete = easycap_complete;\n"); | 4075 | JOM(4, " purb->complete = easycap_complete;\n"); |
4076 | JOM(4, " purb->context = peasycap;\n"); | 4076 | JOM(4, " purb->context = peasycap;\n"); |
4077 | JOM(4, " purb->start_frame = 0;\n"); | 4077 | JOM(4, " purb->start_frame = 0;\n"); |
4078 | JOM(4, " purb->number_of_packets = %i;\n", | 4078 | JOM(4, " purb->number_of_packets = %i;\n", |
4079 | peasycap->video_isoc_framesperdesc); | 4079 | peasycap->video_isoc_framesperdesc); |
4080 | JOM(4, " for (j = 0; j < %i; j++)\n", | 4080 | JOM(4, " for (j = 0; j < %i; j++)\n", |
4081 | peasycap->video_isoc_framesperdesc); | 4081 | peasycap->video_isoc_framesperdesc); |
4082 | JOM(4, " {\n"); | 4082 | JOM(4, " {\n"); |
4083 | JOM(4, " purb->iso_frame_desc[j].offset = j*%i;\n", | 4083 | JOM(4, " purb->iso_frame_desc[j].offset = j*%i;\n", |
4084 | peasycap->video_isoc_maxframesize); | 4084 | peasycap->video_isoc_maxframesize); |
4085 | JOM(4, " purb->iso_frame_desc[j].length = %i;\n", | 4085 | JOM(4, " purb->iso_frame_desc[j].length = %i;\n", |
4086 | peasycap->video_isoc_maxframesize); | 4086 | peasycap->video_isoc_maxframesize); |
4087 | JOM(4, " }\n"); | 4087 | JOM(4, " }\n"); |
4088 | } | 4088 | } |
4089 | 4089 | ||
4090 | purb->interval = 1; | 4090 | purb->interval = 1; |
4091 | purb->dev = peasycap->pusb_device; | 4091 | purb->dev = peasycap->pusb_device; |
4092 | purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, | 4092 | purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, |
4093 | peasycap->video_endpointnumber); | 4093 | peasycap->video_endpointnumber); |
4094 | purb->transfer_flags = URB_ISO_ASAP; | 4094 | purb->transfer_flags = URB_ISO_ASAP; |
4095 | purb->transfer_buffer = peasycap->video_isoc_buffer[k].pgo; | 4095 | purb->transfer_buffer = peasycap->video_isoc_buffer[k].pgo; |
4096 | purb->transfer_buffer_length = | 4096 | purb->transfer_buffer_length = |
4097 | peasycap->video_isoc_buffer_size; | 4097 | peasycap->video_isoc_buffer_size; |
4098 | purb->complete = easycap_complete; | 4098 | purb->complete = easycap_complete; |
4099 | purb->context = peasycap; | 4099 | purb->context = peasycap; |
4100 | purb->start_frame = 0; | 4100 | purb->start_frame = 0; |
4101 | purb->number_of_packets = peasycap->video_isoc_framesperdesc; | 4101 | purb->number_of_packets = peasycap->video_isoc_framesperdesc; |
4102 | for (j = 0; j < peasycap->video_isoc_framesperdesc; j++) { | 4102 | for (j = 0; j < peasycap->video_isoc_framesperdesc; j++) { |
4103 | purb->iso_frame_desc[j].offset = j * | 4103 | purb->iso_frame_desc[j].offset = j * |
4104 | peasycap->video_isoc_maxframesize; | 4104 | peasycap->video_isoc_maxframesize; |
4105 | purb->iso_frame_desc[j].length = | 4105 | purb->iso_frame_desc[j].length = |
4106 | peasycap->video_isoc_maxframesize; | 4106 | peasycap->video_isoc_maxframesize; |
4107 | } | ||
4107 | } | 4108 | } |
4108 | } | 4109 | JOM(4, "allocation of %i struct urb done.\n", k); |
4109 | JOM(4, "allocation of %i struct urb done.\n", k); | ||
4110 | /*--------------------------------------------------------------------------*/ | 4110 | /*--------------------------------------------------------------------------*/ |
4111 | /* | 4111 | /* |
4112 | * SAVE POINTER peasycap IN THIS INTERFACE. | 4112 | * SAVE POINTER peasycap IN THIS INTERFACE. |
4113 | */ | 4113 | */ |
4114 | /*--------------------------------------------------------------------------*/ | 4114 | /*--------------------------------------------------------------------------*/ |
4115 | usb_set_intfdata(pusb_interface, peasycap); | 4115 | usb_set_intfdata(pusb_interface, peasycap); |
4116 | /*---------------------------------------------------------------------------*/ | 4116 | /*---------------------------------------------------------------------------*/ |
4117 | /* | 4117 | /* |
4118 | * IT IS ESSENTIAL TO INITIALIZE THE HARDWARE BEFORE, RATHER THAN AFTER, | 4118 | * IT IS ESSENTIAL TO INITIALIZE THE HARDWARE BEFORE, RATHER THAN AFTER, |
@@ -4122,44 +4122,44 @@ case 0: { | |||
4122 | */ | 4122 | */ |
4123 | /*---------------------------------------------------------------------------*/ | 4123 | /*---------------------------------------------------------------------------*/ |
4124 | #ifdef PREFER_NTSC | 4124 | #ifdef PREFER_NTSC |
4125 | peasycap->ntsc = true; | 4125 | peasycap->ntsc = true; |
4126 | JOM(8, "defaulting initially to NTSC\n"); | 4126 | JOM(8, "defaulting initially to NTSC\n"); |
4127 | #else | 4127 | #else |
4128 | peasycap->ntsc = false; | 4128 | peasycap->ntsc = false; |
4129 | JOM(8, "defaulting initially to PAL\n"); | 4129 | JOM(8, "defaulting initially to PAL\n"); |
4130 | #endif /*PREFER_NTSC*/ | 4130 | #endif /*PREFER_NTSC*/ |
4131 | rc = reset(peasycap); | 4131 | rc = reset(peasycap); |
4132 | if (rc) { | 4132 | if (rc) { |
4133 | SAM("ERROR: reset() returned %i\n", rc); | 4133 | SAM("ERROR: reset() returned %i\n", rc); |
4134 | return -EFAULT; | 4134 | return -EFAULT; |
4135 | } | 4135 | } |
4136 | /*--------------------------------------------------------------------------*/ | 4136 | /*--------------------------------------------------------------------------*/ |
4137 | /* | 4137 | /* |
4138 | * THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. | 4138 | * THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. |
4139 | */ | 4139 | */ |
4140 | /*--------------------------------------------------------------------------*/ | 4140 | /*--------------------------------------------------------------------------*/ |
4141 | #ifndef EASYCAP_IS_VIDEODEV_CLIENT | 4141 | #ifndef EASYCAP_IS_VIDEODEV_CLIENT |
4142 | if (0 != (usb_register_dev(pusb_interface, &easycap_class))) { | 4142 | if (0 != (usb_register_dev(pusb_interface, &easycap_class))) { |
4143 | err("Not able to get a minor for this device"); | 4143 | err("Not able to get a minor for this device"); |
4144 | usb_set_intfdata(pusb_interface, NULL); | 4144 | usb_set_intfdata(pusb_interface, NULL); |
4145 | return -ENODEV; | 4145 | return -ENODEV; |
4146 | } else { | 4146 | } else { |
4147 | (peasycap->registered_video)++; | 4147 | (peasycap->registered_video)++; |
4148 | SAM("easycap attached to minor #%d\n", pusb_interface->minor); | 4148 | SAM("easycap attached to minor #%d\n", pusb_interface->minor); |
4149 | peasycap->minor = pusb_interface->minor; | 4149 | peasycap->minor = pusb_interface->minor; |
4150 | break; | 4150 | break; |
4151 | } | 4151 | } |
4152 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | 4152 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ |
4153 | #else | 4153 | #else |
4154 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H | 4154 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H |
4155 | if (0 != (v4l2_device_register(&(pusb_interface->dev), | 4155 | if (0 != (v4l2_device_register(&(pusb_interface->dev), |
4156 | &(peasycap->v4l2_device)))) { | 4156 | &(peasycap->v4l2_device)))) { |
4157 | SAM("v4l2_device_register() failed\n"); | 4157 | SAM("v4l2_device_register() failed\n"); |
4158 | return -ENODEV; | 4158 | return -ENODEV; |
4159 | } else { | 4159 | } else { |
4160 | JOM(4, "registered device instance: %s\n", | 4160 | JOM(4, "registered device instance: %s\n", |
4161 | &(peasycap->v4l2_device.name[0])); | 4161 | &(peasycap->v4l2_device.name[0])); |
4162 | } | 4162 | } |
4163 | /*---------------------------------------------------------------------------*/ | 4163 | /*---------------------------------------------------------------------------*/ |
4164 | /* | 4164 | /* |
4165 | * FIXME | 4165 | * FIXME |
@@ -4168,37 +4168,37 @@ case 0: { | |||
4168 | * THIS IS BELIEVED TO BE HARMLESS, BUT MAY WELL BE UNNECESSARY OR WRONG: | 4168 | * THIS IS BELIEVED TO BE HARMLESS, BUT MAY WELL BE UNNECESSARY OR WRONG: |
4169 | */ | 4169 | */ |
4170 | /*---------------------------------------------------------------------------*/ | 4170 | /*---------------------------------------------------------------------------*/ |
4171 | peasycap->video_device.v4l2_dev = NULL; | 4171 | peasycap->video_device.v4l2_dev = NULL; |
4172 | /*---------------------------------------------------------------------------*/ | 4172 | /*---------------------------------------------------------------------------*/ |
4173 | 4173 | ||
4174 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ | 4174 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ |
4175 | 4175 | ||
4176 | strcpy(&peasycap->video_device.name[0], "easycapdc60"); | 4176 | strcpy(&peasycap->video_device.name[0], "easycapdc60"); |
4177 | #ifdef EASYCAP_NEEDS_V4L2_FOPS | 4177 | #ifdef EASYCAP_NEEDS_V4L2_FOPS |
4178 | peasycap->video_device.fops = &v4l2_fops; | 4178 | peasycap->video_device.fops = &v4l2_fops; |
4179 | #else | 4179 | #else |
4180 | peasycap->video_device.fops = &easycap_fops; | 4180 | peasycap->video_device.fops = &easycap_fops; |
4181 | #endif /*EASYCAP_NEEDS_V4L2_FOPS*/ | 4181 | #endif /*EASYCAP_NEEDS_V4L2_FOPS*/ |
4182 | peasycap->video_device.minor = -1; | 4182 | peasycap->video_device.minor = -1; |
4183 | peasycap->video_device.release = (void *)(&videodev_release); | 4183 | peasycap->video_device.release = (void *)(&videodev_release); |
4184 | 4184 | ||
4185 | video_set_drvdata(&(peasycap->video_device), (void *)peasycap); | 4185 | video_set_drvdata(&(peasycap->video_device), (void *)peasycap); |
4186 | 4186 | ||
4187 | if (0 != (video_register_device(&(peasycap->video_device), | 4187 | if (0 != (video_register_device(&(peasycap->video_device), |
4188 | VFL_TYPE_GRABBER, -1))) { | 4188 | VFL_TYPE_GRABBER, -1))) { |
4189 | err("Not able to register with videodev"); | 4189 | err("Not able to register with videodev"); |
4190 | videodev_release(&(peasycap->video_device)); | 4190 | videodev_release(&(peasycap->video_device)); |
4191 | return -ENODEV; | 4191 | return -ENODEV; |
4192 | } else { | 4192 | } else { |
4193 | (peasycap->registered_video)++; | 4193 | (peasycap->registered_video)++; |
4194 | SAM("registered with videodev: %i=minor\n", | 4194 | SAM("registered with videodev: %i=minor\n", |
4195 | peasycap->video_device.minor); | 4195 | peasycap->video_device.minor); |
4196 | peasycap->minor = peasycap->video_device.minor; | 4196 | peasycap->minor = peasycap->video_device.minor; |
4197 | } | 4197 | } |
4198 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ | 4198 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ |
4199 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | 4199 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
4200 | 4200 | ||
4201 | break; | 4201 | break; |
4202 | } | 4202 | } |
4203 | /*--------------------------------------------------------------------------*/ | 4203 | /*--------------------------------------------------------------------------*/ |
4204 | /* | 4204 | /* |
@@ -4206,338 +4206,338 @@ case 0: { | |||
4206 | * INTERFACE 2 IS THE AUDIO STREAMING INTERFACE | 4206 | * INTERFACE 2 IS THE AUDIO STREAMING INTERFACE |
4207 | */ | 4207 | */ |
4208 | /*--------------------------------------------------------------------------*/ | 4208 | /*--------------------------------------------------------------------------*/ |
4209 | case 1: { | 4209 | case 1: { |
4210 | #ifdef EASYCAP_SILENT | 4210 | #ifdef EASYCAP_SILENT |
4211 | return -ENOENT; | 4211 | return -ENOENT; |
4212 | #endif /*EASYCAP_SILENT*/ | 4212 | #endif /*EASYCAP_SILENT*/ |
4213 | if (!peasycap) { | 4213 | if (!peasycap) { |
4214 | SAM("MISTAKE: peasycap is NULL\n"); | 4214 | SAM("MISTAKE: peasycap is NULL\n"); |
4215 | return -EFAULT; | 4215 | return -EFAULT; |
4216 | } | 4216 | } |
4217 | /*--------------------------------------------------------------------------*/ | 4217 | /*--------------------------------------------------------------------------*/ |
4218 | /* | 4218 | /* |
4219 | * SAVE POINTER peasycap IN INTERFACE 1 | 4219 | * SAVE POINTER peasycap IN INTERFACE 1 |
4220 | */ | 4220 | */ |
4221 | /*--------------------------------------------------------------------------*/ | 4221 | /*--------------------------------------------------------------------------*/ |
4222 | usb_set_intfdata(pusb_interface, peasycap); | 4222 | usb_set_intfdata(pusb_interface, peasycap); |
4223 | JOM(4, "no initialization required for interface %i\n", | 4223 | JOM(4, "no initialization required for interface %i\n", |
4224 | pusb_interface_descriptor->bInterfaceNumber); | 4224 | pusb_interface_descriptor->bInterfaceNumber); |
4225 | break; | 4225 | break; |
4226 | } | ||
4227 | /*--------------------------------------------------------------------------*/ | ||
4228 | case 2: { | ||
4229 | #ifdef EASYCAP_SILENT | ||
4230 | return -ENOENT; | ||
4231 | #endif /*EASYCAP_SILENT*/ | ||
4232 | if (!peasycap) { | ||
4233 | SAM("MISTAKE: peasycap is NULL\n"); | ||
4234 | return -EFAULT; | ||
4235 | } | 4226 | } |
4236 | if (!isokalt) { | 4227 | /*--------------------------------------------------------------------------*/ |
4237 | SAM("ERROR: no viable audio_altsetting_on\n"); | 4228 | case 2: { |
4229 | #ifdef EASYCAP_SILENT | ||
4238 | return -ENOENT; | 4230 | return -ENOENT; |
4239 | } else { | 4231 | #endif /*EASYCAP_SILENT*/ |
4240 | peasycap->audio_altsetting_on = okalt[isokalt - 1]; | 4232 | if (!peasycap) { |
4241 | JOM(4, "%i=audio_altsetting_on <====\n", | 4233 | SAM("MISTAKE: peasycap is NULL\n"); |
4242 | peasycap->audio_altsetting_on); | 4234 | return -EFAULT; |
4243 | } | 4235 | } |
4236 | if (!isokalt) { | ||
4237 | SAM("ERROR: no viable audio_altsetting_on\n"); | ||
4238 | return -ENOENT; | ||
4239 | } else { | ||
4240 | peasycap->audio_altsetting_on = okalt[isokalt - 1]; | ||
4241 | JOM(4, "%i=audio_altsetting_on <====\n", | ||
4242 | peasycap->audio_altsetting_on); | ||
4243 | } | ||
4244 | 4244 | ||
4245 | peasycap->audio_endpointnumber = okepn[isokalt - 1]; | 4245 | peasycap->audio_endpointnumber = okepn[isokalt - 1]; |
4246 | JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber); | 4246 | JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber); |
4247 | 4247 | ||
4248 | peasycap->audio_isoc_maxframesize = okmps[isokalt - 1]; | 4248 | peasycap->audio_isoc_maxframesize = okmps[isokalt - 1]; |
4249 | JOM(4, "%i=audio_isoc_maxframesize\n", | 4249 | JOM(4, "%i=audio_isoc_maxframesize\n", |
4250 | peasycap->audio_isoc_maxframesize); | 4250 | peasycap->audio_isoc_maxframesize); |
4251 | if (0 >= peasycap->audio_isoc_maxframesize) { | 4251 | if (0 >= peasycap->audio_isoc_maxframesize) { |
4252 | SAM("ERROR: bad audio_isoc_maxframesize\n"); | 4252 | SAM("ERROR: bad audio_isoc_maxframesize\n"); |
4253 | return -ENOENT; | 4253 | return -ENOENT; |
4254 | } | 4254 | } |
4255 | if (9 == peasycap->audio_isoc_maxframesize) { | 4255 | if (9 == peasycap->audio_isoc_maxframesize) { |
4256 | peasycap->ilk |= 0x02; | 4256 | peasycap->ilk |= 0x02; |
4257 | SAM("audio hardware is microphone\n"); | 4257 | SAM("audio hardware is microphone\n"); |
4258 | peasycap->microphone = true; | 4258 | peasycap->microphone = true; |
4259 | peasycap->audio_pages_per_fragment = PAGES_PER_AUDIO_FRAGMENT; | 4259 | peasycap->audio_pages_per_fragment = PAGES_PER_AUDIO_FRAGMENT; |
4260 | } else if (256 == peasycap->audio_isoc_maxframesize) { | 4260 | } else if (256 == peasycap->audio_isoc_maxframesize) { |
4261 | peasycap->ilk &= ~0x02; | 4261 | peasycap->ilk &= ~0x02; |
4262 | SAM("audio hardware is AC'97\n"); | 4262 | SAM("audio hardware is AC'97\n"); |
4263 | peasycap->microphone = false; | 4263 | peasycap->microphone = false; |
4264 | peasycap->audio_pages_per_fragment = PAGES_PER_AUDIO_FRAGMENT; | 4264 | peasycap->audio_pages_per_fragment = PAGES_PER_AUDIO_FRAGMENT; |
4265 | } else { | 4265 | } else { |
4266 | SAM("hardware is unidentified:\n"); | 4266 | SAM("hardware is unidentified:\n"); |
4267 | SAM("%i=audio_isoc_maxframesize\n", | 4267 | SAM("%i=audio_isoc_maxframesize\n", |
4268 | peasycap->audio_isoc_maxframesize); | 4268 | peasycap->audio_isoc_maxframesize); |
4269 | return -ENOENT; | 4269 | return -ENOENT; |
4270 | } | 4270 | } |
4271 | 4271 | ||
4272 | peasycap->audio_bytes_per_fragment = | 4272 | peasycap->audio_bytes_per_fragment = |
4273 | peasycap->audio_pages_per_fragment * | 4273 | peasycap->audio_pages_per_fragment * |
4274 | PAGE_SIZE ; | 4274 | PAGE_SIZE ; |
4275 | peasycap->audio_buffer_page_many = (AUDIO_FRAGMENT_MANY * | 4275 | peasycap->audio_buffer_page_many = (AUDIO_FRAGMENT_MANY * |
4276 | peasycap->audio_pages_per_fragment); | 4276 | peasycap->audio_pages_per_fragment); |
4277 | 4277 | ||
4278 | JOM(4, "%6i=AUDIO_FRAGMENT_MANY\n", AUDIO_FRAGMENT_MANY); | 4278 | JOM(4, "%6i=AUDIO_FRAGMENT_MANY\n", AUDIO_FRAGMENT_MANY); |
4279 | JOM(4, "%6i=audio_pages_per_fragment\n", | 4279 | JOM(4, "%6i=audio_pages_per_fragment\n", |
4280 | peasycap->audio_pages_per_fragment); | 4280 | peasycap->audio_pages_per_fragment); |
4281 | JOM(4, "%6i=audio_bytes_per_fragment\n", | 4281 | JOM(4, "%6i=audio_bytes_per_fragment\n", |
4282 | peasycap->audio_bytes_per_fragment); | 4282 | peasycap->audio_bytes_per_fragment); |
4283 | JOM(4, "%6i=audio_buffer_page_many\n", | 4283 | JOM(4, "%6i=audio_buffer_page_many\n", |
4284 | peasycap->audio_buffer_page_many); | 4284 | peasycap->audio_buffer_page_many); |
4285 | 4285 | ||
4286 | peasycap->audio_isoc_framesperdesc = AUDIO_ISOC_FRAMESPERDESC; | 4286 | peasycap->audio_isoc_framesperdesc = AUDIO_ISOC_FRAMESPERDESC; |
4287 | 4287 | ||
4288 | JOM(4, "%i=audio_isoc_framesperdesc\n", | 4288 | JOM(4, "%i=audio_isoc_framesperdesc\n", |
4289 | peasycap->audio_isoc_framesperdesc); | 4289 | peasycap->audio_isoc_framesperdesc); |
4290 | if (0 >= peasycap->audio_isoc_framesperdesc) { | 4290 | if (0 >= peasycap->audio_isoc_framesperdesc) { |
4291 | SAM("ERROR: bad audio_isoc_framesperdesc\n"); | 4291 | SAM("ERROR: bad audio_isoc_framesperdesc\n"); |
4292 | return -ENOENT; | 4292 | return -ENOENT; |
4293 | } | 4293 | } |
4294 | 4294 | ||
4295 | peasycap->audio_isoc_buffer_size = | 4295 | peasycap->audio_isoc_buffer_size = |
4296 | peasycap->audio_isoc_maxframesize * | 4296 | peasycap->audio_isoc_maxframesize * |
4297 | peasycap->audio_isoc_framesperdesc; | 4297 | peasycap->audio_isoc_framesperdesc; |
4298 | JOM(4, "%i=audio_isoc_buffer_size\n", | 4298 | JOM(4, "%i=audio_isoc_buffer_size\n", |
4299 | peasycap->audio_isoc_buffer_size); | 4299 | peasycap->audio_isoc_buffer_size); |
4300 | if (AUDIO_ISOC_BUFFER_SIZE < peasycap->audio_isoc_buffer_size) { | 4300 | if (AUDIO_ISOC_BUFFER_SIZE < peasycap->audio_isoc_buffer_size) { |
4301 | SAM("MISTAKE: audio_isoc_buffer_size bigger " | 4301 | SAM("MISTAKE: audio_isoc_buffer_size bigger " |
4302 | "than %li=AUDIO_ISOC_BUFFER_SIZE\n", | 4302 | "than %li=AUDIO_ISOC_BUFFER_SIZE\n", |
4303 | AUDIO_ISOC_BUFFER_SIZE); | 4303 | AUDIO_ISOC_BUFFER_SIZE); |
4304 | return -EFAULT; | 4304 | return -EFAULT; |
4305 | } | 4305 | } |
4306 | if (-1 == peasycap->audio_interface) { | 4306 | if (-1 == peasycap->audio_interface) { |
4307 | SAM("MISTAKE: audio_interface is unset\n"); | 4307 | SAM("MISTAKE: audio_interface is unset\n"); |
4308 | return -EFAULT; | 4308 | return -EFAULT; |
4309 | } | 4309 | } |
4310 | if (-1 == peasycap->audio_altsetting_on) { | 4310 | if (-1 == peasycap->audio_altsetting_on) { |
4311 | SAM("MISTAKE: audio_altsetting_on is unset\n"); | 4311 | SAM("MISTAKE: audio_altsetting_on is unset\n"); |
4312 | return -EFAULT; | 4312 | return -EFAULT; |
4313 | } | 4313 | } |
4314 | if (-1 == peasycap->audio_altsetting_off) { | 4314 | if (-1 == peasycap->audio_altsetting_off) { |
4315 | SAM("MISTAKE: audio_interface_off is unset\n"); | 4315 | SAM("MISTAKE: audio_interface_off is unset\n"); |
4316 | return -EFAULT; | 4316 | return -EFAULT; |
4317 | } | 4317 | } |
4318 | if (-1 == peasycap->audio_endpointnumber) { | 4318 | if (-1 == peasycap->audio_endpointnumber) { |
4319 | SAM("MISTAKE: audio_endpointnumber is unset\n"); | 4319 | SAM("MISTAKE: audio_endpointnumber is unset\n"); |
4320 | return -EFAULT; | 4320 | return -EFAULT; |
4321 | } | 4321 | } |
4322 | if (-1 == peasycap->audio_isoc_maxframesize) { | 4322 | if (-1 == peasycap->audio_isoc_maxframesize) { |
4323 | SAM("MISTAKE: audio_isoc_maxframesize is unset\n"); | 4323 | SAM("MISTAKE: audio_isoc_maxframesize is unset\n"); |
4324 | return -EFAULT; | 4324 | return -EFAULT; |
4325 | } | 4325 | } |
4326 | if (-1 == peasycap->audio_isoc_buffer_size) { | 4326 | if (-1 == peasycap->audio_isoc_buffer_size) { |
4327 | SAM("MISTAKE: audio_isoc_buffer_size is unset\n"); | 4327 | SAM("MISTAKE: audio_isoc_buffer_size is unset\n"); |
4328 | return -EFAULT; | 4328 | return -EFAULT; |
4329 | } | 4329 | } |
4330 | /*---------------------------------------------------------------------------*/ | 4330 | /*---------------------------------------------------------------------------*/ |
4331 | /* | 4331 | /* |
4332 | * ALLOCATE MEMORY FOR AUDIO BUFFERS. LISTS MUST BE INITIALIZED FIRST. | 4332 | * ALLOCATE MEMORY FOR AUDIO BUFFERS. LISTS MUST BE INITIALIZED FIRST. |
4333 | */ | 4333 | */ |
4334 | /*---------------------------------------------------------------------------*/ | 4334 | /*---------------------------------------------------------------------------*/ |
4335 | INIT_LIST_HEAD(&(peasycap->urb_audio_head)); | 4335 | INIT_LIST_HEAD(&(peasycap->urb_audio_head)); |
4336 | peasycap->purb_audio_head = &(peasycap->urb_audio_head); | 4336 | peasycap->purb_audio_head = &(peasycap->urb_audio_head); |
4337 | 4337 | ||
4338 | #ifdef CONFIG_EASYCAP_OSS | 4338 | #ifdef CONFIG_EASYCAP_OSS |
4339 | JOM(4, "allocating an audio buffer\n"); | 4339 | JOM(4, "allocating an audio buffer\n"); |
4340 | JOM(4, ".... scattered over %i pages\n", | 4340 | JOM(4, ".... scattered over %i pages\n", |
4341 | peasycap->audio_buffer_page_many); | 4341 | peasycap->audio_buffer_page_many); |
4342 | 4342 | ||
4343 | for (k = 0; k < peasycap->audio_buffer_page_many; k++) { | 4343 | for (k = 0; k < peasycap->audio_buffer_page_many; k++) { |
4344 | if (NULL != peasycap->audio_buffer[k].pgo) { | 4344 | if (NULL != peasycap->audio_buffer[k].pgo) { |
4345 | SAM("ERROR: attempting to reallocate audio buffers\n"); | 4345 | SAM("ERROR: attempting to reallocate audio buffers\n"); |
4346 | } else { | 4346 | } else { |
4347 | pbuf = (void *) __get_free_page(GFP_KERNEL); | 4347 | pbuf = (void *) __get_free_page(GFP_KERNEL); |
4348 | if (NULL == pbuf) { | 4348 | if (NULL == pbuf) { |
4349 | SAM("ERROR: Could not allocate audio " | 4349 | SAM("ERROR: Could not allocate audio " |
4350 | "buffer page %i\n", k); | 4350 | "buffer page %i\n", k); |
4351 | return -ENOMEM; | 4351 | return -ENOMEM; |
4352 | } else | 4352 | } else |
4353 | peasycap->allocation_audio_page += 1; | 4353 | peasycap->allocation_audio_page += 1; |
4354 | 4354 | ||
4355 | peasycap->audio_buffer[k].pgo = pbuf; | 4355 | peasycap->audio_buffer[k].pgo = pbuf; |
4356 | } | ||
4357 | peasycap->audio_buffer[k].pto = peasycap->audio_buffer[k].pgo; | ||
4356 | } | 4358 | } |
4357 | peasycap->audio_buffer[k].pto = peasycap->audio_buffer[k].pgo; | ||
4358 | } | ||
4359 | 4359 | ||
4360 | peasycap->audio_fill = 0; | 4360 | peasycap->audio_fill = 0; |
4361 | peasycap->audio_read = 0; | 4361 | peasycap->audio_read = 0; |
4362 | JOM(4, "allocation of audio buffer done: %i pages\n", k); | 4362 | JOM(4, "allocation of audio buffer done: %i pages\n", k); |
4363 | #endif /* CONFIG_EASYCAP_OSS */ | 4363 | #endif /* CONFIG_EASYCAP_OSS */ |
4364 | /*---------------------------------------------------------------------------*/ | 4364 | /*---------------------------------------------------------------------------*/ |
4365 | JOM(4, "allocating %i isoc audio buffers of size %i\n", | 4365 | JOM(4, "allocating %i isoc audio buffers of size %i\n", |
4366 | AUDIO_ISOC_BUFFER_MANY, peasycap->audio_isoc_buffer_size); | 4366 | AUDIO_ISOC_BUFFER_MANY, peasycap->audio_isoc_buffer_size); |
4367 | JOM(4, ".... each occupying contiguous memory pages\n"); | 4367 | JOM(4, ".... each occupying contiguous memory pages\n"); |
4368 | 4368 | ||
4369 | for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { | 4369 | for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { |
4370 | pbuf = (void *)__get_free_pages(GFP_KERNEL, AUDIO_ISOC_ORDER); | 4370 | pbuf = (void *)__get_free_pages(GFP_KERNEL, AUDIO_ISOC_ORDER); |
4371 | if (NULL == pbuf) { | 4371 | if (NULL == pbuf) { |
4372 | SAM("ERROR: Could not allocate isoc audio buffer " | 4372 | SAM("ERROR: Could not allocate isoc audio buffer " |
4373 | "%i\n", k); | 4373 | "%i\n", k); |
4374 | return -ENOMEM; | 4374 | return -ENOMEM; |
4375 | } else | 4375 | } else |
4376 | peasycap->allocation_audio_page += | 4376 | peasycap->allocation_audio_page += |
4377 | ((unsigned int)(0x01 << AUDIO_ISOC_ORDER)); | 4377 | ((unsigned int)(0x01 << AUDIO_ISOC_ORDER)); |
4378 | 4378 | ||
4379 | peasycap->audio_isoc_buffer[k].pgo = pbuf; | 4379 | peasycap->audio_isoc_buffer[k].pgo = pbuf; |
4380 | peasycap->audio_isoc_buffer[k].pto = pbuf + | 4380 | peasycap->audio_isoc_buffer[k].pto = pbuf + |
4381 | peasycap->audio_isoc_buffer_size; | 4381 | peasycap->audio_isoc_buffer_size; |
4382 | peasycap->audio_isoc_buffer[k].kount = k; | 4382 | peasycap->audio_isoc_buffer[k].kount = k; |
4383 | } | 4383 | } |
4384 | JOM(4, "allocation of isoc audio buffers done.\n"); | 4384 | JOM(4, "allocation of isoc audio buffers done.\n"); |
4385 | /*---------------------------------------------------------------------------*/ | 4385 | /*---------------------------------------------------------------------------*/ |
4386 | /* | 4386 | /* |
4387 | * ALLOCATE AND INITIALIZE MULTIPLE struct urb ... | 4387 | * ALLOCATE AND INITIALIZE MULTIPLE struct urb ... |
4388 | */ | 4388 | */ |
4389 | /*---------------------------------------------------------------------------*/ | 4389 | /*---------------------------------------------------------------------------*/ |
4390 | JOM(4, "allocating %i struct urb.\n", AUDIO_ISOC_BUFFER_MANY); | 4390 | JOM(4, "allocating %i struct urb.\n", AUDIO_ISOC_BUFFER_MANY); |
4391 | JOM(4, "using %i=peasycap->audio_isoc_framesperdesc\n", | 4391 | JOM(4, "using %i=peasycap->audio_isoc_framesperdesc\n", |
4392 | peasycap->audio_isoc_framesperdesc); | 4392 | peasycap->audio_isoc_framesperdesc); |
4393 | JOM(4, "using %i=peasycap->audio_isoc_maxframesize\n", | 4393 | JOM(4, "using %i=peasycap->audio_isoc_maxframesize\n", |
4394 | peasycap->audio_isoc_maxframesize); | 4394 | peasycap->audio_isoc_maxframesize); |
4395 | JOM(4, "using %i=peasycap->audio_isoc_buffer_size\n", | 4395 | JOM(4, "using %i=peasycap->audio_isoc_buffer_size\n", |
4396 | peasycap->audio_isoc_buffer_size); | 4396 | peasycap->audio_isoc_buffer_size); |
4397 | 4397 | ||
4398 | for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { | 4398 | for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { |
4399 | purb = usb_alloc_urb(peasycap->audio_isoc_framesperdesc, | 4399 | purb = usb_alloc_urb(peasycap->audio_isoc_framesperdesc, |
4400 | GFP_KERNEL); | 4400 | GFP_KERNEL); |
4401 | if (NULL == purb) { | 4401 | if (NULL == purb) { |
4402 | SAM("ERROR: usb_alloc_urb returned NULL for buffer " | 4402 | SAM("ERROR: usb_alloc_urb returned NULL for buffer " |
4403 | "%i\n", k); | 4403 | "%i\n", k); |
4404 | return -ENOMEM; | 4404 | return -ENOMEM; |
4405 | } else | 4405 | } else |
4406 | peasycap->allocation_audio_urb += 1 ; | 4406 | peasycap->allocation_audio_urb += 1 ; |
4407 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | 4407 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
4408 | pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); | 4408 | pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); |
4409 | if (NULL == pdata_urb) { | 4409 | if (NULL == pdata_urb) { |
4410 | SAM("ERROR: Could not allocate struct data_urb.\n"); | 4410 | SAM("ERROR: Could not allocate struct data_urb.\n"); |
4411 | return -ENOMEM; | 4411 | return -ENOMEM; |
4412 | } else | 4412 | } else |
4413 | peasycap->allocation_audio_struct += | 4413 | peasycap->allocation_audio_struct += |
4414 | sizeof(struct data_urb); | 4414 | sizeof(struct data_urb); |
4415 | 4415 | ||
4416 | pdata_urb->purb = purb; | 4416 | pdata_urb->purb = purb; |
4417 | pdata_urb->isbuf = k; | 4417 | pdata_urb->isbuf = k; |
4418 | pdata_urb->length = 0; | 4418 | pdata_urb->length = 0; |
4419 | list_add_tail(&(pdata_urb->list_head), | 4419 | list_add_tail(&(pdata_urb->list_head), |
4420 | peasycap->purb_audio_head); | 4420 | peasycap->purb_audio_head); |
4421 | /*---------------------------------------------------------------------------*/ | 4421 | /*---------------------------------------------------------------------------*/ |
4422 | /* | 4422 | /* |
4423 | * ... AND INITIALIZE THEM | 4423 | * ... AND INITIALIZE THEM |
4424 | */ | 4424 | */ |
4425 | /*---------------------------------------------------------------------------*/ | 4425 | /*---------------------------------------------------------------------------*/ |
4426 | if (!k) { | 4426 | if (!k) { |
4427 | JOM(4, "initializing audio urbs thus:\n"); | 4427 | JOM(4, "initializing audio urbs thus:\n"); |
4428 | JOM(4, " purb->interval = 1;\n"); | 4428 | JOM(4, " purb->interval = 1;\n"); |
4429 | JOM(4, " purb->dev = peasycap->pusb_device;\n"); | 4429 | JOM(4, " purb->dev = peasycap->pusb_device;\n"); |
4430 | JOM(4, " purb->pipe = usb_rcvisocpipe(peasycap->" | 4430 | JOM(4, " purb->pipe = usb_rcvisocpipe(peasycap->" |
4431 | "pusb_device,%i);\n", | 4431 | "pusb_device,%i);\n", |
4432 | peasycap->audio_endpointnumber); | 4432 | peasycap->audio_endpointnumber); |
4433 | JOM(4, " purb->transfer_flags = URB_ISO_ASAP;\n"); | 4433 | JOM(4, " purb->transfer_flags = URB_ISO_ASAP;\n"); |
4434 | JOM(4, " purb->transfer_buffer = " | 4434 | JOM(4, " purb->transfer_buffer = " |
4435 | "peasycap->audio_isoc_buffer[.].pgo;\n"); | 4435 | "peasycap->audio_isoc_buffer[.].pgo;\n"); |
4436 | JOM(4, " purb->transfer_buffer_length = %i;\n", | 4436 | JOM(4, " purb->transfer_buffer_length = %i;\n", |
4437 | peasycap->audio_isoc_buffer_size); | 4437 | peasycap->audio_isoc_buffer_size); |
4438 | #ifdef CONFIG_EASYCAP_OSS | 4438 | #ifdef CONFIG_EASYCAP_OSS |
4439 | JOM(4, " purb->complete = easyoss_complete;\n"); | 4439 | JOM(4, " purb->complete = easyoss_complete;\n"); |
4440 | #else /* CONFIG_EASYCAP_OSS */ | 4440 | #else /* CONFIG_EASYCAP_OSS */ |
4441 | JOM(4, " purb->complete = easycap_alsa_complete;\n"); | 4441 | JOM(4, " purb->complete = easycap_alsa_complete;\n"); |
4442 | #endif /* CONFIG_EASYCAP_OSS */ | 4442 | #endif /* CONFIG_EASYCAP_OSS */ |
4443 | JOM(4, " purb->context = peasycap;\n"); | 4443 | JOM(4, " purb->context = peasycap;\n"); |
4444 | JOM(4, " purb->start_frame = 0;\n"); | 4444 | JOM(4, " purb->start_frame = 0;\n"); |
4445 | JOM(4, " purb->number_of_packets = %i;\n", | 4445 | JOM(4, " purb->number_of_packets = %i;\n", |
4446 | peasycap->audio_isoc_framesperdesc); | 4446 | peasycap->audio_isoc_framesperdesc); |
4447 | JOM(4, " for (j = 0; j < %i; j++)\n", | 4447 | JOM(4, " for (j = 0; j < %i; j++)\n", |
4448 | peasycap->audio_isoc_framesperdesc); | 4448 | peasycap->audio_isoc_framesperdesc); |
4449 | JOM(4, " {\n"); | 4449 | JOM(4, " {\n"); |
4450 | JOM(4, " purb->iso_frame_desc[j].offset = j*%i;\n", | 4450 | JOM(4, " purb->iso_frame_desc[j].offset = j*%i;\n", |
4451 | peasycap->audio_isoc_maxframesize); | 4451 | peasycap->audio_isoc_maxframesize); |
4452 | JOM(4, " purb->iso_frame_desc[j].length = %i;\n", | 4452 | JOM(4, " purb->iso_frame_desc[j].length = %i;\n", |
4453 | peasycap->audio_isoc_maxframesize); | 4453 | peasycap->audio_isoc_maxframesize); |
4454 | JOM(4, " }\n"); | 4454 | JOM(4, " }\n"); |
4455 | } | 4455 | } |
4456 | 4456 | ||
4457 | purb->interval = 1; | 4457 | purb->interval = 1; |
4458 | purb->dev = peasycap->pusb_device; | 4458 | purb->dev = peasycap->pusb_device; |
4459 | purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, | 4459 | purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, |
4460 | peasycap->audio_endpointnumber); | 4460 | peasycap->audio_endpointnumber); |
4461 | purb->transfer_flags = URB_ISO_ASAP; | 4461 | purb->transfer_flags = URB_ISO_ASAP; |
4462 | purb->transfer_buffer = peasycap->audio_isoc_buffer[k].pgo; | 4462 | purb->transfer_buffer = peasycap->audio_isoc_buffer[k].pgo; |
4463 | purb->transfer_buffer_length = | 4463 | purb->transfer_buffer_length = |
4464 | peasycap->audio_isoc_buffer_size; | 4464 | peasycap->audio_isoc_buffer_size; |
4465 | #ifdef CONFIG_EASYCAP_OSS | 4465 | #ifdef CONFIG_EASYCAP_OSS |
4466 | purb->complete = easyoss_complete; | 4466 | purb->complete = easyoss_complete; |
4467 | #else /* CONFIG_EASYCAP_OSS */ | 4467 | #else /* CONFIG_EASYCAP_OSS */ |
4468 | purb->complete = easycap_alsa_complete; | 4468 | purb->complete = easycap_alsa_complete; |
4469 | #endif /* CONFIG_EASYCAP_OSS */ | 4469 | #endif /* CONFIG_EASYCAP_OSS */ |
4470 | purb->context = peasycap; | 4470 | purb->context = peasycap; |
4471 | purb->start_frame = 0; | 4471 | purb->start_frame = 0; |
4472 | purb->number_of_packets = peasycap->audio_isoc_framesperdesc; | 4472 | purb->number_of_packets = peasycap->audio_isoc_framesperdesc; |
4473 | for (j = 0; j < peasycap->audio_isoc_framesperdesc; j++) { | 4473 | for (j = 0; j < peasycap->audio_isoc_framesperdesc; j++) { |
4474 | purb->iso_frame_desc[j].offset = j * | 4474 | purb->iso_frame_desc[j].offset = j * |
4475 | peasycap->audio_isoc_maxframesize; | 4475 | peasycap->audio_isoc_maxframesize; |
4476 | purb->iso_frame_desc[j].length = | 4476 | purb->iso_frame_desc[j].length = |
4477 | peasycap->audio_isoc_maxframesize; | 4477 | peasycap->audio_isoc_maxframesize; |
4478 | } | ||
4478 | } | 4479 | } |
4479 | } | 4480 | JOM(4, "allocation of %i struct urb done.\n", k); |
4480 | JOM(4, "allocation of %i struct urb done.\n", k); | ||
4481 | /*---------------------------------------------------------------------------*/ | 4481 | /*---------------------------------------------------------------------------*/ |
4482 | /* | 4482 | /* |
4483 | * SAVE POINTER peasycap IN THIS INTERFACE. | 4483 | * SAVE POINTER peasycap IN THIS INTERFACE. |
4484 | */ | 4484 | */ |
4485 | /*---------------------------------------------------------------------------*/ | 4485 | /*---------------------------------------------------------------------------*/ |
4486 | usb_set_intfdata(pusb_interface, peasycap); | 4486 | usb_set_intfdata(pusb_interface, peasycap); |
4487 | /*---------------------------------------------------------------------------*/ | 4487 | /*---------------------------------------------------------------------------*/ |
4488 | /* | 4488 | /* |
4489 | * THE AUDIO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. | 4489 | * THE AUDIO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. |
4490 | */ | 4490 | */ |
4491 | /*---------------------------------------------------------------------------*/ | 4491 | /*---------------------------------------------------------------------------*/ |
4492 | #ifndef CONFIG_EASYCAP_OSS | 4492 | #ifndef CONFIG_EASYCAP_OSS |
4493 | JOM(4, "initializing ALSA card\n"); | 4493 | JOM(4, "initializing ALSA card\n"); |
4494 | 4494 | ||
4495 | rc = easycap_alsa_probe(peasycap); | 4495 | rc = easycap_alsa_probe(peasycap); |
4496 | if (rc) { | 4496 | if (rc) { |
4497 | err("easycap_alsa_probe() returned %i\n", rc); | 4497 | err("easycap_alsa_probe() returned %i\n", rc); |
4498 | return -ENODEV; | 4498 | return -ENODEV; |
4499 | } else { | 4499 | } else { |
4500 | JOM(8, "kref_get() with %i=peasycap->kref.refcount.counter\n", | 4500 | JOM(8, "kref_get() with %i=peasycap->kref.refcount.counter\n", |
4501 | (int)peasycap->kref.refcount.counter); | 4501 | (int)peasycap->kref.refcount.counter); |
4502 | kref_get(&peasycap->kref); | 4502 | kref_get(&peasycap->kref); |
4503 | (peasycap->registered_audio)++; | 4503 | (peasycap->registered_audio)++; |
4504 | } | 4504 | } |
4505 | 4505 | ||
4506 | #else /* CONFIG_EASYCAP_OSS */ | 4506 | #else /* CONFIG_EASYCAP_OSS */ |
4507 | rc = usb_register_dev(pusb_interface, &easyoss_class); | 4507 | rc = usb_register_dev(pusb_interface, &easyoss_class); |
4508 | if (rc) { | 4508 | if (rc) { |
4509 | SAY("ERROR: usb_register_dev() failed\n"); | 4509 | SAY("ERROR: usb_register_dev() failed\n"); |
4510 | usb_set_intfdata(pusb_interface, NULL); | 4510 | usb_set_intfdata(pusb_interface, NULL); |
4511 | return -ENODEV; | 4511 | return -ENODEV; |
4512 | } else { | 4512 | } else { |
4513 | JOM(8, "kref_get() with %i=peasycap->kref.refcount.counter\n", | 4513 | JOM(8, "kref_get() with %i=peasycap->kref.refcount.counter\n", |
4514 | (int)peasycap->kref.refcount.counter); | 4514 | (int)peasycap->kref.refcount.counter); |
4515 | kref_get(&peasycap->kref); | 4515 | kref_get(&peasycap->kref); |
4516 | (peasycap->registered_audio)++; | 4516 | (peasycap->registered_audio)++; |
4517 | } | 4517 | } |
4518 | /*---------------------------------------------------------------------------*/ | 4518 | /*---------------------------------------------------------------------------*/ |
4519 | /* | 4519 | /* |
4520 | * LET THE USER KNOW WHAT NODE THE AUDIO DEVICE IS ATTACHED TO. | 4520 | * LET THE USER KNOW WHAT NODE THE AUDIO DEVICE IS ATTACHED TO. |
4521 | */ | 4521 | */ |
4522 | /*---------------------------------------------------------------------------*/ | 4522 | /*---------------------------------------------------------------------------*/ |
4523 | SAM("easyoss attached to minor #%d\n", pusb_interface->minor); | 4523 | SAM("easyoss attached to minor #%d\n", pusb_interface->minor); |
4524 | #endif /* CONFIG_EASYCAP_OSS */ | 4524 | #endif /* CONFIG_EASYCAP_OSS */ |
4525 | 4525 | ||
4526 | break; | 4526 | break; |
4527 | } | 4527 | } |
4528 | /*---------------------------------------------------------------------------*/ | 4528 | /*---------------------------------------------------------------------------*/ |
4529 | /* | 4529 | /* |
4530 | * INTERFACES OTHER THAN 0, 1 AND 2 ARE UNEXPECTED | 4530 | * INTERFACES OTHER THAN 0, 1 AND 2 ARE UNEXPECTED |
4531 | */ | 4531 | */ |
4532 | /*---------------------------------------------------------------------------*/ | 4532 | /*---------------------------------------------------------------------------*/ |
4533 | default: { | 4533 | default: { |
4534 | JOM(4, "ERROR: unexpected interface %i\n", bInterfaceNumber); | 4534 | JOM(4, "ERROR: unexpected interface %i\n", bInterfaceNumber); |
4535 | return -EINVAL; | 4535 | return -EINVAL; |
4536 | } | 4536 | } |
4537 | } | 4537 | } |
4538 | SAM("ends successfully for interface %i\n", | 4538 | SAM("ends successfully for interface %i\n", |
4539 | pusb_interface_descriptor->bInterfaceNumber); | 4539 | pusb_interface_descriptor->bInterfaceNumber); |
4540 | return 0; | 4540 | return 0; |
4541 | } | 4541 | } |
4542 | /*****************************************************************************/ | 4542 | /*****************************************************************************/ |
4543 | /*---------------------------------------------------------------------------*/ | 4543 | /*---------------------------------------------------------------------------*/ |
@@ -4550,50 +4550,50 @@ return 0; | |||
4550 | /*---------------------------------------------------------------------------*/ | 4550 | /*---------------------------------------------------------------------------*/ |
4551 | static void easycap_usb_disconnect(struct usb_interface *pusb_interface) | 4551 | static void easycap_usb_disconnect(struct usb_interface *pusb_interface) |
4552 | { | 4552 | { |
4553 | struct usb_host_interface *pusb_host_interface; | 4553 | struct usb_host_interface *pusb_host_interface; |
4554 | struct usb_interface_descriptor *pusb_interface_descriptor; | 4554 | struct usb_interface_descriptor *pusb_interface_descriptor; |
4555 | u8 bInterfaceNumber; | 4555 | u8 bInterfaceNumber; |
4556 | struct easycap *peasycap; | 4556 | struct easycap *peasycap; |
4557 | 4557 | ||
4558 | struct list_head *plist_head; | 4558 | struct list_head *plist_head; |
4559 | struct data_urb *pdata_urb; | 4559 | struct data_urb *pdata_urb; |
4560 | int minor, m, kd; | 4560 | int minor, m, kd; |
4561 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ | 4561 | /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ |
4562 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT | 4562 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT |
4563 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H | 4563 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H |
4564 | struct v4l2_device *pv4l2_device; | 4564 | struct v4l2_device *pv4l2_device; |
4565 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ | 4565 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ |
4566 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ | 4566 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ |
4567 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | 4567 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
4568 | 4568 | ||
4569 | JOT(4, "\n"); | 4569 | JOT(4, "\n"); |
4570 | 4570 | ||
4571 | if (NULL == pusb_interface) { | 4571 | if (NULL == pusb_interface) { |
4572 | JOT(4, "ERROR: pusb_interface is NULL\n"); | 4572 | JOT(4, "ERROR: pusb_interface is NULL\n"); |
4573 | return; | 4573 | return; |
4574 | } | 4574 | } |
4575 | pusb_host_interface = pusb_interface->cur_altsetting; | 4575 | pusb_host_interface = pusb_interface->cur_altsetting; |
4576 | if (NULL == pusb_host_interface) { | 4576 | if (NULL == pusb_host_interface) { |
4577 | JOT(4, "ERROR: pusb_host_interface is NULL\n"); | 4577 | JOT(4, "ERROR: pusb_host_interface is NULL\n"); |
4578 | return; | 4578 | return; |
4579 | } | 4579 | } |
4580 | pusb_interface_descriptor = &(pusb_host_interface->desc); | 4580 | pusb_interface_descriptor = &(pusb_host_interface->desc); |
4581 | if (NULL == pusb_interface_descriptor) { | 4581 | if (NULL == pusb_interface_descriptor) { |
4582 | JOT(4, "ERROR: pusb_interface_descriptor is NULL\n"); | 4582 | JOT(4, "ERROR: pusb_interface_descriptor is NULL\n"); |
4583 | return; | 4583 | return; |
4584 | } | 4584 | } |
4585 | bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; | 4585 | bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; |
4586 | minor = pusb_interface->minor; | 4586 | minor = pusb_interface->minor; |
4587 | JOT(4, "intf[%i]: minor=%i\n", bInterfaceNumber, minor); | 4587 | JOT(4, "intf[%i]: minor=%i\n", bInterfaceNumber, minor); |
4588 | 4588 | ||
4589 | if (1 == bInterfaceNumber) | 4589 | if (1 == bInterfaceNumber) |
4590 | return; | 4590 | return; |
4591 | 4591 | ||
4592 | peasycap = usb_get_intfdata(pusb_interface); | 4592 | peasycap = usb_get_intfdata(pusb_interface); |
4593 | if (NULL == peasycap) { | 4593 | if (NULL == peasycap) { |
4594 | SAY("ERROR: peasycap is NULL\n"); | 4594 | SAY("ERROR: peasycap is NULL\n"); |
4595 | return; | 4595 | return; |
4596 | } | 4596 | } |
4597 | /*---------------------------------------------------------------------------*/ | 4597 | /*---------------------------------------------------------------------------*/ |
4598 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT | 4598 | #ifdef EASYCAP_IS_VIDEODEV_CLIENT |
4599 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H | 4599 | #ifdef EASYCAP_NEEDS_V4L2_DEVICE_H |
@@ -4605,77 +4605,77 @@ if (NULL == peasycap) { | |||
4605 | * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED. | 4605 | * TO DETECT THIS, THE STRING IN THE easycap.telltale[] BUFFER IS CHECKED. |
4606 | */ | 4606 | */ |
4607 | /*---------------------------------------------------------------------------*/ | 4607 | /*---------------------------------------------------------------------------*/ |
4608 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 4608 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
4609 | pv4l2_device = usb_get_intfdata(pusb_interface); | 4609 | pv4l2_device = usb_get_intfdata(pusb_interface); |
4610 | if (NULL == pv4l2_device) { | 4610 | if (NULL == pv4l2_device) { |
4611 | SAY("ERROR: pv4l2_device is NULL\n"); | 4611 | SAY("ERROR: pv4l2_device is NULL\n"); |
4612 | return; | 4612 | return; |
4613 | } | ||
4614 | peasycap = (struct easycap *) | ||
4615 | container_of(pv4l2_device, struct easycap, v4l2_device); | ||
4613 | } | 4616 | } |
4614 | peasycap = (struct easycap *) | ||
4615 | container_of(pv4l2_device, struct easycap, v4l2_device); | ||
4616 | } | ||
4617 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ | 4617 | #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ |
4618 | # | 4618 | # |
4619 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ | 4619 | #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ |
4620 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ | 4620 | /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ |
4621 | /*---------------------------------------------------------------------------*/ | 4621 | /*---------------------------------------------------------------------------*/ |
4622 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 4622 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
4623 | SAY("ERROR: bad peasycap: 0x%08lX\n", (unsigned long int) peasycap); | 4623 | SAY("ERROR: bad peasycap: 0x%08lX\n", (unsigned long int) peasycap); |
4624 | return; | 4624 | return; |
4625 | } | 4625 | } |
4626 | /*---------------------------------------------------------------------------*/ | 4626 | /*---------------------------------------------------------------------------*/ |
4627 | /* | 4627 | /* |
4628 | * IF THE WAIT QUEUES ARE NOT CLEARED A DEADLOCK IS POSSIBLE. BEWARE. | 4628 | * IF THE WAIT QUEUES ARE NOT CLEARED A DEADLOCK IS POSSIBLE. BEWARE. |
4629 | */ | 4629 | */ |
4630 | /*---------------------------------------------------------------------------*/ | 4630 | /*---------------------------------------------------------------------------*/ |
4631 | peasycap->video_eof = 1; | 4631 | peasycap->video_eof = 1; |
4632 | peasycap->audio_eof = 1; | 4632 | peasycap->audio_eof = 1; |
4633 | wake_up_interruptible(&(peasycap->wq_video)); | 4633 | wake_up_interruptible(&(peasycap->wq_video)); |
4634 | wake_up_interruptible(&(peasycap->wq_audio)); | 4634 | wake_up_interruptible(&(peasycap->wq_audio)); |
4635 | /*---------------------------------------------------------------------------*/ | 4635 | /*---------------------------------------------------------------------------*/ |
4636 | switch (bInterfaceNumber) { | 4636 | switch (bInterfaceNumber) { |
4637 | case 0: { | 4637 | case 0: { |
4638 | if (NULL != peasycap->purb_video_head) { | 4638 | if (NULL != peasycap->purb_video_head) { |
4639 | JOM(4, "killing video urbs\n"); | 4639 | JOM(4, "killing video urbs\n"); |
4640 | m = 0; | 4640 | m = 0; |
4641 | list_for_each(plist_head, (peasycap->purb_video_head)) | 4641 | list_for_each(plist_head, (peasycap->purb_video_head)) |
4642 | { | 4642 | { |
4643 | pdata_urb = list_entry(plist_head, | 4643 | pdata_urb = list_entry(plist_head, |
4644 | struct data_urb, list_head); | 4644 | struct data_urb, list_head); |
4645 | if (NULL != pdata_urb) { | 4645 | if (NULL != pdata_urb) { |
4646 | if (NULL != pdata_urb->purb) { | 4646 | if (NULL != pdata_urb->purb) { |
4647 | usb_kill_urb(pdata_urb->purb); | 4647 | usb_kill_urb(pdata_urb->purb); |
4648 | m++; | 4648 | m++; |
4649 | } | ||
4649 | } | 4650 | } |
4650 | } | 4651 | } |
4652 | JOM(4, "%i video urbs killed\n", m); | ||
4651 | } | 4653 | } |
4652 | JOM(4, "%i video urbs killed\n", m); | 4654 | break; |
4653 | } | 4655 | } |
4654 | break; | ||
4655 | } | ||
4656 | /*---------------------------------------------------------------------------*/ | 4656 | /*---------------------------------------------------------------------------*/ |
4657 | case 2: { | 4657 | case 2: { |
4658 | if (NULL != peasycap->purb_audio_head) { | 4658 | if (NULL != peasycap->purb_audio_head) { |
4659 | JOM(4, "killing audio urbs\n"); | 4659 | JOM(4, "killing audio urbs\n"); |
4660 | m = 0; | 4660 | m = 0; |
4661 | list_for_each(plist_head, | 4661 | list_for_each(plist_head, |
4662 | (peasycap->purb_audio_head)) { | 4662 | (peasycap->purb_audio_head)) { |
4663 | pdata_urb = list_entry(plist_head, | 4663 | pdata_urb = list_entry(plist_head, |
4664 | struct data_urb, list_head); | 4664 | struct data_urb, list_head); |
4665 | if (NULL != pdata_urb) { | 4665 | if (NULL != pdata_urb) { |
4666 | if (NULL != pdata_urb->purb) { | 4666 | if (NULL != pdata_urb->purb) { |
4667 | usb_kill_urb(pdata_urb->purb); | 4667 | usb_kill_urb(pdata_urb->purb); |
4668 | m++; | 4668 | m++; |
4669 | } | ||
4669 | } | 4670 | } |
4670 | } | 4671 | } |
4672 | JOM(4, "%i audio urbs killed\n", m); | ||
4671 | } | 4673 | } |
4672 | JOM(4, "%i audio urbs killed\n", m); | 4674 | break; |
4673 | } | 4675 | } |
4674 | break; | ||
4675 | } | ||
4676 | /*---------------------------------------------------------------------------*/ | 4676 | /*---------------------------------------------------------------------------*/ |
4677 | default: | 4677 | default: |
4678 | break; | 4678 | break; |
4679 | } | 4679 | } |
4680 | /*--------------------------------------------------------------------------*/ | 4680 | /*--------------------------------------------------------------------------*/ |
4681 | /* | 4681 | /* |