Lines Matching refs:cd

243 #define stats(i) { ++cd->stats[st_ ## i]; \
244 cd->last_stat[st_ ## i] = cd->stat_counter++; \
298 #define DISC_STATUS cd->disc_status[0]
299 #define FIRST_TRACK cd->disc_status[1]
300 #define LAST_TRACK cd->disc_status[2]
301 #define PAUSED cd->audio_status[0] /* misuse this memory byte! */
302 #define PLAY_TO cd->toc[0] /* toc[0] records end-time in play */
304 static struct cm206_struct *cd; /* the main memory structure */ variable
338 if (cd->ur_r != cd->ur_w) { in clear_ur()
340 for (; cd->ur_r != cd->ur_w; in clear_ur()
341 cd->ur_r++, cd->ur_r %= UR_SIZE) in clear_ur()
342 debug((" 0x%x", cd->ur[cd->ur_r])); in clear_ur()
364 cd->intr_ds = inw(r_data_status); /* resets data_ready, data_error, in cm206_interrupt()
367 cd->intr_ls = inw(r_line_status); /* resets overrun bit */ in cm206_interrupt()
368 debug(("Intr, 0x%x 0x%x, %d\n", cd->intr_ds, cd->intr_ls, in cm206_interrupt()
369 cd->background)); in cm206_interrupt()
370 if (cd->intr_ls & ls_attention) in cm206_interrupt()
373 if (cd->intr_ls & ls_receive_buffer_full) { in cm206_interrupt()
374 cd->ur[cd->ur_w] = inb(r_uart_receive); /* get order right! */ in cm206_interrupt()
375 cd->intr_ls = inw(r_line_status); /* resets rbf interrupt */ in cm206_interrupt()
376 debug(("receiving #%d: 0x%x\n", cd->ur_w, in cm206_interrupt()
377 cd->ur[cd->ur_w])); in cm206_interrupt()
378 cd->ur_w++; in cm206_interrupt()
379 cd->ur_w %= UR_SIZE; in cm206_interrupt()
380 if (cd->ur_w == cd->ur_r) in cm206_interrupt()
382 if (waitqueue_active(&cd->uart) && cd->background < 2) { in cm206_interrupt()
383 del_timer(&cd->timer); in cm206_interrupt()
384 wake_up_interruptible(&cd->uart); in cm206_interrupt()
388 else if (cd->intr_ds & ds_data_ready) { in cm206_interrupt()
389 if (cd->background) in cm206_interrupt()
390 ++cd->adapter_last; in cm206_interrupt()
391 if (waitqueue_active(&cd->data) in cm206_interrupt()
392 && (cd->wait_back || !cd->background)) { in cm206_interrupt()
393 del_timer(&cd->timer); in cm206_interrupt()
394 wake_up_interruptible(&cd->data); in cm206_interrupt()
399 else if (cd->command && cd->intr_ls & ls_transmitter_buffer_empty) { in cm206_interrupt()
402 outw(cd->command, r_uart_transmit); in cm206_interrupt()
403 cd->command = 0; in cm206_interrupt()
404 if (!cd->background) in cm206_interrupt()
405 wake_up_interruptible(&cd->uart); in cm206_interrupt()
408 else if (cd->intr_ds & ds_fifo_overflow) { in cm206_interrupt()
410 cd->sector_first)); in cm206_interrupt()
412 cd->fifo_overflowed = 1; /* signal one word less should be read */ in cm206_interrupt()
414 } else if (cd->intr_ds & ds_data_error) { in cm206_interrupt()
415 debug(("Data error at sector 0x%x\n", cd->sector_first)); in cm206_interrupt()
417 } else if (cd->intr_ds & ds_crc_error) { in cm206_interrupt()
418 debug(("CRC error at sector 0x%x\n", cd->sector_first)); in cm206_interrupt()
420 } else if (cd->intr_ds & ds_sync_error) { in cm206_interrupt()
421 debug(("Sync at sector 0x%x\n", cd->sector_first)); in cm206_interrupt()
423 } else if (cd->intr_ds & ds_toc_ready) { in cm206_interrupt()
431 if (cd->background in cm206_interrupt()
432 && (cd->adapter_last - cd->adapter_first == cd->max_sectors in cm206_interrupt()
433 || cd->fifo_overflowed)) in cm206_interrupt()
441 cd->timed_out = 1; in cm206_timeout()
450 cd->timed_out = 0; in sleep_or_timeout()
451 cd->timer.data = (unsigned long) wait; in sleep_or_timeout()
452 cd->timer.expires = jiffies + timeout; in sleep_or_timeout()
453 add_timer(&cd->timer); in sleep_or_timeout()
456 del_timer(&cd->timer); in sleep_or_timeout()
457 if (cd->timed_out) { in sleep_or_timeout()
458 cd->timed_out = 0; in sleep_or_timeout()
474 cd->command = command; in send_command()
479 if (sleep_or_timeout(&cd->uart, UART_TIMEOUT)) { in send_command()
494 ret = cd->ur[cd->ur_r]; in receive_byte()
495 if (cd->ur_r != cd->ur_w) { in receive_byte()
497 debug(("returning #%d: 0x%x\n", cd->ur_r, in receive_byte()
498 cd->ur[cd->ur_r])); in receive_byte()
499 cd->ur_r++; in receive_byte()
500 cd->ur_r %= UR_SIZE; in receive_byte()
502 } else if (sleep_or_timeout(&cd->uart, timeout)) { /* does sti() */ in receive_byte()
512 ret = cd->ur[cd->ur_r]; in receive_byte()
513 debug(("slept; returning #%d: 0x%x\n", cd->ur_r, in receive_byte()
514 cd->ur[cd->ur_r])); in receive_byte()
515 cd->ur_r++; in receive_byte()
516 cd->ur_r %= UR_SIZE; in receive_byte()
546 cd->dsb = wait_dsb(); /* wait for command to finish */ in type_0_command()
631 if (cd->background) in read_background()
636 cd->adapter_first = cd->adapter_last = start; in read_background()
637 cd->background = 1; /* flag a read is going on */ in read_background()
660 if (cd->background) { in read_sector()
661 cd->background = 0; in read_sector()
662 cd->adapter_last = -1; /* invalidate adapter memory */ in read_sector()
665 cd->fifo_overflowed = 0; in read_sector()
670 if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) { in read_sector()
677 } while (cd->intr_ds & ds_fifo_empty && tries < MAX_TRIES); in read_sector()
683 transport_data(r_fifo_output_buffer, cd->sector, in read_sector()
687 cd->sector_first = start; in read_sector()
688 cd->sector_last = start + READ_AHEAD; in read_sector()
705 debug(("bh: %d\n", cd->background)); in cm206_bh()
706 switch (cd->background) { in cm206_bh()
709 if (!(cd->intr_ls & ls_transmitter_buffer_empty)) { in cm206_bh()
710 cd->command = c_stop; in cm206_bh()
713 cd->background = 2; in cm206_bh()
720 cd->background = 3; in cm206_bh()
723 if (cd->ur_r != cd->ur_w) { in cm206_bh()
724 if (cd->ur[cd->ur_r] != c_stop) { in cm206_bh()
726 cd->ur[cd->ur_r])); in cm206_bh()
729 cd->ur_r++; in cm206_bh()
730 cd->ur_r %= UR_SIZE; in cm206_bh()
732 cd->background++; in cm206_bh()
735 if (cd->ur_r != cd->ur_w) { in cm206_bh()
736 if (cd->ur[cd->ur_r] != 0xff) { in cm206_bh()
737 debug(("cm206_bh: c_stop reacted with 0x%x\n", cd->ur[cd->ur_r])); in cm206_bh()
740 cd->ur_r++; in cm206_bh()
741 cd->ur_r %= UR_SIZE; in cm206_bh()
743 cd->background = 0; in cm206_bh()
754 cd->dsb = status[0]; in get_drive_status()
755 cd->cc = status[1]; in get_drive_status()
756 cd->media_changed |= in get_drive_status()
757 !!(cd->dsb & (dsb_possible_media_change | in get_drive_status()
763 if (type_1_command(c_disc_status, 7, cd->disc_status)) { in get_disc_status()
781 if (!cd->openfiles) { /* reset only first time */ in cm206_open()
782 cd->background = 0; in cm206_open()
784 cd->adapter_last = -1; /* invalidate adapter memory */ in cm206_open()
785 cd->sector_last = -1; in cm206_open()
787 ++cd->openfiles; in cm206_open()
794 if (cd->openfiles == 1) { in cm206_release()
795 if (cd->background) { in cm206_release()
796 cd->background = 0; in cm206_release()
799 cd->sector_last = -1; /* Make our internal buffer invalid */ in cm206_release()
802 --cd->openfiles; in cm206_release()
811 cd->sector + cd->fifo_overflowed, in empty_buffer()
812 RAW_SECTOR_SIZE / 2 - cd->fifo_overflowed); in empty_buffer()
814 ++cd->adapter_first; /* update the current adapter sector */ in empty_buffer()
815 cd->fifo_overflowed = 0; /* reset overflow bit */ in empty_buffer()
818 cd->sector_first = cd->adapter_first - 1; in empty_buffer()
819 cd->sector_last = cd->adapter_first; /* update the buffer sector */ in empty_buffer()
827 if (cd->adapter_first <= sector && sector < cd->adapter_last) { in try_adapter()
829 empty_buffer(sector - cd->adapter_first); in try_adapter()
831 } else if (cd->background == 1 && cd->adapter_first <= sector in try_adapter()
832 && sector < cd->adapter_first + cd->max_sectors) { in try_adapter()
834 cd->wait_back = 1; in try_adapter()
835 while (sector >= cd->adapter_last) { in try_adapter()
836 if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) { in try_adapter()
837 …imed out during background wait: %d %d %d %d\n", sector, cd->adapter_last, cd->adapter_first, cd->… in try_adapter()
839 cd->wait_back = 0; in try_adapter()
843 cd->wait_back = 0; in try_adapter()
844 empty_buffer(sector - cd->adapter_first); in try_adapter()
877 if (cd->sector_first <= cd_sec_no in do_cm206_request()
878 && cd_sec_no < cd->sector_last) { in do_cm206_request()
880 ((uch *) cd->sector) + 16 + in do_cm206_request()
883 cd->sector_first) * RAW_SECTOR_SIZE; in do_cm206_request()
888 ((uch *) cd->sector) + 16 + in do_cm206_request()
923 cd->dsb = wait_dsb(); in seek()
946 int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm); in get_toc_lba()
948 uch *q = cd->q; in get_toc_lba()
954 if (cd->toc[i].track) { in get_toc_lba()
955 min = fsm2lba(cd->toc[i].fsm); in get_toc_lba()
963 if (!cd->toc[ct].track) { in get_toc_lba()
969 cd->toc[ct].track = q[1]; /* lead out still 0xaa */ in get_toc_lba()
970 fsm(l, cd->toc[ct].fsm); in get_toc_lba()
971 cd->toc[ct].q0 = q[0]; /* contains adr and ctrl info */ in get_toc_lba()
999 if (!cd->toc[track].track) in update_toc_entry()
1014 cd->toc[1].fsm[i] = cd->disc_status[3 + i]; in read_toc_header()
1034 cd->dsb = wait_dsb(); in play_from_to_msf()
1044 play_command[i + 1] = cd->audio_status[i + 2]; in play_from_to_track()
1051 play_command[i + 1] = cd->toc[from].fsm[i]; in play_from_to_track()
1053 cd->toc[to + 1].fsm[i]; in play_from_to_track()
1061 cd->dsb = wait_dsb(); in play_from_to_track()
1067 uch *q = cd->q; in get_current_q()
1089 if (cd->dsb & dsb_play_in_progress) in get_current_q()
1100 memset(cd->toc, 0, sizeof(cd->toc)); in invalidate_toc()
1101 memset(cd->disc_status, 0, sizeof(cd->disc_status)); in invalidate_toc()
1109 ep->cdte_addr.msf.frame = cd->toc[track].fsm[0]; in get_toc_entry()
1110 ep->cdte_addr.msf.second = cd->toc[track].fsm[1]; in get_toc_entry()
1111 ep->cdte_addr.msf.minute = cd->toc[track].fsm[2]; in get_toc_entry()
1112 ep->cdte_adr = cd->toc[track].q0 & 0xf; in get_toc_entry()
1113 ep->cdte_ctrl = cd->toc[track].q0 >> 4; in get_toc_entry()
1140 if (cd->dsb & dsb_play_in_progress) in cm206_audio_ioctl()
1146 if (cd->dsb & dsb_play_in_progress) { in cm206_audio_ioctl()
1149 cd->audio_status); in cm206_audio_ioctl()
1181 return cd->stats[arg]; in cm206_ioctl()
1186 return cd->last_stat[arg]; in cm206_ioctl()
1196 if (cd != NULL) { in cm206_media_changed()
1199 r = cd->media_changed; in cm206_media_changed()
1200 cd->media_changed = 0; /* clear bit */ in cm206_media_changed()
1212 if (cd) in cm206_open_files()
1213 return cd->openfiles; in cm206_open_files()
1232 if (cd->dsb & dsb_tray_not_closed) in cm206_drive_status()
1234 if (!(cd->dsb & dsb_disc_present)) in cm206_drive_status()
1236 if (cd->dsb & dsb_drive_not_ready) in cm206_drive_status()
1247 return lock ^ ((cd->dsb & dsb_tray_locked) != 0); in cm206_lock_door()
1260 mssp->addr.msf.frame = cd->disc_status[3]; in cm206_get_last_session()
1261 mssp->addr.msf.second = cd->disc_status[4]; in cm206_get_last_session()
1262 mssp->addr.msf.minute = cd->disc_status[5]; in cm206_get_last_session()
1299 cd->sector_last = -1; /* flag no data buffered */ in cm206_reset()
1300 cd->adapter_last = -1; in cm206_reset()
1374 kfree(cd); in cleanup()
1442 cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL); in cm206_init()
1443 if (!cd) in cm206_init()
1507 memset(cd, 0, sizeof(*cd)); /* give'm some reasonable value */ in cm206_init()
1508 cd->sector_last = -1; /* flag no data buffered */ in cm206_init()
1509 cd->adapter_last = -1; in cm206_init()
1510 cd->timer.function = cm206_timeout; in cm206_init()
1511 cd->max_sectors = (inw(r_data_status) & ds_ram_size) ? 24 : 97; in cm206_init()
1513 " %ld bytes kernel memory used.\n", cd->max_sectors * 2, in cm206_init()