Set the viewfinder mode for camera

Before you can start using the camera, you must set the viewfinder mode.

When you start the viewfinder mode, it resets an previously configuration settings on the camera. For more information, see Viewfinder Mode. It's recommended that you check what viewfinder modes are available on the camera before you set it. If the viewfinder mode isn't correctly set, the camera won't function as expected and you may see adverse or undefined results when you start to work with the image buffers from the camera. For information about determining what viewfinder modes are available, see Determine the viewfinder modes available.”

That being said, you'll likely know the specific viewfinder mode you want to use based on fact you'll know what camera you're using. For example, if your camera supports only the CAMERA_VFMODE_VIDEO mode, there's no reason to determine what video modes are available. In this situation, it's sensible that you set the viewfinder mode directly to optimize your code. Here's sample code snippet to show how to set the viewfinder mode:
...
...
// First connect to the camera
if (camera_open(CAMERA_UNIT_1, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &cameraHandle) != CAMERA_EOK) {
    printf("Failed to open the camera\n");
    return 1;
}
// Set the viewfinder image stream mode
if (camera_set_vf_mode(cameraHandle, CAMERA_VFMODE_VIDEO) != CAMERA_EOK)
{
   printf("Failed to set the viewfinder mode\n");
   camera_close(cameraHandle);
}

...
...

Determine the viewfinder modes available

To determine the viewfinder modes that are available, call camera_get_supported_vf_modes() twice. You call the function the first time to determine the number of modes that are available. After you know the number of modes that are available, you must allocate an array large enough to hold the number of modes, and then call camera_get_supported_vf_modes() again to retrieve the modes. For more information, see camera_get_supported_vf_modes().” Typically, most cameras support CAMERA_VFMODE_VIDEO, which is the mode necessary to use video.

In the following code snippet, we presume that CAMERA_UNIT_1 is the camera connected to the system:
...
...
uint32_t numSupported;
camera_vfmode_t* modes;
uint32_t x;
int err;
camera_handle_t cameraHandle;

if (camera_open(CAMERA_UNIT_1, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &cameraHandle) != CAMERA_EOK) {
    printf("Failed to open the camera\n");
}

 err = camera_get_supported_vf_modes(cameraHandle, 0, &numSupported, NULL);
 if (err != EOK) {
     printf("Failed to get number of supported VF modes: err = %d\n", err);
 }
 // Allocate an array big enough to hold all modes
 modes = (camera_vfmode_t*) malloc(sizeof(camera_vfmode_t) * numSupported);
 if (modes == NULL) {
    printf("Failed to allocated VF modes\n");
}
//Call the function a second time
if (camera_get_supported_vf_modes(cameraHandle, numSupported,
                                  &numSupported, modes) == EOK) {
   for(x=0; x < numSupported; ++x) {
       printf("\t Enumerator Value: %d\n",  modes[x]);
    }
}
...
...