Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. |
| 3 | * |
| 4 | * This source file is released under GPL v2 license (no other versions). |
| 5 | * See the COPYING file included in the main directory of this source |
| 6 | * distribution for the license terms and conditions. |
| 7 | * |
| 8 | * @File ctdaio.c |
| 9 | * |
| 10 | * @Brief |
| 11 | * This file contains the implementation of Digital Audio Input Output |
| 12 | * resource management object. |
| 13 | * |
| 14 | * @Author Liu Chun |
| 15 | * @Date May 23 2008 |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include "ctdaio.h" |
| 20 | #include "cthardware.h" |
| 21 | #include "ctimap.h" |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/kernel.h> |
| 24 | |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 25 | #define DAIO_OUT_MAX SPDIFOO |
| 26 | |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 27 | struct daio_usage { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 28 | unsigned short data; |
| 29 | }; |
| 30 | |
| 31 | struct daio_rsc_idx { |
| 32 | unsigned short left; |
| 33 | unsigned short right; |
| 34 | }; |
| 35 | |
Sachin Kamat | b71495e | 2013-09-13 15:14:21 +0530 | [diff] [blame] | 36 | static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 37 | [LINEO1] = {.left = 0x00, .right = 0x01}, |
| 38 | [LINEO2] = {.left = 0x18, .right = 0x19}, |
| 39 | [LINEO3] = {.left = 0x08, .right = 0x09}, |
| 40 | [LINEO4] = {.left = 0x10, .right = 0x11}, |
| 41 | [LINEIM] = {.left = 0x1b5, .right = 0x1bd}, |
| 42 | [SPDIFOO] = {.left = 0x20, .right = 0x21}, |
| 43 | [SPDIFIO] = {.left = 0x15, .right = 0x1d}, |
| 44 | [SPDIFI1] = {.left = 0x95, .right = 0x9d}, |
| 45 | }; |
| 46 | |
Sachin Kamat | b71495e | 2013-09-13 15:14:21 +0530 | [diff] [blame] | 47 | static struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 48 | [LINEO1] = {.left = 0x40, .right = 0x41}, |
Frank Roth | 55fe27f | 2009-07-20 17:00:14 +0200 | [diff] [blame] | 49 | [LINEO2] = {.left = 0x60, .right = 0x61}, |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 50 | [LINEO3] = {.left = 0x50, .right = 0x51}, |
Frank Roth | 55fe27f | 2009-07-20 17:00:14 +0200 | [diff] [blame] | 51 | [LINEO4] = {.left = 0x70, .right = 0x71}, |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 52 | [LINEIM] = {.left = 0x45, .right = 0xc5}, |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 53 | [MIC] = {.left = 0x55, .right = 0xd5}, |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 54 | [SPDIFOO] = {.left = 0x00, .right = 0x01}, |
| 55 | [SPDIFIO] = {.left = 0x05, .right = 0x85}, |
| 56 | }; |
| 57 | |
| 58 | static int daio_master(struct rsc *rsc) |
| 59 | { |
| 60 | /* Actually, this is not the resource index of DAIO. |
| 61 | * For DAO, it is the input mapper index. And, for DAI, |
| 62 | * it is the output time-slot index. */ |
| 63 | return rsc->conj = rsc->idx; |
| 64 | } |
| 65 | |
| 66 | static int daio_index(const struct rsc *rsc) |
| 67 | { |
| 68 | return rsc->conj; |
| 69 | } |
| 70 | |
| 71 | static int daio_out_next_conj(struct rsc *rsc) |
| 72 | { |
| 73 | return rsc->conj += 2; |
| 74 | } |
| 75 | |
| 76 | static int daio_in_next_conj_20k1(struct rsc *rsc) |
| 77 | { |
| 78 | return rsc->conj += 0x200; |
| 79 | } |
| 80 | |
| 81 | static int daio_in_next_conj_20k2(struct rsc *rsc) |
| 82 | { |
| 83 | return rsc->conj += 0x100; |
| 84 | } |
| 85 | |
Julia Lawall | 43f2cde | 2015-11-08 23:40:41 +0100 | [diff] [blame] | 86 | static const struct rsc_ops daio_out_rsc_ops = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 87 | .master = daio_master, |
| 88 | .next_conj = daio_out_next_conj, |
| 89 | .index = daio_index, |
| 90 | .output_slot = NULL, |
| 91 | }; |
| 92 | |
Julia Lawall | 43f2cde | 2015-11-08 23:40:41 +0100 | [diff] [blame] | 93 | static const struct rsc_ops daio_in_rsc_ops_20k1 = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 94 | .master = daio_master, |
| 95 | .next_conj = daio_in_next_conj_20k1, |
| 96 | .index = NULL, |
| 97 | .output_slot = daio_index, |
| 98 | }; |
| 99 | |
Julia Lawall | 43f2cde | 2015-11-08 23:40:41 +0100 | [diff] [blame] | 100 | static const struct rsc_ops daio_in_rsc_ops_20k2 = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 101 | .master = daio_master, |
| 102 | .next_conj = daio_in_next_conj_20k2, |
| 103 | .index = NULL, |
| 104 | .output_slot = daio_index, |
| 105 | }; |
| 106 | |
| 107 | static unsigned int daio_device_index(enum DAIOTYP type, struct hw *hw) |
| 108 | { |
Takashi Iwai | 9470195 | 2009-06-08 18:10:32 +0200 | [diff] [blame] | 109 | switch (hw->chip_type) { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 110 | case ATC20K1: |
| 111 | switch (type) { |
| 112 | case SPDIFOO: return 0; |
| 113 | case SPDIFIO: return 0; |
| 114 | case SPDIFI1: return 1; |
| 115 | case LINEO1: return 4; |
| 116 | case LINEO2: return 7; |
| 117 | case LINEO3: return 5; |
| 118 | case LINEO4: return 6; |
| 119 | case LINEIM: return 7; |
| 120 | default: return -EINVAL; |
| 121 | } |
| 122 | case ATC20K2: |
| 123 | switch (type) { |
| 124 | case SPDIFOO: return 0; |
| 125 | case SPDIFIO: return 0; |
| 126 | case LINEO1: return 4; |
| 127 | case LINEO2: return 7; |
| 128 | case LINEO3: return 5; |
| 129 | case LINEO4: return 6; |
| 130 | case LINEIM: return 4; |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 131 | case MIC: return 5; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 132 | default: return -EINVAL; |
| 133 | } |
| 134 | default: |
| 135 | return -EINVAL; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | static int dao_rsc_reinit(struct dao *dao, const struct dao_desc *desc); |
| 140 | |
| 141 | static int dao_spdif_get_spos(struct dao *dao, unsigned int *spos) |
| 142 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 143 | dao->hw->dao_get_spos(dao->ctrl_blk, spos); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | static int dao_spdif_set_spos(struct dao *dao, unsigned int spos) |
| 148 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 149 | dao->hw->dao_set_spos(dao->ctrl_blk, spos); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static int dao_commit_write(struct dao *dao) |
| 154 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 155 | dao->hw->dao_commit_write(dao->hw, |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 156 | daio_device_index(dao->daio.type, dao->hw), dao->ctrl_blk); |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | static int dao_set_left_input(struct dao *dao, struct rsc *input) |
| 161 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 162 | struct imapper *entry; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 163 | struct daio *daio = &dao->daio; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 164 | int i; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 165 | |
| 166 | entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL); |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 167 | if (!entry) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 168 | return -ENOMEM; |
| 169 | |
Przemyslaw Bruski | efed5f2 | 2011-03-13 16:18:58 +0100 | [diff] [blame] | 170 | dao->ops->clear_left_input(dao); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 171 | /* Program master and conjugate resources */ |
| 172 | input->ops->master(input); |
| 173 | daio->rscl.ops->master(&daio->rscl); |
| 174 | for (i = 0; i < daio->rscl.msr; i++, entry++) { |
| 175 | entry->slot = input->ops->output_slot(input); |
| 176 | entry->user = entry->addr = daio->rscl.ops->index(&daio->rscl); |
| 177 | dao->mgr->imap_add(dao->mgr, entry); |
| 178 | dao->imappers[i] = entry; |
| 179 | |
| 180 | input->ops->next_conj(input); |
| 181 | daio->rscl.ops->next_conj(&daio->rscl); |
| 182 | } |
| 183 | input->ops->master(input); |
| 184 | daio->rscl.ops->master(&daio->rscl); |
| 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | static int dao_set_right_input(struct dao *dao, struct rsc *input) |
| 190 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 191 | struct imapper *entry; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 192 | struct daio *daio = &dao->daio; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 193 | int i; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 194 | |
| 195 | entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL); |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 196 | if (!entry) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 197 | return -ENOMEM; |
| 198 | |
Przemyslaw Bruski | efed5f2 | 2011-03-13 16:18:58 +0100 | [diff] [blame] | 199 | dao->ops->clear_right_input(dao); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 200 | /* Program master and conjugate resources */ |
| 201 | input->ops->master(input); |
| 202 | daio->rscr.ops->master(&daio->rscr); |
| 203 | for (i = 0; i < daio->rscr.msr; i++, entry++) { |
| 204 | entry->slot = input->ops->output_slot(input); |
| 205 | entry->user = entry->addr = daio->rscr.ops->index(&daio->rscr); |
| 206 | dao->mgr->imap_add(dao->mgr, entry); |
| 207 | dao->imappers[daio->rscl.msr + i] = entry; |
| 208 | |
| 209 | input->ops->next_conj(input); |
| 210 | daio->rscr.ops->next_conj(&daio->rscr); |
| 211 | } |
| 212 | input->ops->master(input); |
| 213 | daio->rscr.ops->master(&daio->rscr); |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | static int dao_clear_left_input(struct dao *dao) |
| 219 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 220 | struct imapper *entry; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 221 | struct daio *daio = &dao->daio; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 222 | int i; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 223 | |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 224 | if (!dao->imappers[0]) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 225 | return 0; |
| 226 | |
| 227 | entry = dao->imappers[0]; |
| 228 | dao->mgr->imap_delete(dao->mgr, entry); |
| 229 | /* Program conjugate resources */ |
| 230 | for (i = 1; i < daio->rscl.msr; i++) { |
| 231 | entry = dao->imappers[i]; |
| 232 | dao->mgr->imap_delete(dao->mgr, entry); |
| 233 | dao->imappers[i] = NULL; |
| 234 | } |
| 235 | |
| 236 | kfree(dao->imappers[0]); |
| 237 | dao->imappers[0] = NULL; |
| 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | static int dao_clear_right_input(struct dao *dao) |
| 243 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 244 | struct imapper *entry; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 245 | struct daio *daio = &dao->daio; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 246 | int i; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 247 | |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 248 | if (!dao->imappers[daio->rscl.msr]) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 249 | return 0; |
| 250 | |
| 251 | entry = dao->imappers[daio->rscl.msr]; |
| 252 | dao->mgr->imap_delete(dao->mgr, entry); |
| 253 | /* Program conjugate resources */ |
| 254 | for (i = 1; i < daio->rscr.msr; i++) { |
| 255 | entry = dao->imappers[daio->rscl.msr + i]; |
| 256 | dao->mgr->imap_delete(dao->mgr, entry); |
| 257 | dao->imappers[daio->rscl.msr + i] = NULL; |
| 258 | } |
| 259 | |
| 260 | kfree(dao->imappers[daio->rscl.msr]); |
| 261 | dao->imappers[daio->rscl.msr] = NULL; |
| 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | |
Julia Lawall | 43f2cde | 2015-11-08 23:40:41 +0100 | [diff] [blame] | 266 | static const struct dao_rsc_ops dao_ops = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 267 | .set_spos = dao_spdif_set_spos, |
| 268 | .commit_write = dao_commit_write, |
| 269 | .get_spos = dao_spdif_get_spos, |
| 270 | .reinit = dao_rsc_reinit, |
| 271 | .set_left_input = dao_set_left_input, |
| 272 | .set_right_input = dao_set_right_input, |
| 273 | .clear_left_input = dao_clear_left_input, |
| 274 | .clear_right_input = dao_clear_right_input, |
| 275 | }; |
| 276 | |
| 277 | static int dai_set_srt_srcl(struct dai *dai, struct rsc *src) |
| 278 | { |
| 279 | src->ops->master(src); |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 280 | dai->hw->dai_srt_set_srcm(dai->ctrl_blk, src->ops->index(src)); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | static int dai_set_srt_srcr(struct dai *dai, struct rsc *src) |
| 285 | { |
| 286 | src->ops->master(src); |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 287 | dai->hw->dai_srt_set_srco(dai->ctrl_blk, src->ops->index(src)); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | static int dai_set_srt_msr(struct dai *dai, unsigned int msr) |
| 292 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 293 | unsigned int rsr; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 294 | |
| 295 | for (rsr = 0; msr > 1; msr >>= 1) |
| 296 | rsr++; |
| 297 | |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 298 | dai->hw->dai_srt_set_rsr(dai->ctrl_blk, rsr); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | static int dai_set_enb_src(struct dai *dai, unsigned int enb) |
| 303 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 304 | dai->hw->dai_srt_set_ec(dai->ctrl_blk, enb); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | static int dai_set_enb_srt(struct dai *dai, unsigned int enb) |
| 309 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 310 | dai->hw->dai_srt_set_et(dai->ctrl_blk, enb); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | static int dai_commit_write(struct dai *dai) |
| 315 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 316 | dai->hw->dai_commit_write(dai->hw, |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 317 | daio_device_index(dai->daio.type, dai->hw), dai->ctrl_blk); |
| 318 | return 0; |
| 319 | } |
| 320 | |
Julia Lawall | 43f2cde | 2015-11-08 23:40:41 +0100 | [diff] [blame] | 321 | static const struct dai_rsc_ops dai_ops = { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 322 | .set_srt_srcl = dai_set_srt_srcl, |
| 323 | .set_srt_srcr = dai_set_srt_srcr, |
| 324 | .set_srt_msr = dai_set_srt_msr, |
| 325 | .set_enb_src = dai_set_enb_src, |
| 326 | .set_enb_srt = dai_set_enb_srt, |
| 327 | .commit_write = dai_commit_write, |
| 328 | }; |
| 329 | |
| 330 | static int daio_rsc_init(struct daio *daio, |
| 331 | const struct daio_desc *desc, |
Sudip Mukherjee | 6664089 | 2014-09-29 14:33:21 +0530 | [diff] [blame] | 332 | struct hw *hw) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 333 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 334 | int err; |
| 335 | unsigned int idx_l, idx_r; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 336 | |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 337 | switch (hw->chip_type) { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 338 | case ATC20K1: |
| 339 | idx_l = idx_20k1[desc->type].left; |
| 340 | idx_r = idx_20k1[desc->type].right; |
| 341 | break; |
| 342 | case ATC20K2: |
| 343 | idx_l = idx_20k2[desc->type].left; |
| 344 | idx_r = idx_20k2[desc->type].right; |
| 345 | break; |
| 346 | default: |
| 347 | return -EINVAL; |
| 348 | } |
| 349 | err = rsc_init(&daio->rscl, idx_l, DAIO, desc->msr, hw); |
| 350 | if (err) |
| 351 | return err; |
| 352 | |
| 353 | err = rsc_init(&daio->rscr, idx_r, DAIO, desc->msr, hw); |
| 354 | if (err) |
| 355 | goto error1; |
| 356 | |
| 357 | /* Set daio->rscl/r->ops to daio specific ones */ |
| 358 | if (desc->type <= DAIO_OUT_MAX) { |
| 359 | daio->rscl.ops = daio->rscr.ops = &daio_out_rsc_ops; |
| 360 | } else { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 361 | switch (hw->chip_type) { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 362 | case ATC20K1: |
| 363 | daio->rscl.ops = daio->rscr.ops = &daio_in_rsc_ops_20k1; |
| 364 | break; |
| 365 | case ATC20K2: |
| 366 | daio->rscl.ops = daio->rscr.ops = &daio_in_rsc_ops_20k2; |
| 367 | break; |
| 368 | default: |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | daio->type = desc->type; |
| 373 | |
| 374 | return 0; |
| 375 | |
| 376 | error1: |
| 377 | rsc_uninit(&daio->rscl); |
| 378 | return err; |
| 379 | } |
| 380 | |
| 381 | static int daio_rsc_uninit(struct daio *daio) |
| 382 | { |
| 383 | rsc_uninit(&daio->rscl); |
| 384 | rsc_uninit(&daio->rscr); |
| 385 | |
| 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | static int dao_rsc_init(struct dao *dao, |
| 390 | const struct daio_desc *desc, |
| 391 | struct daio_mgr *mgr) |
| 392 | { |
| 393 | struct hw *hw = mgr->mgr.hw; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 394 | unsigned int conf; |
| 395 | int err; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 396 | |
| 397 | err = daio_rsc_init(&dao->daio, desc, mgr->mgr.hw); |
| 398 | if (err) |
| 399 | return err; |
| 400 | |
| 401 | dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 402 | if (!dao->imappers) { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 403 | err = -ENOMEM; |
| 404 | goto error1; |
| 405 | } |
| 406 | dao->ops = &dao_ops; |
| 407 | dao->mgr = mgr; |
| 408 | dao->hw = hw; |
| 409 | err = hw->dao_get_ctrl_blk(&dao->ctrl_blk); |
| 410 | if (err) |
| 411 | goto error2; |
| 412 | |
| 413 | hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, |
| 414 | daio_device_index(dao->daio.type, hw)); |
| 415 | hw->daio_mgr_commit_write(hw, mgr->mgr.ctrl_blk); |
| 416 | |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 417 | conf = (desc->msr & 0x7) | (desc->passthru << 3); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 418 | hw->daio_mgr_dao_init(mgr->mgr.ctrl_blk, |
| 419 | daio_device_index(dao->daio.type, hw), conf); |
| 420 | hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, |
| 421 | daio_device_index(dao->daio.type, hw)); |
| 422 | hw->daio_mgr_commit_write(hw, mgr->mgr.ctrl_blk); |
| 423 | |
| 424 | return 0; |
| 425 | |
| 426 | error2: |
| 427 | kfree(dao->imappers); |
| 428 | dao->imappers = NULL; |
| 429 | error1: |
| 430 | daio_rsc_uninit(&dao->daio); |
| 431 | return err; |
| 432 | } |
| 433 | |
| 434 | static int dao_rsc_uninit(struct dao *dao) |
| 435 | { |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 436 | if (dao->imappers) { |
| 437 | if (dao->imappers[0]) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 438 | dao_clear_left_input(dao); |
| 439 | |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 440 | if (dao->imappers[dao->daio.rscl.msr]) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 441 | dao_clear_right_input(dao); |
| 442 | |
| 443 | kfree(dao->imappers); |
| 444 | dao->imappers = NULL; |
| 445 | } |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 446 | dao->hw->dao_put_ctrl_blk(dao->ctrl_blk); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 447 | dao->hw = dao->ctrl_blk = NULL; |
| 448 | daio_rsc_uninit(&dao->daio); |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | static int dao_rsc_reinit(struct dao *dao, const struct dao_desc *desc) |
| 454 | { |
| 455 | struct daio_mgr *mgr = dao->mgr; |
| 456 | struct daio_desc dsc = {0}; |
| 457 | |
| 458 | dsc.type = dao->daio.type; |
| 459 | dsc.msr = desc->msr; |
| 460 | dsc.passthru = desc->passthru; |
| 461 | dao_rsc_uninit(dao); |
| 462 | return dao_rsc_init(dao, &dsc, mgr); |
| 463 | } |
| 464 | |
| 465 | static int dai_rsc_init(struct dai *dai, |
| 466 | const struct daio_desc *desc, |
| 467 | struct daio_mgr *mgr) |
| 468 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 469 | int err; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 470 | struct hw *hw = mgr->mgr.hw; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 471 | unsigned int rsr, msr; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 472 | |
| 473 | err = daio_rsc_init(&dai->daio, desc, mgr->mgr.hw); |
| 474 | if (err) |
| 475 | return err; |
| 476 | |
| 477 | dai->ops = &dai_ops; |
| 478 | dai->hw = mgr->mgr.hw; |
| 479 | err = hw->dai_get_ctrl_blk(&dai->ctrl_blk); |
| 480 | if (err) |
| 481 | goto error1; |
| 482 | |
| 483 | for (rsr = 0, msr = desc->msr; msr > 1; msr >>= 1) |
| 484 | rsr++; |
| 485 | |
| 486 | hw->dai_srt_set_rsr(dai->ctrl_blk, rsr); |
| 487 | hw->dai_srt_set_drat(dai->ctrl_blk, 0); |
| 488 | /* default to disabling control of a SRC */ |
| 489 | hw->dai_srt_set_ec(dai->ctrl_blk, 0); |
| 490 | hw->dai_srt_set_et(dai->ctrl_blk, 0); /* default to disabling SRT */ |
| 491 | hw->dai_commit_write(hw, |
| 492 | daio_device_index(dai->daio.type, dai->hw), dai->ctrl_blk); |
| 493 | |
| 494 | return 0; |
| 495 | |
| 496 | error1: |
| 497 | daio_rsc_uninit(&dai->daio); |
| 498 | return err; |
| 499 | } |
| 500 | |
| 501 | static int dai_rsc_uninit(struct dai *dai) |
| 502 | { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 503 | dai->hw->dai_put_ctrl_blk(dai->ctrl_blk); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 504 | dai->hw = dai->ctrl_blk = NULL; |
| 505 | daio_rsc_uninit(&dai->daio); |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | static int daio_mgr_get_rsc(struct rsc_mgr *mgr, enum DAIOTYP type) |
| 510 | { |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 511 | if (((struct daio_usage *)mgr->rscs)->data & (0x1 << type)) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 512 | return -ENOENT; |
| 513 | |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 514 | ((struct daio_usage *)mgr->rscs)->data |= (0x1 << type); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 515 | |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | static int daio_mgr_put_rsc(struct rsc_mgr *mgr, enum DAIOTYP type) |
| 520 | { |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 521 | ((struct daio_usage *)mgr->rscs)->data &= ~(0x1 << type); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 522 | |
| 523 | return 0; |
| 524 | } |
| 525 | |
| 526 | static int get_daio_rsc(struct daio_mgr *mgr, |
| 527 | const struct daio_desc *desc, |
| 528 | struct daio **rdaio) |
| 529 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 530 | int err; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 531 | unsigned long flags; |
| 532 | |
| 533 | *rdaio = NULL; |
| 534 | |
| 535 | /* Check whether there are sufficient daio resources to meet request. */ |
| 536 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
| 537 | err = daio_mgr_get_rsc(&mgr->mgr, desc->type); |
| 538 | spin_unlock_irqrestore(&mgr->mgr_lock, flags); |
| 539 | if (err) { |
Sudip Mukherjee | 0cae90a | 2014-09-29 14:33:26 +0530 | [diff] [blame] | 540 | dev_err(mgr->card->dev, |
| 541 | "Can't meet DAIO resource request!\n"); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 542 | return err; |
| 543 | } |
| 544 | |
Joe Perches | 5395103 | 2014-12-03 09:59:31 -0800 | [diff] [blame] | 545 | err = -ENOMEM; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 546 | /* Allocate mem for daio resource */ |
| 547 | if (desc->type <= DAIO_OUT_MAX) { |
Joe Perches | 5395103 | 2014-12-03 09:59:31 -0800 | [diff] [blame] | 548 | struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL); |
| 549 | if (!dao) |
| 550 | goto error; |
| 551 | |
| 552 | err = dao_rsc_init(dao, desc, mgr); |
| 553 | if (err) { |
| 554 | kfree(dao); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 555 | goto error; |
| 556 | } |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 557 | |
| 558 | *rdaio = &dao->daio; |
| 559 | } else { |
Joe Perches | 5395103 | 2014-12-03 09:59:31 -0800 | [diff] [blame] | 560 | struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL); |
| 561 | if (!dai) |
| 562 | goto error; |
| 563 | |
| 564 | err = dai_rsc_init(dai, desc, mgr); |
| 565 | if (err) { |
| 566 | kfree(dai); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 567 | goto error; |
| 568 | } |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 569 | |
| 570 | *rdaio = &dai->daio; |
| 571 | } |
| 572 | |
| 573 | mgr->daio_enable(mgr, *rdaio); |
| 574 | mgr->commit_write(mgr); |
| 575 | |
| 576 | return 0; |
| 577 | |
| 578 | error: |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 579 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
| 580 | daio_mgr_put_rsc(&mgr->mgr, desc->type); |
| 581 | spin_unlock_irqrestore(&mgr->mgr_lock, flags); |
| 582 | return err; |
| 583 | } |
| 584 | |
| 585 | static int put_daio_rsc(struct daio_mgr *mgr, struct daio *daio) |
| 586 | { |
| 587 | unsigned long flags; |
| 588 | |
| 589 | mgr->daio_disable(mgr, daio); |
| 590 | mgr->commit_write(mgr); |
| 591 | |
| 592 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
| 593 | daio_mgr_put_rsc(&mgr->mgr, daio->type); |
| 594 | spin_unlock_irqrestore(&mgr->mgr_lock, flags); |
| 595 | |
| 596 | if (daio->type <= DAIO_OUT_MAX) { |
| 597 | dao_rsc_uninit(container_of(daio, struct dao, daio)); |
| 598 | kfree(container_of(daio, struct dao, daio)); |
| 599 | } else { |
| 600 | dai_rsc_uninit(container_of(daio, struct dai, daio)); |
| 601 | kfree(container_of(daio, struct dai, daio)); |
| 602 | } |
| 603 | |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | static int daio_mgr_enb_daio(struct daio_mgr *mgr, struct daio *daio) |
| 608 | { |
| 609 | struct hw *hw = mgr->mgr.hw; |
| 610 | |
| 611 | if (DAIO_OUT_MAX >= daio->type) { |
| 612 | hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, |
| 613 | daio_device_index(daio->type, hw)); |
| 614 | } else { |
| 615 | hw->daio_mgr_enb_dai(mgr->mgr.ctrl_blk, |
| 616 | daio_device_index(daio->type, hw)); |
| 617 | } |
| 618 | return 0; |
| 619 | } |
| 620 | |
| 621 | static int daio_mgr_dsb_daio(struct daio_mgr *mgr, struct daio *daio) |
| 622 | { |
| 623 | struct hw *hw = mgr->mgr.hw; |
| 624 | |
| 625 | if (DAIO_OUT_MAX >= daio->type) { |
| 626 | hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, |
| 627 | daio_device_index(daio->type, hw)); |
| 628 | } else { |
| 629 | hw->daio_mgr_dsb_dai(mgr->mgr.ctrl_blk, |
| 630 | daio_device_index(daio->type, hw)); |
| 631 | } |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | static int daio_map_op(void *data, struct imapper *entry) |
| 636 | { |
| 637 | struct rsc_mgr *mgr = &((struct daio_mgr *)data)->mgr; |
| 638 | struct hw *hw = mgr->hw; |
| 639 | |
| 640 | hw->daio_mgr_set_imaparc(mgr->ctrl_blk, entry->slot); |
| 641 | hw->daio_mgr_set_imapnxt(mgr->ctrl_blk, entry->next); |
| 642 | hw->daio_mgr_set_imapaddr(mgr->ctrl_blk, entry->addr); |
| 643 | hw->daio_mgr_commit_write(mgr->hw, mgr->ctrl_blk); |
| 644 | |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | static int daio_imap_add(struct daio_mgr *mgr, struct imapper *entry) |
| 649 | { |
| 650 | unsigned long flags; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 651 | int err; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 652 | |
| 653 | spin_lock_irqsave(&mgr->imap_lock, flags); |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 654 | if (!entry->addr && mgr->init_imap_added) { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 655 | input_mapper_delete(&mgr->imappers, mgr->init_imap, |
| 656 | daio_map_op, mgr); |
| 657 | mgr->init_imap_added = 0; |
| 658 | } |
| 659 | err = input_mapper_add(&mgr->imappers, entry, daio_map_op, mgr); |
| 660 | spin_unlock_irqrestore(&mgr->imap_lock, flags); |
| 661 | |
| 662 | return err; |
| 663 | } |
| 664 | |
| 665 | static int daio_imap_delete(struct daio_mgr *mgr, struct imapper *entry) |
| 666 | { |
| 667 | unsigned long flags; |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 668 | int err; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 669 | |
| 670 | spin_lock_irqsave(&mgr->imap_lock, flags); |
| 671 | err = input_mapper_delete(&mgr->imappers, entry, daio_map_op, mgr); |
| 672 | if (list_empty(&mgr->imappers)) { |
| 673 | input_mapper_add(&mgr->imappers, mgr->init_imap, |
| 674 | daio_map_op, mgr); |
| 675 | mgr->init_imap_added = 1; |
| 676 | } |
| 677 | spin_unlock_irqrestore(&mgr->imap_lock, flags); |
| 678 | |
| 679 | return err; |
| 680 | } |
| 681 | |
| 682 | static int daio_mgr_commit_write(struct daio_mgr *mgr) |
| 683 | { |
| 684 | struct hw *hw = mgr->mgr.hw; |
| 685 | |
| 686 | hw->daio_mgr_commit_write(hw, mgr->mgr.ctrl_blk); |
| 687 | return 0; |
| 688 | } |
| 689 | |
Sudip Mukherjee | 6664089 | 2014-09-29 14:33:21 +0530 | [diff] [blame] | 690 | int daio_mgr_create(struct hw *hw, struct daio_mgr **rdaio_mgr) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 691 | { |
Takashi Iwai | 514eef9 | 2009-06-08 14:57:57 +0200 | [diff] [blame] | 692 | int err, i; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 693 | struct daio_mgr *daio_mgr; |
| 694 | struct imapper *entry; |
| 695 | |
| 696 | *rdaio_mgr = NULL; |
| 697 | daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL); |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 698 | if (!daio_mgr) |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 699 | return -ENOMEM; |
| 700 | |
Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 701 | err = rsc_mgr_init(&daio_mgr->mgr, DAIO, NUM_DAIOTYP, hw); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 702 | if (err) |
| 703 | goto error1; |
| 704 | |
| 705 | spin_lock_init(&daio_mgr->mgr_lock); |
| 706 | spin_lock_init(&daio_mgr->imap_lock); |
| 707 | INIT_LIST_HEAD(&daio_mgr->imappers); |
| 708 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
Takashi Iwai | 35ebf6e | 2009-07-22 17:12:34 +0200 | [diff] [blame] | 709 | if (!entry) { |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 710 | err = -ENOMEM; |
| 711 | goto error2; |
| 712 | } |
| 713 | entry->slot = entry->addr = entry->next = entry->user = 0; |
| 714 | list_add(&entry->list, &daio_mgr->imappers); |
| 715 | daio_mgr->init_imap = entry; |
| 716 | daio_mgr->init_imap_added = 1; |
| 717 | |
| 718 | daio_mgr->get_daio = get_daio_rsc; |
| 719 | daio_mgr->put_daio = put_daio_rsc; |
| 720 | daio_mgr->daio_enable = daio_mgr_enb_daio; |
| 721 | daio_mgr->daio_disable = daio_mgr_dsb_daio; |
| 722 | daio_mgr->imap_add = daio_imap_add; |
| 723 | daio_mgr->imap_delete = daio_imap_delete; |
| 724 | daio_mgr->commit_write = daio_mgr_commit_write; |
Sudip Mukherjee | e5347f9 | 2014-09-29 14:33:24 +0530 | [diff] [blame] | 725 | daio_mgr->card = hw->card; |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 726 | |
| 727 | for (i = 0; i < 8; i++) { |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 728 | hw->daio_mgr_dsb_dao(daio_mgr->mgr.ctrl_blk, i); |
| 729 | hw->daio_mgr_dsb_dai(daio_mgr->mgr.ctrl_blk, i); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 730 | } |
Sudip Mukherjee | 3d0fdc8 | 2014-09-29 14:33:23 +0530 | [diff] [blame] | 731 | hw->daio_mgr_commit_write(hw, daio_mgr->mgr.ctrl_blk); |
Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 732 | |
| 733 | *rdaio_mgr = daio_mgr; |
| 734 | |
| 735 | return 0; |
| 736 | |
| 737 | error2: |
| 738 | rsc_mgr_uninit(&daio_mgr->mgr); |
| 739 | error1: |
| 740 | kfree(daio_mgr); |
| 741 | return err; |
| 742 | } |
| 743 | |
| 744 | int daio_mgr_destroy(struct daio_mgr *daio_mgr) |
| 745 | { |
| 746 | unsigned long flags; |
| 747 | |
| 748 | /* free daio input mapper list */ |
| 749 | spin_lock_irqsave(&daio_mgr->imap_lock, flags); |
| 750 | free_input_mapper_list(&daio_mgr->imappers); |
| 751 | spin_unlock_irqrestore(&daio_mgr->imap_lock, flags); |
| 752 | |
| 753 | rsc_mgr_uninit(&daio_mgr->mgr); |
| 754 | kfree(daio_mgr); |
| 755 | |
| 756 | return 0; |
| 757 | } |
| 758 | |