diff --git a/host_applications/linux/apps/raspicam/RaspiStill.c b/host_applications/linux/apps/raspicam/RaspiStill.c index bc7884341..9b791fb64 100644 --- a/host_applications/linux/apps/raspicam/RaspiStill.c +++ b/host_applications/linux/apps/raspicam/RaspiStill.c @@ -136,6 +136,7 @@ typedef struct int settings; /// Request settings from the camera int cameraNum; /// Camera number int burstCaptureMode; /// Enable burst mode + int sensor_mode; /// Sensor mode. 0=auto. Check docs/forum for modes selected by other values. RASPIPREVIEW_PARAMETERS preview_parameters; /// Preview setup parameters RASPICAM_CAMERA_PARAMETERS camera_parameters; /// Camera setup parameters @@ -187,6 +188,7 @@ static void store_exif_tag(RASPISTILL_STATE *state, const char *exif_tag); #define CommandSettings 19 #define CommandCamSelect 20 #define CommandBurstMode 21 +#define CommandSensorMode 22 static COMMAND_LIST cmdline_commands[] = { @@ -211,7 +213,8 @@ static COMMAND_LIST cmdline_commands[] = { CommandGLCapture, "-glcapture","gc", "Capture the GL frame-buffer instead of the camera image", 0}, { CommandSettings, "-settings", "set","Retrieve camera settings and write to stdout", 0}, { CommandCamSelect, "-camselect","cs", "Select camera . Default 0", 1 }, - { CommandBurstMode, "-burst", "bm", "Enable 'burst capture mode'", 0}, + { CommandBurstMode, "-burst", "bm", "Enable 'burst capture mode'", 0}, + { CommandSensorMode,"-mode", "md", "Force sensor mode. 0=auto. See docs for other modes available", 1}, }; static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_commands[0]); @@ -290,6 +293,7 @@ static void default_status(RASPISTILL_STATE *state) state->settings = 0; state->cameraNum = 0; state->burstCaptureMode=0; + state->sensor_mode = 0; // Setup preview window defaults raspipreview_set_defaults(&state->preview_parameters); @@ -622,6 +626,18 @@ static int parse_cmdline(int argc, const char **argv, RASPISTILL_STATE *state) state->burstCaptureMode=1; break; + case CommandSensorMode: + { + if (sscanf(argv[i + 1], "%u", &state->sensor_mode) == 1) + { + i++; + } + else + valid = 0; + break; + } + + default: { // Try parsing for any image specific parameters @@ -848,6 +864,14 @@ static MMAL_STATUS_T create_camera_component(RASPISTILL_STATE *state) goto error; } + status = mmal_port_parameter_set_uint32(camera->control, MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, state->sensor_mode); + + if (status != MMAL_SUCCESS) + { + vcos_log_error("Could not set sensor mode : error %d", status); + goto error; + } + preview_port = camera->output[MMAL_CAMERA_PREVIEW_PORT]; video_port = camera->output[MMAL_CAMERA_VIDEO_PORT]; still_port = camera->output[MMAL_CAMERA_CAPTURE_PORT]; diff --git a/host_applications/linux/apps/raspicam/RaspiVid.c b/host_applications/linux/apps/raspicam/RaspiVid.c index 97af7c91d..afb836382 100755 --- a/host_applications/linux/apps/raspicam/RaspiVid.c +++ b/host_applications/linux/apps/raspicam/RaspiVid.c @@ -186,7 +186,7 @@ struct RASPIVID_STATE_S int cameraNum; /// Camera number int settings; /// Request settings from the camera - + int sensor_mode; /// Sensor mode. 0=auto. Check docs/forum for modes selected by other values. }; @@ -239,6 +239,7 @@ static void display_valid_parameters(char *app_name); #define CommandIMV 23 #define CommandCamSelect 24 #define CommandSettings 25 +#define CommandSensorMode 26 static COMMAND_LIST cmdline_commands[] = { @@ -267,7 +268,8 @@ static COMMAND_LIST cmdline_commands[] = { CommandCircular, "-circular", "c", "Run encoded data through circular buffer until triggered then save", 0}, { CommandIMV, "-vectors", "x", "Output filename for inline motion vectors", 1 }, { CommandCamSelect, "-camselect", "cs", "Select camera . Default 0", 1 }, - { CommandSettings, "-settings", "set","Retrieve camera settings and write to stdout", 0}, + { CommandSettings, "-settings", "set","Retrieve camera settings and write to stdout", 0}, + { CommandSensorMode, "-mode", "md", "Force sensor mode. 0=auto. See docs for other modes available", 1}, }; static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_commands[0]); @@ -335,6 +337,7 @@ static void default_status(RASPIVID_STATE *state) state->cameraNum = 0; state->settings = 0; + state->sensor_mode = 0; // Setup preview window defaults raspipreview_set_defaults(&state->preview_parameters); @@ -675,13 +678,24 @@ static int parse_cmdline(int argc, const char **argv, RASPIVID_STATE *state) } else valid = 0; - break; - } + break; + } case CommandSettings: state->settings = 1; break; + case CommandSensorMode: + { + if (sscanf(argv[i + 1], "%u", &state->sensor_mode) == 1) + { + i++; + } + else + valid = 0; + break; + } + default: { // Try parsing for any image specific parameters @@ -1115,6 +1129,14 @@ static MMAL_STATUS_T create_camera_component(RASPIVID_STATE *state) goto error; } + status = mmal_port_parameter_set_uint32(camera->control, MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, state->sensor_mode); + + if (status != MMAL_SUCCESS) + { + vcos_log_error("Could not set sensor mode : error %d", status); + goto error; + } + preview_port = camera->output[MMAL_CAMERA_PREVIEW_PORT]; video_port = camera->output[MMAL_CAMERA_VIDEO_PORT]; still_port = camera->output[MMAL_CAMERA_CAPTURE_PORT];