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

Commit 434f9fac authored by Praneeth Paladugu's avatar Praneeth Paladugu Committed by Matt Wagantall
Browse files

msm: vidc: Remove clock state variable



Clock state variable is redundant and can be replaced by
power_enabled variable. By doing this driver has less state
variables.

Change-Id: Ic6da6c53d9292aed0c1d6c89e3d9479a3bbbd809
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
parent 08a9dcb3
Loading
Loading
Loading
Loading
+10 −20
Original line number Diff line number Diff line
@@ -628,9 +628,10 @@ static void __write_register(struct venus_hfi_device *device,

	__strict_check(device);

	if (device->clk_state != ENABLED_PREPARED) {
	if (!device->power_enabled) {
		dprintk(VIDC_WARN,
			"HFI Write register failed : Clocks are OFF\n");
			"HFI Write register failed : Power is OFF\n");
		WARN_ON(1);
		return;
	}

@@ -653,9 +654,10 @@ static int __read_register(struct venus_hfi_device *device, u32 reg)

	__strict_check(device);

	if (device->clk_state != ENABLED_PREPARED) {
	if (!device->power_enabled) {
		dprintk(VIDC_WARN,
			"HFI Read register failed : Clocks are OFF\n");
			"HFI Read register failed : Power is OFF\n");
		WARN_ON(1);
		return -EINVAL;
	}

@@ -1389,9 +1391,10 @@ static int __halt_axi(struct venus_hfi_device *device)
	 * Driver needs to make sure that clocks are enabled to read Venus AXI
	 * registers. If not skip AXI HALT.
	 */
	if (device->clk_state != ENABLED_PREPARED) {
	if (!device->power_enabled) {
		dprintk(VIDC_WARN,
			"Clocks are OFF, skipping AXI HALT\n");
		WARN_ON(1);
		return -EINVAL;
	}

@@ -3719,22 +3722,11 @@ static inline void __disable_unprepare_clks(struct venus_hfi_device *device)
		return;
	}

	if (device->clk_state == DISABLED_UNPREPARED) {
	if (!device->power_enabled) {
		dprintk(VIDC_DBG, "Clocks already unprepared and disabled\n");
		return;
	}

	/*
	* Make the clock state variable as unprepared before actually
	* unpreparing clocks. This will make sure that when we check
	* the state, we have the right clock state. We are not taking
	* any action based unprepare failures. So it is safe to do
	* before the call. This is also in sync with prepare_enable
	* state update.
	*/

	device->clk_state = DISABLED_UNPREPARED;

	venus_hfi_for_each_clock(device, cl) {
		 usleep_range(100, 500);
		dprintk(VIDC_DBG, "Clock: %s disable and unprepare\n",
@@ -3752,7 +3744,7 @@ static inline int __prepare_enable_clks(struct venus_hfi_device *device)
		return -EINVAL;
	}

	if (device->clk_state == ENABLED_PREPARED) {
	if (device->power_enabled) {
		dprintk(VIDC_DBG, "Clocks already prepared and enabled\n");
		return 0;
	}
@@ -3776,7 +3768,6 @@ static inline int __prepare_enable_clks(struct venus_hfi_device *device)
		dprintk(VIDC_DBG, "Clock: %s prepared and enabled\n", cl->name);
	}

	device->clk_state = ENABLED_PREPARED;
	__write_register(device, VIDC_WRAPPER_CLOCK_CONFIG, 0);
	__write_register(device, VIDC_WRAPPER_CPU_CLOCK_CONFIG, 0);
	return rc;
@@ -3791,7 +3782,6 @@ fail_clk_enable:
		clk_disable_unprepare(cl->clk);
	}

	device->clk_state = DISABLED_UNPREPARED;
	return rc;
}

+0 −6
Original line number Diff line number Diff line
@@ -120,11 +120,6 @@ enum vidc_hw_reg {
	VIDC_HWREG_HVI_SOFTINTEN =  0xA,
};

enum clock_state {
	DISABLED_UNPREPARED,
	ENABLED_PREPARED,
};

struct vidc_mem_addr {
	ion_phys_addr_t align_device_addr;
	u8 *align_virtual_addr;
@@ -230,7 +225,6 @@ struct venus_hfi_device {
	u32 codecs_enabled;
	u32 last_packet_type;
	struct msm_vidc_gov_data bus_vote;
	enum clock_state clk_state;
	bool power_enabled;
	struct mutex lock;
	msm_vidc_callback callback;