Lines Matching refs:ctx

29 static struct crystalhd_user *bc_cproc_get_uid(struct crystalhd_cmd *ctx)
35 if (!ctx->user[i].in_use) {
36 user = &ctx->user[i];
44 static int bc_cproc_get_user_count(struct crystalhd_cmd *ctx)
49 if (ctx->user[i].in_use)
56 static void bc_cproc_mark_pwr_state(struct crystalhd_cmd *ctx)
61 if (!ctx->user[i].in_use)
63 if (ctx->user[i].mode == DTS_DIAG_MODE ||
64 ctx->user[i].mode == DTS_PLAYBACK_MODE) {
65 ctx->pwr_state_change = 1;
71 static enum BC_STATUS bc_cproc_notify_mode(struct crystalhd_cmd *ctx,
76 if (!ctx || !idata) {
81 if (ctx->user[idata->u_id].mode != DTS_MODE_INV) {
86 ctx->user[idata->u_id].mode = idata->udata.u.NotifyMode.Mode;
89 if (ctx->state != BC_LINK_INVALID) {
90 BCMLOG_ERR("Link invalid state %d\n", ctx->state);
95 if (ctx->user[i].mode == DTS_DIAG_MODE ||
96 ctx->user[i].mode == DTS_PLAYBACK_MODE) {
102 ctx->cin_wait_exit = 0;
103 ctx->user[idata->u_id].mode = idata->udata.u.NotifyMode.Mode;
105 rc = crystalhd_create_dio_pool(ctx->adp, BC_LINK_MAX_SGLS);
110 return crystalhd_hw_setup_dma_rings(&ctx->hw_ctx);
113 static enum BC_STATUS bc_cproc_get_version(struct crystalhd_cmd *ctx,
117 if (!ctx || !idata) {
128 static enum BC_STATUS bc_cproc_get_hwtype(struct crystalhd_cmd *ctx,
131 if (!ctx || !idata) {
136 crystalhd_pci_cfg_rd(ctx->adp, 0, 2,
138 crystalhd_pci_cfg_rd(ctx->adp, 2, 2,
140 crystalhd_pci_cfg_rd(ctx->adp, 8, 1,
146 static enum BC_STATUS bc_cproc_reg_rd(struct crystalhd_cmd *ctx,
149 if (!ctx || !idata)
151 idata->udata.u.regAcc.Value = bc_dec_reg_rd(ctx->adp,
156 static enum BC_STATUS bc_cproc_reg_wr(struct crystalhd_cmd *ctx,
159 if (!ctx || !idata)
162 bc_dec_reg_wr(ctx->adp, idata->udata.u.regAcc.Offset,
168 static enum BC_STATUS bc_cproc_link_reg_rd(struct crystalhd_cmd *ctx,
171 if (!ctx || !idata)
174 idata->udata.u.regAcc.Value = crystalhd_reg_rd(ctx->adp,
179 static enum BC_STATUS bc_cproc_link_reg_wr(struct crystalhd_cmd *ctx,
182 if (!ctx || !idata)
185 crystalhd_reg_wr(ctx->adp, idata->udata.u.regAcc.Offset,
191 static enum BC_STATUS bc_cproc_mem_rd(struct crystalhd_cmd *ctx,
196 if (!ctx || !idata || !idata->add_cdata)
203 sts = crystalhd_mem_rd(ctx->adp, idata->udata.u.devMem.StartOff,
210 static enum BC_STATUS bc_cproc_mem_wr(struct crystalhd_cmd *ctx,
215 if (!ctx || !idata || !idata->add_cdata)
223 sts = crystalhd_mem_wr(ctx->adp, idata->udata.u.devMem.StartOff,
229 static enum BC_STATUS bc_cproc_cfg_rd(struct crystalhd_cmd *ctx,
236 if (!ctx || !idata)
244 return crystalhd_pci_cfg_rd(ctx->adp, off, len, temp);
250 sts = crystalhd_pci_cfg_rd(ctx->adp, off, len, &temp[ix]);
261 static enum BC_STATUS bc_cproc_cfg_wr(struct crystalhd_cmd *ctx,
268 if (!ctx || !idata)
276 return crystalhd_pci_cfg_wr(ctx->adp, off, len, temp[0]);
282 sts = crystalhd_pci_cfg_wr(ctx->adp, off, len, temp[ix]);
293 static enum BC_STATUS bc_cproc_download_fw(struct crystalhd_cmd *ctx,
298 if (!ctx || !idata || !idata->add_cdata || !idata->add_cdata_sz) {
303 if (ctx->state != BC_LINK_INVALID) {
304 BCMLOG_ERR("Link invalid state %d\n", ctx->state);
308 sts = crystalhd_download_fw(ctx->adp, (uint8_t *)idata->add_cdata,
314 ctx->state |= BC_LINK_INIT;
332 static enum BC_STATUS bc_cproc_do_fw_cmd(struct crystalhd_cmd *ctx,
338 if (!(ctx->state & BC_LINK_INIT)) {
339 BCMLOG_ERR("Link invalid state %d\n", ctx->state);
348 ctx->state &= ~BC_LINK_PAUSED;
349 crystalhd_hw_unpause(&ctx->hw_ctx);
354 ctx->cin_wait_exit = 1;
357 sts = crystalhd_do_fw_cmd(&ctx->hw_ctx, &idata->udata.u.fwCmd);
367 ctx->state |= BC_LINK_PAUSED;
368 crystalhd_hw_pause(&ctx->hw_ctx);
390 static enum BC_STATUS bc_cproc_codein_sleep(struct crystalhd_cmd *ctx)
395 if (ctx->state & BC_LINK_SUSPEND)
398 if (ctx->cin_wait_exit) {
399 ctx->cin_wait_exit = 0;
410 static enum BC_STATUS bc_cproc_hw_txdma(struct crystalhd_cmd *ctx,
419 if (!ctx || !idata || !dio) {
426 ctx->tx_list_id = 0;
428 sts = crystalhd_hw_post_tx(&ctx->hw_ctx, dio, bc_proc_in_completion,
433 sts = bc_cproc_codein_sleep(ctx);
436 sts = crystalhd_hw_post_tx(&ctx->hw_ctx, dio,
445 if (ctx->cin_wait_exit)
446 ctx->cin_wait_exit = 0;
448 ctx->tx_list_id = tx_listid;
452 ctx->tx_list_id = 0;
469 crystalhd_hw_cancel_tx(&ctx->hw_ctx, tx_listid);
506 static enum BC_STATUS bc_cproc_proc_input(struct crystalhd_cmd *ctx,
514 if (!ctx || !idata) {
526 sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz, 0, 0, 1, &dio_hnd);
535 sts = bc_cproc_hw_txdma(ctx, idata, dio_hnd);
537 crystalhd_unmap_dio(ctx->adp, dio_hnd);
542 static enum BC_STATUS bc_cproc_add_cap_buff(struct crystalhd_cmd *ctx,
551 if (!ctx || !idata) {
565 sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz, uv_off,
575 sts = crystalhd_hw_add_cap_buffer(&ctx->hw_ctx, dio_hnd, (ctx->state == BC_LINK_READY));
577 crystalhd_unmap_dio(ctx->adp, dio_hnd);
584 static enum BC_STATUS bc_cproc_fmt_change(struct crystalhd_cmd *ctx,
589 sts = crystalhd_hw_add_cap_buffer(&ctx->hw_ctx, dio, 0);
593 ctx->state |= BC_LINK_FMT_CHG;
594 if (ctx->state == BC_LINK_READY)
595 sts = crystalhd_hw_start_capture(&ctx->hw_ctx);
600 static enum BC_STATUS bc_cproc_fetch_frame(struct crystalhd_cmd *ctx,
607 if (!ctx || !idata) {
612 if (!(ctx->state & BC_LINK_CAP_EN)) {
613 BCMLOG(BCMLOG_DBG, "Capture not enabled..%x\n", ctx->state);
619 sts = crystalhd_hw_get_cap_buffer(&ctx->hw_ctx, &frame->PibInfo, &dio);
621 return (ctx->state & BC_LINK_SUSPEND) ? BC_STS_IO_USER_ABORT : sts;
626 return bc_cproc_fmt_change(ctx, dio);
636 crystalhd_unmap_dio(ctx->adp, dio);
641 static enum BC_STATUS bc_cproc_start_capture(struct crystalhd_cmd *ctx,
644 ctx->state |= BC_LINK_CAP_EN;
645 if (ctx->state == BC_LINK_READY)
646 return crystalhd_hw_start_capture(&ctx->hw_ctx);
651 static enum BC_STATUS bc_cproc_flush_cap_buffs(struct crystalhd_cmd *ctx,
659 if (!ctx || !idata) {
664 if (!(ctx->state & BC_LINK_CAP_EN))
668 if (!(ctx->state & BC_LINK_READY))
669 return crystalhd_hw_stop_capture(&ctx->hw_ctx);
671 ctx->state &= ~(BC_LINK_CAP_EN|BC_LINK_FMT_CHG);
676 sts = crystalhd_hw_get_cap_buffer(&ctx->hw_ctx, &frame->PibInfo, &dio);
680 crystalhd_unmap_dio(ctx->adp, dio);
683 return crystalhd_hw_stop_capture(&ctx->hw_ctx);
686 static enum BC_STATUS bc_cproc_get_stats(struct crystalhd_cmd *ctx,
692 if (!ctx || !idata) {
697 crystalhd_hw_stats(&ctx->hw_ctx, &hw_stats);
710 if (ctx->pwr_state_change)
712 if (ctx->state & BC_LINK_PAUSED)
718 static enum BC_STATUS bc_cproc_reset_stats(struct crystalhd_cmd *ctx,
721 crystalhd_hw_stats(&ctx->hw_ctx, NULL);
726 static enum BC_STATUS bc_cproc_chg_clk(struct crystalhd_cmd *ctx,
733 if (!ctx || !idata) {
739 oldClk = ctx->hw_ctx.core_clock_mhz;
740 ctx->hw_ctx.core_clock_mhz = clock->clk;
742 if (ctx->state & BC_LINK_READY) {
743 sts = crystalhd_hw_set_core_clock(&ctx->hw_ctx);
745 ctx->hw_ctx.core_clock_mhz = oldClk;
748 clock->clk = ctx->hw_ctx.core_clock_mhz;
783 * @ctx: Command layer context.
801 enum BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx,
806 if (!ctx || !idata) {
811 if (ctx->state & BC_LINK_SUSPEND)
814 if (ctx->state == BC_LINK_INVALID) {
819 ctx->state |= BC_LINK_SUSPEND;
821 bc_cproc_mark_pwr_state(ctx);
823 if (ctx->state & BC_LINK_CAP_EN) {
824 sts = bc_cproc_flush_cap_buffs(ctx, idata);
829 if (ctx->tx_list_id) {
830 sts = crystalhd_hw_cancel_tx(&ctx->hw_ctx, ctx->tx_list_id);
835 sts = crystalhd_hw_suspend(&ctx->hw_ctx);
846 * @ctx: Command layer contextx.
860 enum BC_STATUS crystalhd_resume(struct crystalhd_cmd *ctx)
862 BCMLOG(BCMLOG_DBG, "crystalhd_resume Success %x\n", ctx->state);
864 bc_cproc_mark_pwr_state(ctx);
871 * @ctx: Command layer contextx.
881 enum BC_STATUS crystalhd_user_open(struct crystalhd_cmd *ctx,
886 if (!ctx || !user_ctx) {
891 uc = bc_cproc_get_uid(ctx);
899 crystalhd_hw_open(&ctx->hw_ctx, ctx->adp);
910 * @ctx: Command layer contextx.
919 enum BC_STATUS crystalhd_user_close(struct crystalhd_cmd *ctx, struct crystalhd_user *uc)
923 ctx->user[uc->uid].mode = DTS_MODE_INV;
924 ctx->user[uc->uid].in_use = 0;
925 ctx->cin_wait_exit = 1;
926 ctx->pwr_state_change = 0;
931 crystalhd_hw_free_dma_rings(&ctx->hw_ctx);
932 crystalhd_destroy_dio_pool(ctx->adp);
933 } else if (bc_cproc_get_user_count(ctx)) {
937 crystalhd_hw_close(&ctx->hw_ctx);
939 ctx->state = BC_LINK_INVALID;
946 * @ctx: Command layer contextx.
954 enum BC_STATUS __devinit crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx,
959 if (!ctx || !adp) {
964 if (ctx->adp)
967 ctx->adp = adp;
969 ctx->user[i].uid = i;
970 ctx->user[i].in_use = 0;
971 ctx->user[i].mode = DTS_MODE_INV;
975 crystalhd_hw_open(&ctx->hw_ctx, ctx->adp);
976 crystalhd_hw_close(&ctx->hw_ctx);
982 * @ctx: Command layer contextx.
989 enum BC_STATUS __devexit crystalhd_delete_cmd_context(struct crystalhd_cmd *ctx)
993 ctx->adp = NULL;
1000 * @ctx: Command layer contextx.
1011 crystalhd_cmd_proc crystalhd_get_cmd_proc(struct crystalhd_cmd *ctx, uint32_t cmd,
1017 if (!ctx) {
1022 if ((cmd != BCM_IOC_GET_DRV_STAT) && (ctx->state & BC_LINK_SUSPEND)) {
1045 * @ctx: Command layer contextx.
1053 bool crystalhd_cmd_interrupt(struct crystalhd_cmd *ctx)
1055 if (!ctx) {
1060 return crystalhd_hw_interrupt(ctx->adp, &ctx->hw_ctx);