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

Commit d5f64568 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "asoc: update wakeup_source API"

parents 1038df1f 9524bda6
Loading
Loading
Loading
Loading
+26 −22
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/dma-mapping.h>
#include <linux/of.h>
#include <linux/freezer.h>
#include <linux/version.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
@@ -92,7 +93,7 @@ struct lsm_priv {
	int xrun_count;
	int xrun_index;
	spinlock_t xrun_lock;
	struct wakeup_source ws;
	struct wakeup_source *ws;
};

enum { /* lsm session states */
@@ -220,7 +221,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
	}
	rtd = substream->private_data;

	pm_wakeup_ws_event(&prtd->ws, WAKELOCK_TIMEOUT, true);
	pm_wakeup_ws_event(prtd->ws, WAKELOCK_TIMEOUT, true);
	dev_dbg(rtd->dev, "%s: opcode %x\n", __func__, opcode);
	switch (opcode) {
	case LSM_DATA_EVENT_READ_DONE: {
@@ -235,13 +236,13 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
				"%s: EVENT_READ_DONE invalid callback, session %d callback %d payload %pK",
				__func__, prtd->lsm_client->session,
				token, read_done);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		if (atomic_read(&prtd->read_abort)) {
			dev_dbg(rtd->dev,
				"%s: read abort set skip data\n", __func__);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		if (!lsm_lab_buffer_sanity(prtd, read_done, &buf_index)) {
@@ -254,7 +255,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
					"%s: Invalid index %d buf_index max cnt %d\n",
					__func__, buf_index,
				prtd->lsm_client->out_hw_params.period_count);
				__pm_relax(&prtd->ws);
				__pm_relax(prtd->ws);
				return;
			}
			spin_lock_irqsave(&prtd->xrun_lock, flags);
@@ -292,7 +293,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
			dev_err(rtd->dev,
					"%s: client_size has invalid size[%d]\n",
					__func__, client_size);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		status = (uint16_t)((uint8_t *)payload)[0];
@@ -308,7 +309,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
			dev_err(rtd->dev,
					"%s: client_size has invalid size[%d]\n",
					__func__, client_size);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		status = (uint16_t)((uint8_t *)payload)[0];
@@ -324,7 +325,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
			dev_err(rtd->dev,
					"%s: client_size has invalid size[%d]\n",
					__func__, client_size);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		event_ts_lsw = ((uint32_t *)payload)[0];
@@ -344,7 +345,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
			dev_err(rtd->dev,
					"%s: client_size has invalid size[%d]\n",
					__func__, client_size);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}

@@ -364,7 +365,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
				"LSM_SESSION_DETECTION_ENGINE_GENERIC_EVENT",
				sizeof(struct snd_lsm_event_status) +
				payload_size);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}

@@ -379,7 +380,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
			dev_err(rtd->dev,
				"%s: Failed to copy memory with invalid size = %d\n",
				__func__, payload_size);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		prtd->event_avail = 1;
