From patchwork Mon Apr 6 19:48:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46791 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 31860214BA for ; Mon, 6 Apr 2015 19:48:42 +0000 (UTC) Received: by layy10 with SMTP id y10sf8106774lay.0 for ; Mon, 06 Apr 2015 12:48:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=QdNFum+HXhOINqBZ3KkeUM2xJ+4g4szEK7JqCpibosI=; b=Lr/ln4pDAVQFzwrB1EXl6+73ZgcT4EiLzBOvKSTPlvZeBZ5h9HJZlnT61w0t0OUVXx nivZX/R+8jSatN7P4IwcvV7rTEM2bDIGg+enZj7Pp61HM5qDwGjupEQisf5OUGRvelAb mBrLNiGx62Phs2qsWzNL/HzYT3qexxhwW/9zv9YVt3dIILxP5Az6xcj08D0nB2O9lRiD Kr9ZqxL6CVx84vU08Yc4p5r2SwYux6OI+vdluIWd9boTuPPQoHIQCwnamRgEqZZ8daEC RzWHsRcfBWy+XpaHDSQndd6mVPGV35ORfHxAqIDegih58WHRErM3akcMIkAtmwPhOQq8 WGMg== X-Gm-Message-State: ALoCoQk6PIzr1fCl4bEaHSq/dKP3lSONbSfy0yxF9m9pQQLrxwWzveXgh7lijWSsmYJ9ylUbNHRK X-Received: by 10.180.85.129 with SMTP id h1mr3196wiz.6.1428349720935; Mon, 06 Apr 2015 12:48:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.101 with SMTP id z5ls614116laz.12.gmail; Mon, 06 Apr 2015 12:48:40 -0700 (PDT) X-Received: by 10.153.6.6 with SMTP id cq6mr15042854lad.13.1428349720770; Mon, 06 Apr 2015 12:48:40 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id zg6si4249620lbb.169.2015.04.06.12.48.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 12:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by layy10 with SMTP id y10so26986373lay.0 for ; Mon, 06 Apr 2015 12:48:40 -0700 (PDT) X-Received: by 10.152.36.2 with SMTP id m2mr4049636laj.72.1428349720540; Mon, 06 Apr 2015 12:48:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp17260lbt; Mon, 6 Apr 2015 12:48:39 -0700 (PDT) X-Received: by 10.70.14.33 with SMTP id m1mr29933814pdc.123.1428349718573; Mon, 06 Apr 2015 12:48:38 -0700 (PDT) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com. [209.85.192.180]) by mx.google.com with ESMTPS id vr5si7946229pbc.93.2015.04.06.12.48.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 12:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.180 as permitted sender) client-ip=209.85.192.180; Received: by pdea3 with SMTP id a3so54161013pde.3 for ; Mon, 06 Apr 2015 12:48:37 -0700 (PDT) X-Received: by 10.66.159.193 with SMTP id xe1mr30495272pab.48.1428349717515; Mon, 06 Apr 2015 12:48:37 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id fk4sm5627405pab.48.2015.04.06.12.48.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Apr 2015 12:48:36 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: John Stultz , mark greer , Alex Elder , Greg Kroah-Hartman Subject: [PATCH] gbsim: Add GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS support Date: Mon, 6 Apr 2015 12:48:33 -0700 Message-Id: <1428349713-7925-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add I2S support for GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS messages. (Also some nearby whitespace fixes) Cc: mark greer Cc: Alex Elder Cc: Greg Kroah-Hartman Signed-off-by: John Stultz --- gbsim.h | 53 +++++++++++++++++++++++++++++------- i2s.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 10 deletions(-) diff --git a/gbsim.h b/gbsim.h index a75ed49..82d2da6 100644 --- a/gbsim.h +++ b/gbsim.h @@ -198,14 +198,45 @@ struct pwm_disable_req { __u8 which; }; +struct gb_i2s_mgmt_configuration { + __le32 sample_frequency; + __u8 num_channels; + __u8 bytes_per_channel; + __u8 byte_order; + __u8 pad; + __le32 spatial_locations; + __le32 ll_protocol; + __u8 ll_bclk_role; + __u8 ll_wclk_role; + __u8 ll_wclk_polarity; + __u8 ll_wclk_change_edge; + __u8 ll_wclk_tx_edge; + __u8 ll_wclk_rx_edge; + __u8 ll_data_offset; + __u8 ll_pad; +}; + +struct gb_i2s_mgmt_get_supported_configurations_response { + __u8 config_count; + __u8 pad[3]; + struct gb_i2s_mgmt_configuration config[0]; +}; + +/* get processing request delay has no payload */ +struct gb_i2s_mgmt_get_processing_delay_response { + __le32 microseconds; +}; + + + /* Ops */ struct op_msg { struct op_header header; union { struct protocol_version_rsp pv_rsp; - struct gpio_line_count_rsp gpio_lc_rsp; - struct gpio_activate_req gpio_act_req; - struct gpio_deactivate_req gpio_deact_req; + struct gpio_line_count_rsp gpio_lc_rsp; + struct gpio_activate_req gpio_act_req; + struct gpio_deactivate_req gpio_deact_req; struct gpio_get_direction_req gpio_get_dir_req; struct gpio_get_direction_rsp gpio_get_dir_rsp; struct gpio_direction_input_req gpio_dir_input_req; @@ -222,13 +253,15 @@ struct op_msg { struct i2c_functionality_rsp i2c_fcn_rsp; struct i2c_transfer_req i2c_xfer_req; struct i2c_transfer_rsp i2c_xfer_rsp; - struct pwm_count_rsp pwm_cnt_rsp; - struct pwm_activate_req pwm_act_req; - struct pwm_deactivate_req pwm_deact_req; - struct pwm_config_req pwm_cfg_req; - struct pwm_polarity_req pwm_pol_req; - struct pwm_enable_req pwm_enb_req; - struct pwm_disable_req pwm_dis_req; + struct pwm_count_rsp pwm_cnt_rsp; + struct pwm_activate_req pwm_act_req; + struct pwm_deactivate_req pwm_deact_req; + struct pwm_config_req pwm_cfg_req; + struct pwm_polarity_req pwm_pol_req; + struct pwm_enable_req pwm_enb_req; + struct pwm_disable_req pwm_dis_req; + struct gb_i2s_mgmt_get_supported_configurations_response i2s_mgmt_get_supported_conf_resp; + struct gb_i2s_mgmt_get_processing_delay_response i2s_mgmt_get_processing_delay_res; }; }; diff --git a/i2s.c b/i2s.c index d4d3ce9..869827e 100644 --- a/i2s.c +++ b/i2s.c @@ -28,6 +28,58 @@ #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08 #define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09 +#ifndef BIT +#define BIT(n) (1UL << (n)) +#endif +#define GB_I2S_MGMT_BYTE_ORDER_NA BIT(0) +#define GB_I2S_MGMT_BYTE_ORDER_BE BIT(1) +#define GB_I2S_MGMT_BYTE_ORDER_LE BIT(2) + +#define GB_I2S_MGMT_SPATIAL_LOCATION_FL BIT(0) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FR BIT(1) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FC BIT(2) +#define GB_I2S_MGMT_SPATIAL_LOCATION_LFE BIT(3) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BL BIT(4) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BR BIT(5) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FLC BIT(6) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FRC BIT(7) +#define GB_I2S_MGMT_SPATIAL_LOCATION_C BIT(8) /* BC in USB */ +#define GB_I2S_MGMT_SPATIAL_LOCATION_SL BIT(9) +#define GB_I2S_MGMT_SPATIAL_LOCATION_SR BIT(10) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TC BIT(11) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFL BIT(12) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFC BIT(13) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFR BIT(14) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TBL BIT(15) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TBC BIT(16) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TBR BIT(17) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC BIT(18) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC BIT(19) +#define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE BIT(20) +#define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE BIT(21) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TSL BIT(22) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TSR BIT(23) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BC BIT(24) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BLC BIT(25) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BRC BIT(26) +#define GB_I2S_MGMT_SPATIAL_LOCATION_RD BIT(31) + +#define GB_I2S_MGMT_PROTOCOL_PCM BIT(0) +#define GB_I2S_MGMT_PROTOCOL_I2S BIT(1) +#define GB_I2S_MGMT_PROTOCOL_LR_STEREO BIT(2) + +#define GB_I2S_MGMT_ROLE_MASTER BIT(0) +#define GB_I2S_MGMT_ROLE_SLAVE BIT(1) + +#define GB_I2S_MGMT_POLARITY_NORMAL BIT(0) +#define GB_I2S_MGMT_POLARITY_REVERSED BIT(1) + +#define GB_I2S_MGMT_EDGE_RISING BIT(0) +#define GB_I2S_MGMT_EDGE_FALLING BIT(1) + +#define CONFIG_COUNT_MAX 32 + + #define GB_I2S_DATA_TYPE_SEND_DATA 0x02 void i2s_mgmt_handler(__u8 *rbuf, size_t size) @@ -36,6 +88,7 @@ void i2s_mgmt_handler(__u8 *rbuf, size_t size) char *tbuf; struct op_msg *op_req, *op_rsp; struct cport_msg *cport_req, *cport_rsp; + struct gb_i2s_mgmt_configuration *conf; size_t sz; tbuf = malloc(4 * 1024); @@ -51,6 +104,45 @@ void i2s_mgmt_handler(__u8 *rbuf, size_t size) oph = (struct op_header *)&op_req->header; switch (oph->type) { + case GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS: + sz = sizeof(struct op_header) + + sizeof(struct gb_i2s_mgmt_get_supported_configurations_response) + + sizeof(struct gb_i2s_mgmt_configuration) * CONFIG_COUNT_MAX; + + printf("JDB: sz=%i\n", sz); + op_rsp->header.size = htole16((__u16)sz); + op_rsp->header.id = oph->id; + + op_rsp->header.type = OP_RESPONSE | GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS; + op_rsp->header.result = PROTOCOL_STATUS_SUCCESS; + + op_rsp->i2s_mgmt_get_supported_conf_resp.config_count = 1; + + conf = &op_rsp->i2s_mgmt_get_supported_conf_resp.config[0]; + conf->sample_frequency = htole32(48000); + conf->num_channels = 2; + conf->bytes_per_channel = 2; + conf->byte_order = GB_I2S_MGMT_BYTE_ORDER_LE; + conf->spatial_locations = htole32( + GB_I2S_MGMT_SPATIAL_LOCATION_FL | + GB_I2S_MGMT_SPATIAL_LOCATION_FR); + conf->ll_protocol = htole32(GB_I2S_MGMT_PROTOCOL_I2S); + conf->ll_bclk_role = GB_I2S_MGMT_ROLE_MASTER; + conf->ll_wclk_role = GB_I2S_MGMT_ROLE_MASTER; + conf->ll_wclk_polarity = GB_I2S_MGMT_POLARITY_NORMAL; + conf->ll_wclk_change_edge = GB_I2S_MGMT_EDGE_FALLING; + conf->ll_wclk_tx_edge = GB_I2S_MGMT_EDGE_FALLING; + conf->ll_wclk_rx_edge = GB_I2S_MGMT_EDGE_RISING; + conf->ll_data_offset = 1; + + + + gbsim_debug("Module %d -> AP CPort %d I2S GET_CONFIGURATION response\n ", + cport_to_module_id(cport_req->cport), cport_rsp->cport); + if (verbose) + gbsim_dump((__u8 *)op_rsp, op_rsp->header.size); + write(cport_in, cport_rsp, op_rsp->header.size + 1); + break; case GB_I2S_MGMT_TYPE_SET_CONFIGURATION: sz = sizeof(struct op_header); op_rsp->header.size = htole16((__u16)sz);