Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: SOF: fix return values for mandatory ops #539

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions sound/soc/sof/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static inline int snd_sof_probe(struct snd_sof_dev *sdev)
if (sof_ops(sdev)->probe)
return sof_ops(sdev)->probe(sdev);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

static inline int snd_sof_remove(struct snd_sof_dev *sdev)
Expand All @@ -44,7 +45,8 @@ static inline int snd_sof_dsp_run(struct snd_sof_dev *sdev)
if (sof_ops(sdev)->run)
return sof_ops(sdev)->run(sdev);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

static inline int snd_sof_dsp_stall(struct snd_sof_dev *sdev)
Expand Down Expand Up @@ -152,15 +154,23 @@ static inline void snd_sof_dsp_dbg_dump(struct snd_sof_dev *sdev, u32 flags)
static inline void snd_sof_dsp_write(struct snd_sof_dev *sdev, u32 bar,
u32 offset, u32 value)
{
if (sof_ops(sdev)->write)
if (sof_ops(sdev)->write) {
sof_ops(sdev)->write(sdev, sdev->bar[bar] + offset, value);
return;
}

dev_err_ratelimited(sdev->dev, "error: %s not defined\n", __func__);
}

static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar,
u32 offset, u64 value)
{
if (sof_ops(sdev)->write64)
if (sof_ops(sdev)->write64) {
sof_ops(sdev)->write64(sdev, sdev->bar[bar] + offset, value);
return;
}

dev_err_ratelimited(sdev->dev, "error: %s not defined\n", __func__);
}

static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar,
Expand All @@ -169,7 +179,8 @@ static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar,
if (sof_ops(sdev)->read)
return sof_ops(sdev)->read(sdev, sdev->bar[bar] + offset);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