@@ -411,7 +412,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
		if (!temp) {
			dev_err(rtd->dev, "%s: no memory for event status\n",
				__func__);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return;
		}
		/*
@@ -438,7 +439,7 @@ static void lsm_event_handler(uint32_t opcode, uint32_t token,
				dev_err(rtd->dev,
						"%s: Failed to copy memory with invalid size = %d\n",
						__func__, payload_size);
				__pm_relax(&prtd->ws);
				__pm_relax(prtd->ws);
				return;
			}
		} else {
@@ -1156,7 +1157,7 @@ static int msm_lsm_ioctl_shared(struct snd_pcm_substream *substream,
			dev_err(rtd->dev,
				"%s: lsm open failed, %d\n",
				__func__, ret);
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return ret;
		}
		prtd->lsm_client->opened = true;
@@ -1504,14 +1505,14 @@ static int msm_lsm_ioctl_shared(struct snd_pcm_substream *substream,
		if (prtd->lsm_client->num_stages > 1) {
			dev_err(rtd->dev, "%s: %s: not supported for multi stage session\n",
				__func__, "LSM_LAB_CONTROL");
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return -EINVAL;
		}

		if (copy_from_user(&enable, arg, sizeof(enable))) {
			dev_err(rtd->dev, "%s: %s: copy_frm_user failed\n",
				__func__, "LSM_LAB_CONTROL");
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return -EFAULT;
		}

@@ -1566,7 +1567,7 @@ static int msm_lsm_ioctl_shared(struct snd_pcm_substream *substream,
		if (copy_from_user(&mode, arg, sizeof(mode))) {
			dev_err(rtd->dev, "%s: %s: copy_frm_user failed\n",
				__func__, "LSM_SET_FWK_MODE_CONFIG");
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return -EFAULT;
		}

@@ -1597,7 +1598,7 @@ static int msm_lsm_ioctl_shared(struct snd_pcm_substream *substream,
		if (copy_from_user(&params, arg, sizeof(params))) {
			dev_err(rtd->dev, "%s: %s: copy_from_user failed\n",
				__func__, "LSM_SET_INPUT_HW_PARAMS");
			__pm_relax(&prtd->ws);
			__pm_relax(prtd->ws);
			return -EFAULT;
		}

@@ -1624,7 +1625,7 @@ static int msm_lsm_ioctl_shared(struct snd_pcm_substream *substream,
		dev_err(rtd->dev, "%s: cmd 0x%x failed %d\n",
			__func__, cmd, rc);

	__pm_relax(&prtd->ws);
	__pm_relax(prtd->ws);
	return rc;
}

@@ -2528,8 +2529,11 @@ static int msm_lsm_open(struct snd_pcm_substream *substream)
	prtd->lsm_client->event_type = LSM_DET_EVENT_TYPE_LEGACY;
	prtd->lsm_client->fe_id = rtd->dai_link->id;
	prtd->lsm_client->unprocessed_data = 0;

	wakeup_source_init(&prtd->ws, "lsm-client");
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 110))
	prtd->ws = wakeup_source_register(rtd->dev, "lsm-client");
#else
	prtd->ws = wakeup_source_register("lsm-client");
#endif
	return 0;
}

@@ -2774,7 +2778,7 @@ static int msm_lsm_close(struct snd_pcm_substream *substream)

	q6lsm_client_free(prtd->lsm_client);

	wakeup_source_trash(&prtd->ws);
	wakeup_source_unregister(prtd->ws);
	spin_lock_irqsave(&prtd->event_lock, flags);
	kfree(prtd->event_status);
	prtd->event_status = NULL;
+11 −7
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/jiffies.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/version.h>
#include <dsp/msm_audio_ion.h>
#include <dsp/apr_audio-v2.h>
#include <dsp/audio_cal_utils.h>
@@ -98,7 +99,7 @@ enum {
};

struct wlock {
	struct wakeup_source ws;
	struct wakeup_source *ws;
};

static struct wlock wl;
@@ -8960,7 +8961,7 @@ static int afe_set_cal_fb_spkr_prot(int32_t cal_type, size_t data_size,
		goto done;

	if (cal_data->cal_info.mode == MSM_SPKR_PROT_CALIBRATION_IN_PROGRESS)
		__pm_wakeup_event(&wl.ws, jiffies_to_msecs(WAKELOCK_TIMEOUT));
		__pm_wakeup_event(wl.ws, jiffies_to_msecs(WAKELOCK_TIMEOUT));
	mutex_lock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
	memcpy(&this_afe.prot_cfg, &cal_data->cal_info,
		sizeof(this_afe.prot_cfg));
@@ -9166,7 +9167,7 @@ static int afe_get_cal_fb_spkr_prot(int32_t cal_type, size_t data_size,
	}
	this_afe.initial_cal = 0;
	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
	__pm_relax(&wl.ws);
	__pm_relax(wl.ws);
done:
	return ret;
}
@@ -9464,7 +9465,6 @@ int __init afe_init(void)
	init_waitqueue_head(&this_afe.wait_wakeup);
	init_waitqueue_head(&this_afe.lpass_core_hw_wait);
	init_waitqueue_head(&this_afe.clk_wait);
	wakeup_source_init(&wl.ws, "spkr-prot");
	ret = afe_init_cal_data();
	if (ret)
		pr_err("%s: could not init cal data! %d\n", __func__, ret);
@@ -9474,7 +9474,11 @@ int __init afe_init(void)
	this_afe.uevent_data = kzalloc(sizeof(*(this_afe.uevent_data)), GFP_KERNEL);
	if (!this_afe.uevent_data)
		return -ENOMEM;

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 110))
	wl.ws = wakeup_source_register(NULL, "spkr-prot");
#else
	wl.ws = wakeup_source_register("spkr-prot");
#endif
/*
	 * Set release function to cleanup memory related to kobject
	 * before initializing the kobject.
@@ -9509,7 +9513,7 @@ void afe_exit(void)
	mutex_destroy(&this_afe.afe_cmd_lock);
	mutex_destroy(&this_afe.afe_apr_lock);
	mutex_destroy(&this_afe.afe_clk_lock);
	wakeup_source_trash(&wl.ws);
	wakeup_source_unregister(wl.ws);
}

/*
+10 −6
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011-2017, 2020, The Linux Foundation. All rights reserved.
 */

#include <linux/compat.h>
@@ -15,6 +15,7 @@
#include <linux/time.h>
#include <linux/kmemleak.h>
#include <linux/mutex.h>
#include <linux/version.h>
#include <dsp/apr_audio-v2.h>
#include "q6usm.h"
#include "usf.h"
@@ -173,7 +174,7 @@ static const int s_button_map[] = {
/* The opened devices container */
static atomic_t s_opened_devs[MAX_DEVS_NUMBER];

static struct wakeup_source usf_wakeup_source;
static struct wakeup_source *usf_wakeup_source;

#define USF_NAME_PREFIX "usf_"
#define USF_NAME_PREFIX_SIZE 4
@@ -442,7 +443,7 @@ static void usf_tx_cb(uint32_t opcode, uint32_t token,
	case Q6USM_EVENT_READ_DONE:
		pr_debug("%s: acquiring %d msec wake lock\n", __func__,
				STAY_AWAKE_AFTER_READ_MSECS);
		__pm_wakeup_event(&usf_wakeup_source,
		__pm_wakeup_event(usf_wakeup_source,
				  STAY_AWAKE_AFTER_READ_MSECS);
		if (token == USM_WRONG_TOKEN)
			usf_xx->usf_state = USF_ERROR_STATE;
@@ -2369,8 +2370,11 @@ static int usf_open(struct inode *inode, struct file *file)
	usf = kzalloc(sizeof(struct usf_type), GFP_KERNEL);
	if (usf == NULL)
		return -ENOMEM;

	wakeup_source_init(&usf_wakeup_source, "usf");
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 110))
	usf_wakeup_source = wakeup_source_register(NULL, "usf");
#else
	usf_wakeup_source = wakeup_source_register("usf");
#endif

	file->private_data = usf;
	usf->dev_ind = dev_ind;
@@ -2401,7 +2405,7 @@ static int usf_release(struct inode *inode, struct file *file)

	atomic_set(&s_opened_devs[usf->dev_ind], 0);

	wakeup_source_trash(&usf_wakeup_source);
	wakeup_source_unregister(usf_wakeup_source);
	mutex_unlock(&usf->mutex);
	mutex_destroy(&usf->mutex);
	kfree(usf);