CameraHAL: modified device node probing

Modified the device node probing from last device node as USB Camera typically
gets registered at last.
There is one problem in probing (opening) device node starting from 0, as there
are many Video Capture drivers in kernel that are typically not camera, and the
open will succeed in them which should not be the case because they are not
Camera driver.

But, need an overall better mechanism of probing device nodes instead of opening all
device nodes in /dev/video*

Change-Id: I88f797ae12f15a11df3aae34143d343981e7dab0
Signed-off-by: Annamalai Lakshmanan <annamalai.lakshmanan@linaro.org>
diff --git a/libcamera/CameraHardware.cpp b/libcamera/CameraHardware.cpp
index 4a2da1c..93299bc 100644
--- a/libcamera/CameraHardware.cpp
+++ b/libcamera/CameraHardware.cpp
@@ -28,6 +28,7 @@
 #include <hal_public.h>
 #include <ui/GraphicBufferMapper.h>
 #include <gui/ISurfaceTexture.h>
+#define MAX_VIDEONODES      20
 #define MIN_WIDTH           320
 #define MIN_HEIGHT          240
 #define CAM_SIZE            "320x240"
@@ -241,7 +242,7 @@
 #if 1
     LOGI("startPreview: in startpreview \n");
     mParameters.getPreviewSize(&width, &height);
-    for( i=0; i<10; i++) {
+    for( i=MAX_VIDEONODES; i>=0; i--) {
         sprintf(devnode,"/dev/video%d",i);
         LOGI("trying the node %s width=%d height=%d \n",devnode,width,height);
         ret = camera.Open(devnode, width, height, PIXEL_FORMAT);
@@ -399,7 +400,7 @@
     mParameters.getPictureSize(&width, &height);
     mParameters.getPreviewSize(&width, &height);
 
-    for(i=0; i<10; i++) {
+    for(i=MAX_VIDEONODES; i>=0; i--) {
         sprintf(devnode,"/dev/video%d",i);
         LOGI("trying the node %s \n",devnode);
         ret = camera.Open(devnode, width, height, PIXEL_FORMAT);