Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d8d55d9 authored by Vignesh Kulothungan's avatar Vignesh Kulothungan Committed by Gerrit - the friendly Code Review server
Browse files

soc: update mechanism to set master port offset1



When multiple slave ports are configured to a single master port,
the offset1 of master is the minimum of all slave port's offset1.

Change-Id: I102269806048ecf9982489164a7651a2cdd0661c
Signed-off-by: default avatarVignesh Kulothungan <vigneshk@codeaurora.org>
parent 19df8856
Loading
Loading
Loading
Loading
+8 −27
Original line number Original line Diff line number Diff line
@@ -1338,28 +1338,6 @@ static void swrm_cleanup_disabled_port_reqs(struct swr_master *master)
	}
	}
}
}


static u8 swrm_get_controller_offset1(struct swr_mstr_ctrl *swrm,
					u8* dev_offset, u8 off1)
{
	u8 offset1 = 0x0F;
	int i = 0;

	if (swrm->master_id == MASTER_ID_TX) {
		for (i = 1; i < SWRM_NUM_AUTO_ENUM_SLAVES; i++) {
			pr_debug("%s: dev offset: %d\n",
				__func__, dev_offset[i]);
			if (offset1 > dev_offset[i])
				offset1 = dev_offset[i];
		}
	} else {
		offset1 = off1;
	}

	pr_debug("%s: offset: %d\n", __func__, offset1);

	return offset1;
}

static void swrm_get_device_frame_shape(struct swr_mstr_ctrl *swrm,
static void swrm_get_device_frame_shape(struct swr_mstr_ctrl *swrm,
					struct swrm_mports *mport,
					struct swrm_mports *mport,
					struct swr_port_info *port_req)
					struct swr_port_info *port_req)
@@ -1417,14 +1395,12 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
	u8 hparams = 0;
	u8 hparams = 0;
	u32 controller_offset = 0;
	u32 controller_offset = 0;
	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
	u8 dev_offset[SWRM_NUM_AUTO_ENUM_SLAVES];


	if (!swrm) {
	if (!swrm) {
		pr_err("%s: swrm is null\n", __func__);
		pr_err("%s: swrm is null\n", __func__);
		return;
		return;
	}
	}


	memset(dev_offset, 0xff, SWRM_NUM_AUTO_ENUM_SLAVES);
	dev_dbg(swrm->dev, "%s: master num_port: %d\n", __func__,
	dev_dbg(swrm->dev, "%s: master num_port: %d\n", __func__,
		master->num_port);
		master->num_port);


@@ -1433,6 +1409,9 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
		if (!mport->port_en)
		if (!mport->port_en)
			continue;
			continue;


		if (swrm->master_id == MASTER_ID_TX)
			controller_offset = 0xFF;

		if (mport->stream_type == SWR_PCM)
		if (mport->stream_type == SWR_PCM)
			swrm_pcm_port_config(swrm, (i + 1), mport->dir, true);
			swrm_pcm_port_config(swrm, (i + 1), mport->dir, true);


@@ -1523,7 +1502,9 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
								slv_id, bank));
								slv_id, bank));
			}
			}
			port_req->ch_en = port_req->req_ch;
			port_req->ch_en = port_req->req_ch;
			dev_offset[port_req->dev_num] = port_req->offset1;
			if (swrm->master_id == MASTER_ID_TX &&
			    controller_offset > port_req->offset1)
				controller_offset = port_req->offset1;
		}
		}
		value = ((mport->req_ch)
		value = ((mport->req_ch)
				<< SWRM_DP_PORT_CTRL_EN_CHAN_SHFT);
				<< SWRM_DP_PORT_CTRL_EN_CHAN_SHFT);
@@ -1531,8 +1512,8 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
		if (mport->offset2 != SWR_INVALID_PARAM)
		if (mport->offset2 != SWR_INVALID_PARAM)
			value |= ((mport->offset2)
			value |= ((mport->offset2)
					<< SWRM_DP_PORT_CTRL_OFFSET2_SHFT);
					<< SWRM_DP_PORT_CTRL_OFFSET2_SHFT);
		controller_offset = (swrm_get_controller_offset1(swrm,
		if (swrm->master_id != MASTER_ID_TX)
						dev_offset, mport->offset1));
			controller_offset = mport->offset1;
		value |= (controller_offset << SWRM_DP_PORT_CTRL_OFFSET1_SHFT);
		value |= (controller_offset << SWRM_DP_PORT_CTRL_OFFSET1_SHFT);
		mport->offset1 = controller_offset;
		mport->offset1 = controller_offset;
		value |= (mport->sinterval & 0xFF);
		value |= (mport->sinterval & 0xFF);