CRAS: New --dsp_config CLI option

Add a command line option to specify the location of the DSP config
file.

This can be used if there are more than one dsp.ini files for a given
system.  This happens when systems are build with different speakers or
mechanicals.

BUG=chrome-os-partner:38776
TEST=pass command --dsp_config and see what it loads

Change-Id: Iab53dd8fb66dad8e9411f79ecbd6d272e56ac1c5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264092
Reviewed-by: Ben Zhang <benzh@chromium.org>
diff --git a/cras/src/server/cras.c b/cras/src/server/cras.c
index d0692a2..82bc505 100644
--- a/cras/src/server/cras.c
+++ b/cras/src/server/cras.c
@@ -14,6 +14,7 @@
 #include "cras_dsp.h"
 
 static struct option long_options[] = {
+	{"dsp_config", required_argument, 0, 'd'},
 	{"syslog_mask", required_argument, 0, 'l'},
 	{0, 0, 0, 0}
 };
@@ -30,6 +31,8 @@
 {
 	int c, option_index;
 	int log_mask = LOG_ERR;
+	const char default_dsp_config[] = CRAS_CONFIG_FILE_DIR "/dsp.ini";
+	const char *dsp_config = default_dsp_config;
 
 	set_signals();
 
@@ -49,6 +52,11 @@
 			log_mask = atoi(optarg);
 			break;
 
+		case 'd':
+			dsp_config = optarg;
+			break;
+		default:
+			break;
 		}
 	}
 
@@ -69,7 +77,7 @@
 	/* Initialize system. */
 	cras_server_init();
 	cras_system_state_init();
-	cras_dsp_init(CRAS_CONFIG_FILE_DIR "/dsp.ini");
+	cras_dsp_init(dsp_config);
 	cras_iodev_list_init();
 
 	/* Start the server. */