sevy
sevy

Reputation: 1

accessing v4l2 in android?

for performance reasons, i'm trying to access directly the video 4 linux device in android and make traditional v4l2 control commands on it, on my htc desire, the device is called /dev/msm_camera/config0 and i manage to open it, but when i try any ioctl on it, i always get 'Invalid argument' but it's the same code that is working fine on any linux system, so what is the difference in android? Here is an example of code for querying device capabilities :

static struct v4l2_capability x_vcap;

if (ioctl(x_conffd, VIDIOC_QUERYCAP, &x_vcap) < 0)
{
   __android_log_write(ANDROID_LOG_ERROR, "libcamera", strerror(errno));
   __android_log_write(ANDROID_LOG_ERROR, "libcamera", "Could not get camera capabitilites.");
}
else
{
    __android_log_write(ANDROID_LOG_INFO, "libcamera", "Got capabilities.");
    sprintf(message, "driver info: %s %d.%d.%d / %s @ %s", x_vcap.driver, (x_vcap.version >> 16) & 0xff, (x_vcap.version >>  8) & 0xff, x_vcap.version & 0xff, x_vcap.card, x_vcap.bus_info);
    __android_log_write(ANDROID_LOG_INFO, "libcamera", message );
}

i really need to access v4l2 to get a much better framerate that what is given by the Camera java class, so please don't direct to me to the Camera android class.

Upvotes: 2

Views: 2967

Answers (1)

ionela.voinescu
ionela.voinescu

Reputation: 384

In a general purpose Linux OS there is another driver that controls the communication between userspace and the camera hardware (easycap and videodev). The IOCTL command you have used it's specific to that driver.
For the Qualcomm platform (meaning your HTC Desire with a Qualcomm processor) they've built a custom camera driver specific for their camera module, which has a different interface with the hardware (different set of IOCTL commands). The interface can be found here or a least a version of it.

Therefore, your IOCTL call returns "Invalid argument" because it cannot find the VIDIOC_QUERYCAP command.

Upvotes: 2

Related Questions