static inline u64 snd_sof_dsp_read64(struct snd_sof_dev *sdev, u32 bar,
Expand All @@ -178,39 +189,56 @@ static inline u64 snd_sof_dsp_read64(struct snd_sof_dev *sdev, u32 bar,
if (sof_ops(sdev)->read64)
return sof_ops(sdev)->read64(sdev, sdev->bar[bar] + offset);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

/* block IO */
static inline void snd_sof_dsp_block_read(struct snd_sof_dev *sdev, u32 bar,
u32 offset, void *dest, size_t bytes)
{
if (sof_ops(sdev)->block_read)
if (sof_ops(sdev)->block_read) {
sof_ops(sdev)->block_read(sdev, bar, offset, dest, bytes);
return;
}

dev_err_ratelimited(sdev->dev, "error: %s not defined\n", __func__);
}

static inline void snd_sof_dsp_block_write(struct snd_sof_dev *sdev, u32 bar,
u32 offset, void *src, size_t bytes)
{
if (sof_ops(sdev)->block_write)
if (sof_ops(sdev)->block_write) {
sof_ops(sdev)->block_write(sdev, bar, offset, src, bytes);
return;
}

dev_err_ratelimited(sdev->dev, "error: %s not defined\n", __func__);
}

/* mailbox */
static inline void snd_sof_dsp_mailbox_read(struct snd_sof_dev *sdev,
u32 offset, void *message,
size_t bytes)
{
if (sof_ops(sdev)->mailbox_read)
if (sof_ops(sdev)->mailbox_read) {
sof_ops(sdev)->mailbox_read(sdev, offset, message, bytes);
return;
}

dev_err_ratelimited(sdev->dev, "error: %s not defined\n", __func__);
}

static inline void snd_sof_dsp_mailbox_write(struct snd_sof_dev *sdev,
u32 offset, void *message,
size_t bytes)
{
if (sof_ops(sdev)->mailbox_write)
if (sof_ops(sdev)->mailbox_write) {
sof_ops(sdev)->mailbox_write(sdev, offset, message, bytes);
return;
}

dev_err_ratelimited(sdev->dev, "error: %s not defined\n", __func__);
}

/* ipc */
Expand All @@ -220,7 +248,8 @@ static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev,
if (sof_ops(sdev)->send_msg)
return sof_ops(sdev)->send_msg(sdev, msg);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

static inline int snd_sof_dsp_get_reply(struct snd_sof_dev *sdev,
Expand All @@ -229,15 +258,17 @@ static inline int snd_sof_dsp_get_reply(struct snd_sof_dev *sdev,
if (sof_ops(sdev)->get_reply)
return sof_ops(sdev)->get_reply(sdev, msg);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

static inline int snd_sof_dsp_is_ipc_ready(struct snd_sof_dev *sdev)
{
if (sof_ops(sdev)->is_ipc_ready)
return sof_ops(sdev)->is_ipc_ready(sdev);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
plbossart marked this conversation as resolved.
Show resolved Hide resolved
}

static inline int snd_sof_dsp_cmd_done(struct snd_sof_dev *sdev,
Expand All @@ -246,7 +277,8 @@ static inline int snd_sof_dsp_cmd_done(struct snd_sof_dev *sdev,
if (sof_ops(sdev)->cmd_done)
return sof_ops(sdev)->cmd_done(sdev, dir);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
}

/* host DMA trace */
Expand Down
119 changes: 64 additions & 55 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,105 +67,114 @@ struct snd_sof_pdata;
* and DSP device(s).
*/
struct snd_sof_dsp_ops {

/* probe and remove */
int (*remove)(struct snd_sof_dev *sof_dev);
int (*probe)(struct snd_sof_dev *sof_dev);
int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */
int (*remove)(struct snd_sof_dev *sof_dev); /* optional */

/* DSP core boot / reset */
int (*run)(struct snd_sof_dev *sof_dev);
int (*stall)(struct snd_sof_dev *sof_dev);
int (*reset)(struct snd_sof_dev *sof_dev);
int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
int (*stall)(struct snd_sof_dev *sof_dev); /* optional */
int (*reset)(struct snd_sof_dev *sof_dev); /* optional */
int (*core_power_up)(struct snd_sof_dev *sof_dev,
unsigned int core_mask);
unsigned int core_mask); /* optional */
int (*core_power_down)(struct snd_sof_dev *sof_dev,
unsigned int core_mask);

/* pre/post firmware run */
int (*pre_fw_run)(struct snd_sof_dev *sof_dev);
int (*post_fw_run)(struct snd_sof_dev *sof_dev);

/* DSP PM */
int (*suspend)(struct snd_sof_dev *sof_dev, int state);
int (*resume)(struct snd_sof_dev *sof_dev);
int (*runtime_suspend)(struct snd_sof_dev *sof_dev, int state);
int (*runtime_resume)(struct snd_sof_dev *sof_dev);

/* DSP clocking */
int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq);
unsigned int core_mask); /* optional */

/* Register IO */
void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
u32 value);
u32 (*read)(struct snd_sof_dev *sof_dev, void __iomem *addr);
u32 value); /* mandatory */
u32 (*read)(struct snd_sof_dev *sof_dev,
void __iomem *addr); /* mandatory */
void (*write64)(struct snd_sof_dev *sof_dev, void __iomem *addr,
u64 value);
u64 (*read64)(struct snd_sof_dev *sof_dev, void __iomem *addr);
u64 value); /* mandatory */
u64 (*read64)(struct snd_sof_dev *sof_dev,
void __iomem *addr); /* mandatory */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is inconsistent with the fact that those functions return 0 if not supported?


/* memcpy IO */
void (*block_read)(struct snd_sof_dev *sof_dev, u32 bar,
u32 offset, void *dest, size_t size);
u32 offset, void *dest,
size_t size); /* mandatory */
void (*block_write)(struct snd_sof_dev *sof_dev, u32 bar,
u32 offset, void *src, size_t size);
u32 offset, void *src,
size_t size); /* mandatory */

