Lines Matching refs:dice
11 static u64 get_subaddr(struct snd_dice *dice, enum snd_dice_addr_type type, in get_subaddr() argument
16 offset += dice->tx_offset; in get_subaddr()
19 offset += dice->rx_offset; in get_subaddr()
22 offset += dice->sync_offset; in get_subaddr()
25 offset += dice->rsrv_offset; in get_subaddr()
29 offset += dice->global_offset; in get_subaddr()
36 int snd_dice_transaction_write(struct snd_dice *dice, in snd_dice_transaction_write() argument
40 return snd_fw_transaction(dice->unit, in snd_dice_transaction_write()
43 get_subaddr(dice, type, offset), buf, len, 0); in snd_dice_transaction_write()
46 int snd_dice_transaction_read(struct snd_dice *dice, in snd_dice_transaction_read() argument
50 return snd_fw_transaction(dice->unit, in snd_dice_transaction_read()
53 get_subaddr(dice, type, offset), buf, len, 0); in snd_dice_transaction_read()
56 static unsigned int get_clock_info(struct snd_dice *dice, __be32 *info) in get_clock_info() argument
58 return snd_dice_transaction_read_global(dice, GLOBAL_CLOCK_SELECT, in get_clock_info()
62 int snd_dice_transaction_get_clock_source(struct snd_dice *dice, in snd_dice_transaction_get_clock_source() argument
68 err = get_clock_info(dice, &info); in snd_dice_transaction_get_clock_source()
75 int snd_dice_transaction_get_rate(struct snd_dice *dice, unsigned int *rate) in snd_dice_transaction_get_rate() argument
81 err = get_clock_info(dice, &info); in snd_dice_transaction_get_rate()
96 int snd_dice_transaction_set_enable(struct snd_dice *dice) in snd_dice_transaction_set_enable() argument
101 if (dice->global_enabled) in snd_dice_transaction_set_enable()
105 err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, in snd_dice_transaction_set_enable()
106 get_subaddr(dice, SND_DICE_ADDR_TYPE_GLOBAL, in snd_dice_transaction_set_enable()
109 FW_FIXED_GENERATION | dice->owner_generation); in snd_dice_transaction_set_enable()
113 dice->global_enabled = true; in snd_dice_transaction_set_enable()
118 void snd_dice_transaction_clear_enable(struct snd_dice *dice) in snd_dice_transaction_clear_enable() argument
123 snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, in snd_dice_transaction_clear_enable()
124 get_subaddr(dice, SND_DICE_ADDR_TYPE_GLOBAL, in snd_dice_transaction_clear_enable()
127 FW_FIXED_GENERATION | dice->owner_generation); in snd_dice_transaction_clear_enable()
129 dice->global_enabled = false; in snd_dice_transaction_clear_enable()
137 struct snd_dice *dice = callback_data; in dice_notification() local
152 spin_lock_irqsave(&dice->lock, flags); in dice_notification()
153 dice->notification_bits |= bits; in dice_notification()
154 spin_unlock_irqrestore(&dice->lock, flags); in dice_notification()
159 complete(&dice->clock_accepted); in dice_notification()
160 wake_up(&dice->hwdep_wait); in dice_notification()
163 static int register_notification_address(struct snd_dice *dice, bool retry) in register_notification_address() argument
165 struct fw_device *device = fw_parent_device(dice->unit); in register_notification_address()
180 dice->notification_handler.offset); in register_notification_address()
182 dice->owner_generation = device->generation; in register_notification_address()
184 err = snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP, in register_notification_address()
185 get_subaddr(dice, in register_notification_address()
190 dice->owner_generation); in register_notification_address()
199 dev_err(&dice->unit->device, in register_notification_address()
212 dice->owner_generation = -1; in register_notification_address()
217 static void unregister_notification_address(struct snd_dice *dice) in unregister_notification_address() argument
219 struct fw_device *device = fw_parent_device(dice->unit); in unregister_notification_address()
228 dice->notification_handler.offset); in unregister_notification_address()
230 snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP, in unregister_notification_address()
231 get_subaddr(dice, SND_DICE_ADDR_TYPE_GLOBAL, in unregister_notification_address()
234 FW_FIXED_GENERATION | dice->owner_generation); in unregister_notification_address()
238 dice->owner_generation = -1; in unregister_notification_address()
241 void snd_dice_transaction_destroy(struct snd_dice *dice) in snd_dice_transaction_destroy() argument
243 struct fw_address_handler *handler = &dice->notification_handler; in snd_dice_transaction_destroy()
248 unregister_notification_address(dice); in snd_dice_transaction_destroy()
254 int snd_dice_transaction_reinit(struct snd_dice *dice) in snd_dice_transaction_reinit() argument
256 struct fw_address_handler *handler = &dice->notification_handler; in snd_dice_transaction_reinit()
261 return register_notification_address(dice, false); in snd_dice_transaction_reinit()
264 static int get_subaddrs(struct snd_dice *dice) in get_subaddrs() argument
289 err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, in get_subaddrs()
308 err = snd_fw_transaction(dice->unit, TCODE_READ_QUADLET_REQUEST, in get_subaddrs()
317 dev_err(&dice->unit->device, in get_subaddrs()
325 dice->clock_caps = 1; in get_subaddrs()
328 dice->global_offset = be32_to_cpu(pointers[0]) * 4; in get_subaddrs()
329 dice->tx_offset = be32_to_cpu(pointers[2]) * 4; in get_subaddrs()
330 dice->rx_offset = be32_to_cpu(pointers[4]) * 4; in get_subaddrs()
334 dice->sync_offset = be32_to_cpu(pointers[6]) * 4; in get_subaddrs()
336 dice->rsrv_offset = be32_to_cpu(pointers[8]) * 4; in get_subaddrs()
342 int snd_dice_transaction_init(struct snd_dice *dice) in snd_dice_transaction_init() argument
344 struct fw_address_handler *handler = &dice->notification_handler; in snd_dice_transaction_init()
347 err = get_subaddrs(dice); in snd_dice_transaction_init()
354 handler->callback_data = dice; in snd_dice_transaction_init()
362 err = register_notification_address(dice, true); in snd_dice_transaction_init()