• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * uvc_device.cpp - uvc device
3  *
4  *  Copyright (c) 2014-2015 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Sameer Kibey <sameer.kibey@intel.com>
19  */
20 
21 #include "uvc_device.h"
22 #include "v4l2_buffer_proxy.h"
23 #include <linux/v4l2-subdev.h>
24 
25 namespace XCam {
26 
UVCDevice(const char * name)27 UVCDevice::UVCDevice (const char *name)
28     : V4l2Device (name)
29 {
30 }
31 
~UVCDevice()32 UVCDevice::~UVCDevice ()
33 {
34 }
35 
36 XCamReturn
allocate_buffer(SmartPtr<V4l2Buffer> & buf,const struct v4l2_format & format,const uint32_t index)37 UVCDevice::allocate_buffer (
38     SmartPtr<V4l2Buffer> &buf,
39     const struct v4l2_format &format,
40     const uint32_t index)
41 {
42 #if HAVE_LIBDRM
43     if (!_drm_disp.ptr()) {
44         _drm_disp = DrmDisplay::instance ();
45     }
46 
47     if (get_mem_type () == V4L2_MEMORY_DMABUF && _drm_disp.ptr () != NULL) {
48         buf = _drm_disp->create_drm_buf (format, index, get_capture_buf_type ());
49         if (!buf.ptr()) {
50             XCAM_LOG_WARNING ("uvc device(%s) allocate buffer failed", XCAM_STR (get_device_name()));
51             return XCAM_RETURN_ERROR_MEM;
52         }
53         return XCAM_RETURN_NO_ERROR;
54     }
55 #endif
56 
57     return V4l2Device::allocate_buffer (buf, format, index);
58 }
59 
60 };
61