/* doorbell */
irqreturn_t (*irq_handler)(int irq, void *context);
irqreturn_t (*irq_thread)(int irq, void *context);
irqreturn_t (*irq_handler)(int irq, void *context); /* mandatory */
irqreturn_t (*irq_thread)(int irq, void *context); /* mandatory */

/* mailbox */
void (*mailbox_read)(struct snd_sof_dev *sof_dev, u32 offset,
void *addr, size_t bytes);
void *addr, size_t bytes); /* mandatory */
void (*mailbox_write)(struct snd_sof_dev *sof_dev, u32 offset,
void *addr, size_t bytes);
void *addr, size_t bytes); /* mandatory */

/* ipc */
int (*send_msg)(struct snd_sof_dev *sof_dev,
struct snd_sof_ipc_msg *msg);
struct snd_sof_ipc_msg *msg); /* mandatory */
int (*get_reply)(struct snd_sof_dev *sof_dev,
struct snd_sof_ipc_msg *msg);
int (*is_ipc_ready)(struct snd_sof_dev *sof_dev);
int (*cmd_done)(struct snd_sof_dev *sof_dev, int dir);
struct snd_sof_ipc_msg *msg); /* mandatory */
int (*is_ipc_ready)(struct snd_sof_dev *sof_dev); /* mandatory */
int (*cmd_done)(struct snd_sof_dev *sof_dev, int dir); /* mandatory */

/* debug */
const struct snd_sof_debugfs_map *debug_map;
int debug_map_count;
void (*dbg_dump)(struct snd_sof_dev *sof_dev, u32 flags);
/* FW loading */
int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
int (*load_module)(struct snd_sof_dev *sof_dev,
struct snd_sof_mod_hdr *hdr); /* optional */
/*
* FW ready checks for ABI compatibility and creates
* memory windows at first boot
*/
int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id); /* mandatory */

/* connect pcm substream to a host stream */
int (*pcm_open)(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
struct snd_pcm_substream *substream); /* optional */
/* disconnect pcm substream to a host stream */
int (*pcm_close)(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
struct snd_pcm_substream *substream); /* optional */

/* host stream hw params */
int (*pcm_hw_params)(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct sof_ipc_stream_params *ipc_params);
struct sof_ipc_stream_params *ipc_params); /* optional */

/* host stream trigger */
int (*pcm_trigger)(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream, int cmd);
struct snd_pcm_substream *substream,
int cmd); /* optional */

/* host stream pointer */
snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
struct snd_pcm_substream *substream); /* optional */

/* FW loading */
int (*load_firmware)(struct snd_sof_dev *sof_dev);
int (*load_module)(struct snd_sof_dev *sof_dev,
struct snd_sof_mod_hdr *hdr);
/* pre/post firmware run */
int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */

/*
* FW ready checks for ABI compatibility and creates
* memory windows at first boot
*/
int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id);
plbossart marked this conversation as resolved.
Show resolved Hide resolved
/* DSP PM */
int (*suspend)(struct snd_sof_dev *sof_dev, int state); /* optional */
int (*resume)(struct snd_sof_dev *sof_dev); /* optional */
int (*runtime_suspend)(struct snd_sof_dev *sof_dev,
int state); /* optional */
int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */

/* DSP clocking */
int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */

/* debug */
const struct snd_sof_debugfs_map *debug_map; /* optional */
int debug_map_count; /* optional */
void (*dbg_dump)(struct snd_sof_dev *sof_dev,
u32 flags); /* optional */

/* host DMA trace initialization */
int (*trace_init)(struct snd_sof_dev *sdev, u32 *stream_tag);
int (*trace_release)(struct snd_sof_dev *sdev);
int (*trace_trigger)(struct snd_sof_dev *sdev, int cmd);
int (*trace_init)(struct snd_sof_dev *sdev,
u32 *stream_tag); /* optional */
int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
int (*trace_trigger)(struct snd_sof_dev *sdev,
int cmd); /* optional */

/* DAI ops */
struct snd_soc_dai_driver *drv;
Expand Down