r851: Merge 2.1:
[cinelerra_cv/ct.git] / cinelerra / device1394output.C
blob2a65a38e70c39fdf4a3403294e0bd3ca55419b9d
1 #ifdef HAVE_FIREWIRE
5 #include "audiodevice.h"
6 #include "condition.h"
7 #include "device1394output.h"
8 #include "mutex.h"
9 #include "playbackconfig.h"
10 #include "bctimer.h"
11 #include "vframe.h"
12 #include "videodevice.h"
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <string.h>
17 #include <sys/ioctl.h>
18 #include <sys/mman.h>
19 #include <unistd.h>
20 #include <sys/utsname.h>
26 // Crazy DV internals
27 #define CIP_N_NTSC 2436
28 #define CIP_D_NTSC 38400
29 #define CIP_N_PAL 1
30 #define CIP_D_PAL 16
31 #define OUTPUT_SAMPLES 262144
32 #define BUFFER_TIMEOUT 500000
35 Device1394Output::Device1394Output(AudioDevice *adevice)
36  : Thread(1, 0, 0)
38         reset();
39         this->adevice = adevice;
41         set_ioctls();
44 Device1394Output::Device1394Output(VideoDevice *vdevice)
45  : Thread(1, 0, 0)
47         reset();
48         this->vdevice = vdevice;
50         set_ioctls();
53 Device1394Output::~Device1394Output()
55         if(Thread::running())
56         {
57                 done = 1;
58                 start_lock->unlock();
59                 Thread::cancel();
60                 Thread::join();
61         }
63         if(buffer)
64         {
65                 for(int i = 0; i < total_buffers; i++)
66                 {
67                         if(buffer[i]) delete [] buffer[i];
68                 }
69                 delete [] buffer;
70                 delete [] buffer_size;
71                 delete [] buffer_valid;
72         }
74         if(audio_lock) delete audio_lock;
75         if(video_lock) delete video_lock;
76         if(start_lock) delete start_lock;
77         if(audio_buffer) delete [] audio_buffer;
79         if(output_fd >= 0)
80         {
81         output_queue.buffer = (output_mmap.nb_buffers + output_queue.buffer - 1) % output_mmap.nb_buffers;
83                 if(get_dv1394())
84                 {
85                         if(ioctl(output_fd, DV1394_IOC_WAIT_FRAMES, status.init.n_frames - 1) < 0)
86                         {
87                                 fprintf(stderr,
88                                         "Device1394Output::close_all: DV1394_WAIT_FRAMES %i: %s",
89                                         output_mmap.nb_buffers,
90                                         strerror(errno));
91                         }
92                         munmap(output_buffer, status.init.n_frames *
93                                 (is_pal ? DV1394_PAL_FRAME_SIZE : DV1394_NTSC_FRAME_SIZE));
94                         if(ioctl(output_fd, DV1394_IOC_SHUTDOWN, NULL) < 0)
95                         {
96                                 perror("Device1394Output::close_all: DV1394_SHUTDOWN");
97                         }
98                 }
99                 else
100                 {
101                 if(ioctl(output_fd, video1394_talk_wait_buffer, &output_queue) < 0) 
102                         {
103                 fprintf(stderr, 
104                                         "Device1394::close_all: VIDEO1394_TALK_WAIT_BUFFER %s: %s",
105                                         output_queue,
106                                         strerror(errno));
107                 }
108                 munmap(output_buffer, output_mmap.nb_buffers * output_mmap.buf_size);
110                 if(ioctl(output_fd, video1394_untalk_channel, &output_mmap.channel) < 0)
111                         {
112                 perror("Device1394::close_all: VIDEO1394_UNTALK_CHANNEL");
113                 }
114                 }
116         close(output_fd);
118 //              if(avc_handle)
119 //                      raw1394_destroy_handle(avc_handle);
120         }
122         if(temp_frame) delete temp_frame;
123         if(temp_frame2) delete temp_frame2;
124         if(video_encoder) dv_delete(video_encoder);
125         if(position_presented) delete position_presented;
126         if(audio_encoder) dv_delete(audio_encoder);
127         if(buffer_lock) delete buffer_lock;
128         if(position_lock) delete position_lock;
132 void Device1394Output::reset()
134         buffer = 0;
135         buffer_size = 0;
136         total_buffers = 0;
137         current_inbuffer = 0;
138         current_outbuffer = 0;
139         done = 0;
140         audio_lock = 0;
141         video_lock = 0;
142         start_lock = 0;
143         buffer_lock = 0;
144         position_lock = 0;
145         video_encoder = 0;
146         audio_encoder = 0;
147         audio_buffer = 0;
148         audio_samples = 0;
149         output_fd = -1;
150 //      avc_handle = 0;
151         temp_frame = 0;
152         temp_frame2 = 0;
153         audio_position = 0;
154         interrupted = 0;
155         position_presented = 0;
156         have_video = 0;
157         adevice = 0;
158         vdevice = 0;
159         is_pal = 0;
162 int Device1394Output::get_dv1394()
164         if(adevice) return adevice->out_config->driver == AUDIO_DV1394;
165         if(vdevice) return vdevice->out_config->driver == PLAYBACK_DV1394;
168 int Device1394Output::open(char *path,
169         int port,
170         int channel,
171         int length,
172         int channels, 
173         int bits, 
174         int samplerate,
175         int syt)
177         this->channels = channels;
178         this->bits = bits;
179         this->samplerate = samplerate;
180         this->total_buffers = length;
181         if (get_dv1394())
182         {
183 // dv1394 syt is given in frames and limited to 2 or 3, default is 3
184 // Needs to be accurate to calculate presentation time
185                 if (syt < 2 || syt > 3)
186                         syt = 3;
187         }
188         this->syt = syt;
190 // Set PAL mode based on frame height
191         if(vdevice) is_pal = (vdevice->out_h == 576);
193     struct dv1394_init setup = 
194         {
195        api_version: DV1394_API_VERSION,
196        channel:     channel,
197            n_frames:    length,
198        format:      is_pal ? DV1394_PAL : DV1394_NTSC,
199        cip_n:       0,
200        cip_d:       0,
201        syt_offset:  syt
202     };
204         
206 //printf("Device1394::open_output 2 %s %d %d %d %d\n", path, port, channel, length, syt);
207         if(output_fd < 0)
208         {
209         output_fd = ::open(path, O_RDWR);
211                 if(output_fd <= 0)
212                 {
213                         fprintf(stderr, 
214                                 "Device1394Output::open path=%s: %s\n", 
215                                 path,
216                                 strerror(errno));
217                         return 1;
218                 }
219                 else
220                 {
221                 output_mmap.channel = channel;
222                 output_queue.channel = channel;
223                 output_mmap.sync_tag = 0;
224                 output_mmap.nb_buffers = total_buffers;
225                 output_mmap.buf_size = 320 * 512;
226                 output_mmap.packet_size = 512;
227 // Shouldn't this be handled by the video1394 driver?
228 // dvgrab originally used 19000
229 // JVC DVL300 -> 30000
230                 output_mmap.syt_offset = syt;
231                 output_mmap.flags = VIDEO1394_VARIABLE_PACKET_SIZE;
235                         if(get_dv1394())
236                         {
237                                 if(ioctl(output_fd, DV1394_IOC_INIT, &setup) < 0)
238                                 {
239                                         perror("Device1394Output::open DV1394_INIT");
240                                 }
242                                 if(ioctl(output_fd, DV1394_IOC_GET_STATUS, &status) < 0)
243                                 {
244                                         perror("Device1394Output::open DV1394_GET_STATUS");
245                                 }
247                         output_buffer = (unsigned char*)mmap(0,
248                         output_mmap.nb_buffers * (is_pal ? DV1394_PAL_FRAME_SIZE : DV1394_NTSC_FRAME_SIZE),
249                         PROT_READ | PROT_WRITE,
250                         MAP_SHARED,
251                         output_fd,
252                         0);
254                                 position_presented = new long[length];
255                                 for (int i = 0; i < length; i++)
256                                         position_presented[i] = 0;
257                         }
258                         else
259                         {
260                         if(ioctl(output_fd, video1394_talk_channel, &output_mmap) < 0)
261                                 {
262                         perror("Device1394Output::open VIDEO1394_TALK_CHANNEL:");
263                         }
265                         output_buffer = (unsigned char*)mmap(0, 
266                                         output_mmap.nb_buffers * output_mmap.buf_size,
267                         PROT_READ | PROT_WRITE, 
268                                         MAP_SHARED, 
269                                         output_fd, 
270                                         0);
271                         }
273                 if(output_buffer <= 0)
274                         {
275                 perror("Device1394Output::open mmap");
276                 }
278                         unused_buffers = output_mmap.nb_buffers;
279                 output_queue.buffer = 0;
280                 output_queue.packet_sizes = packet_sizes;
281                 continuity_counter = 0;
282                 cip_counter = 0;
284 // Create buffers
285                         buffer = new char*[total_buffers];
286                         for(int i = 0; i < length; i++)
287                                 buffer[i] = new char[get_dv1394() ?
288                                         (is_pal ? DV1394_PAL_FRAME_SIZE : DV1394_NTSC_FRAME_SIZE) :
289                                         DV_PAL_SIZE];
290                         buffer_size = new int[total_buffers];
291                         buffer_valid = new int[total_buffers];
292                         bzero(buffer_size, sizeof(int) * total_buffers);
293                         bzero(buffer_valid, sizeof(int) * total_buffers);
294                         bzero(buffer, sizeof(char*) * total_buffers);
295                         video_lock = new Condition(0, "Device1394Output::video_lock");
296                         audio_lock = new Condition(0, "Device1394Output::audio_lock");
297                         start_lock = new Condition(0, "Device1394Output::start_lock");
298                         buffer_lock = new Mutex("Device1394Output::buffer_lock");
299                         position_lock = new Mutex("Device1394Output::position_lock");
300                         encoder = dv_new();
301                         audio_buffer = new char[OUTPUT_SAMPLES * channels * bits / 8];
302                         Thread::start();
303         }
304         }
305         return 0;
308 void Device1394Output::run()
310         unsigned char *output;
311         char *out_buffer;
312         int out_size;
314         Thread::enable_cancel();
315         start_lock->lock("Device1394Output::run");
316         Thread::disable_cancel();
318 //Timer timer;
319 // Write buffers continuously
320         while(!done)
321         {
322 // Get current buffer to play
323                 if(done) return;
325                 buffer_lock->lock("Device1394Output::run 1");
327                 out_buffer = buffer[current_outbuffer];
328                 out_size = buffer_size[current_outbuffer];
334 // No video.  Put in a fake frame for audio only
335                 if(!have_video)
336                 {
337 #include "data/fake_ntsc_dv.h"
338                         out_size = sizeof(fake_ntsc_dv) - 4;
339                         out_buffer = (char*)fake_ntsc_dv + 4;
340                 }
345                 if(get_dv1394())
346                 {
347                         output = output_buffer + 
348                                 out_size *
349                                 status.first_clear_frame;
350                 }
351                 else
352                 {
353                         output = output_buffer + 
354                                 output_queue.buffer * 
355                                 output_mmap.buf_size;
356                 }
365 // Got a buffer
366                 if(out_buffer && out_size)
367                 {
368 // Calculate number of samples needed based on given pattern for 
369 // norm.
370                         int samples_per_frame = 2048;
372 // Encode audio
373                         if(audio_samples > samples_per_frame)
374                         {
376                                 int samples_written = dv_write_audio(encoder,
377                                         (unsigned char*)out_buffer,
378                                         (unsigned char*)audio_buffer,
379                                         samples_per_frame,
380                                         channels,
381                                         bits,
382                                         samplerate,
383                                         is_pal ? DV_PAL : DV_NTSC);
384                                 memcpy(audio_buffer, 
385                                         audio_buffer + samples_written * bits * channels / 8,
386                                         (audio_samples - samples_written) * bits * channels / 8);
387                                 audio_samples -= samples_written;
388                                 position_lock->lock("Device1394Output::run");
390                                 if (get_dv1394())
391                                 {
392 // When this frame is being uploaded to the 1394 device,
393 // the frame actually playing on the device will be the one
394 // uploaded syt frames before.
395                                         position_presented[status.first_clear_frame] = 
396                                                 audio_position - syt * samples_per_frame;
397                                         if (position_presented[status.first_clear_frame] < 0)
398                                                 position_presented[status.first_clear_frame] = 0;
399                                 }
401                                 audio_position += samples_written;
402                                 position_lock->unlock();
405                                 audio_lock->unlock();
406                         }
408 // Copy from current buffer to mmap buffer with firewire encryption
409                         if(get_dv1394())
410                         {
411                                 memcpy(output, out_buffer, out_size);
412                         }
413                         else
414                         {
415                                 encrypt((unsigned char*)output, 
416                                         (unsigned char*)out_buffer, 
417                                         out_size);
418                         }
419                         buffer_valid[current_outbuffer] = 0;
420                 }
422 // Advance buffer number if possible
423                 increment_counter(&current_outbuffer);
425 // Reuse same buffer next time
426                 if(!buffer_valid[current_outbuffer])
427                 {
428                         decrement_counter(&current_outbuffer);
429                 }
430                 else
431 // Wait for user to reach current buffer before unlocking any more.
432                 {
433                         video_lock->unlock();
434                 }
437                 buffer_lock->unlock();
438 //printf("Device1394Output::run 100\n");
442                 if(out_size > 0)
443                 {
445 // Write mmap to device
446                         Thread::enable_cancel();
447                         unused_buffers--;
450                         if(get_dv1394())
451                         {
452                                 if(ioctl(output_fd, DV1394_IOC_SUBMIT_FRAMES, 1) < 0)
453                                 {
454                                         perror("Device1394Output::run DV1394_SUBMIT_FRAMES");
455                                 }
456                                 if(ioctl(output_fd, DV1394_IOC_WAIT_FRAMES, 1) < 0)
457                                 {
458                                         perror("Device1394Output::run DV1394_WAIT_FRAMES");
459                                 }
460                                 if(ioctl(output_fd, DV1394_IOC_GET_STATUS, &status) < 0)
461                                 {
462                                         perror("Device1394Output::run DV1394_GET_STATUS");
463                                 }
464                         }
465                         else
466                         {
467                                 if(ioctl(output_fd, video1394_talk_queue_buffer, &output_queue) < 0)
468                                 {
469                                 perror("Device1394Output::run VIDEO1394_TALK_QUEUE_BUFFER");
470                         }
471                         }
473                 output_queue.buffer++;
474                         if(output_queue.buffer >= output_mmap.nb_buffers) 
475                                 output_queue.buffer = 0;
477                         if(unused_buffers <= 0)
478                         {
479                                 if(!get_dv1394())
480                                 {
481                                 if(ioctl(output_fd, video1394_talk_wait_buffer, &output_queue) < 0) 
482                                         {
483                                         perror("Device1394::run VIDEO1394_TALK_WAIT_BUFFER");
484                                 }
485                                 }
486                                 unused_buffers++;
487                         }
490                         Thread::disable_cancel();
491                 }
492                 else
493                 {
494 //                      Thread::enable_cancel();
495 //                      start_lock->lock();
496 //                      Thread::disable_cancel();
497                 }
499 //printf("Device1394Output::run %lld\n", timer.get_difference());
500         }
505 void Device1394Output::encrypt(unsigned char *output, 
506         unsigned char *data, 
507         int data_size)
509 // Encode in IEEE1394 video encryption
510         int output_size = 320;
511         int packets_per_frame = (is_pal ? 300 : 250);
512         int min_packet_size = output_mmap.packet_size;
513         unsigned long frame_size = packets_per_frame * 480;
514         unsigned long vdata = 0;
515         unsigned int *packet_sizes = this->packet_sizes;
517     if(cip_counter == 0) 
518         {
519         if(!is_pal) 
520                 {
521             cip_n = CIP_N_NTSC;
522             cip_d = CIP_D_NTSC;
523             f50_60 = 0x00;
524         }
525                 else 
526                 {
527             cip_n = CIP_N_PAL;
528             cip_d = CIP_D_PAL;
529             f50_60 = 0x80;
530         }
531         cip_counter = cip_n;
532     }
537         for(int i = 0; i < output_size && vdata < frame_size; i++)
538         {
539         unsigned char *p = output;
540         int want_sync = (cip_counter > cip_d);
542 /* Source node ID ! */
543         *p++ = 0x01; 
544 /* Packet size in quadlets (480 / 4) - this stays the same even for empty packets */
545         *p++ = 0x78; 
546         *p++ = 0x00;
547         *p++ = continuity_counter;
549 /* const */
550         *p++ = 0x80; 
551 /* high bit = 50/60 indicator */
552         *p++ = f50_60; 
554 /* timestamp - generated in driver */
555         *p++ = 0xff; 
556 /* timestamp */
557         *p++ = 0xff; 
559 /* video data */
560         if(!want_sync)
561                 {
562             continuity_counter++;
563             cip_counter += cip_n;
565             memcpy(p, data + vdata, 480);
566             p += 480;
567             vdata += 480;
568         }
569         else
570             cip_counter -= cip_d;
572         *packet_sizes++ = p - output;
573         output += min_packet_size;
574         }
575         *packet_sizes++ = 0;
581 void Device1394Output::write_frame(VFrame *input)
583         VFrame *ptr = 0;
584         int result = 0;
586 //printf("Device1394Output::write_frame 1\n");
588         if(output_fd <= 0) return;
589         if(interrupted) return;
591 // Encode frame to DV
592         if(input->get_color_model() != BC_COMPRESSED)
593         {
594                 if(!temp_frame) temp_frame = new VFrame;
595                 if(!encoder) encoder = dv_new();
596                 ptr = temp_frame;
598 // Exact resolution match.  Don't do colorspace conversion
599                 if(input->get_color_model() == BC_YUV422 &&
600                         input->get_w() == 720 &&
601                         (input->get_h() == 480 ||
602                         input->get_h() == 576))
603                 {
604                         int norm = is_pal ? DV_PAL : DV_NTSC;
605                         int data_size = is_pal ? DV_PAL_SIZE : DV_NTSC_SIZE;
606                         temp_frame->allocate_compressed_data(data_size);
607                         temp_frame->set_compressed_size(data_size);
609                         dv_write_video(encoder,
610                                 temp_frame->get_data(),
611                                 input->get_rows(),
612                                 BC_YUV422,
613                                 norm);
614                         ptr = temp_frame;
615                 }
616                 else
617 // Convert resolution and color model before compressing
618                 {
619                         if(!temp_frame2)
620                         {
621                                 int h = input->get_h();
622 // Default to NTSC if unknown
623                                 if(h != 480 && h != 576) h = 480;
625                                 temp_frame2 = new VFrame(0,
626                                         720,
627                                         h,
628                                         BC_YUV422);
629                                 
630                         }
632                         int norm = is_pal ? DV_PAL : DV_NTSC;
633                         int data_size = is_pal ? DV_PAL_SIZE : DV_NTSC_SIZE;
634                         temp_frame->allocate_compressed_data(data_size);
635                         temp_frame->set_compressed_size(data_size);
638                         cmodel_transfer(temp_frame2->get_rows(), /* Leave NULL if non existent */
639                                 input->get_rows(),
640                                 temp_frame2->get_y(), /* Leave NULL if non existent */
641                                 temp_frame2->get_u(),
642                                 temp_frame2->get_v(),
643                                 input->get_y(), /* Leave NULL if non existent */
644                                 input->get_u(),
645                                 input->get_v(),
646                                 0,        /* Dimensions to capture from input frame */
647                                 0, 
648                                 MIN(temp_frame2->get_w(), input->get_w()),
649                                 MIN(temp_frame2->get_h(), input->get_h()),
650                                 0,       /* Dimensions to project on output frame */
651                                 0, 
652                                 MIN(temp_frame2->get_w(), input->get_w()),
653                                 MIN(temp_frame2->get_h(), input->get_h()),
654                                 input->get_color_model(), 
655                                 BC_YUV422,
656                                 0,         /* When transfering BC_RGBA8888 to non-alpha this is the background color in 0xRRGGBB hex */
657                                 input->get_bytes_per_line(),       /* For planar use the luma rowspan */
658                                 temp_frame2->get_bytes_per_line());     /* For planar use the luma rowspan */
660                         dv_write_video(encoder,
661                                 temp_frame->get_data(),
662                                 temp_frame2->get_rows(),
663                                 BC_YUV422,
664                                 norm);
668                         ptr = temp_frame;
669                 }
670         }
671         else
672                 ptr = input;
684 // Take over buffer table
685         buffer_lock->lock("Device1394Output::write_frame 1");
686         have_video = 1;
687 // Wait for buffer to become available with timeout
688         while(buffer_valid[current_inbuffer] && !result && !interrupted)
689         {
690                 buffer_lock->unlock();
691                 result = video_lock->timed_lock(BUFFER_TIMEOUT);
692                 buffer_lock->lock("Device1394Output::write_frame 2");
693         }
697 // Write buffer if there's room
698         if(!buffer_valid[current_inbuffer])
699         {
700                 if(!buffer[current_inbuffer])
701                 {
702                         buffer[current_inbuffer] = new char[ptr->get_compressed_size()];
703                         buffer_size[current_inbuffer] = ptr->get_compressed_size();
704                 }
705                 memcpy(buffer[current_inbuffer], ptr->get_data(), ptr->get_compressed_size());
706                 buffer_valid[current_inbuffer] = 1;
707                 increment_counter(&current_inbuffer);
708         }
709         else
710 // Ignore it if there isn't room.
711         {
712                 ;
713         }
715         buffer_lock->unlock();
716         start_lock->unlock();
717 //printf("Device1394Output::write_frame 100\n");
720 void Device1394Output::write_samples(char *data, int samples)
722 //printf("Device1394Output::write_samples 1\n");
723         int result = 0;
724         int timeout = (int64_t)samples * 
725                 (int64_t)1000000 * 
726                 (int64_t)2 / 
727                 (int64_t)samplerate;
728         if(interrupted) return;
730 //printf("Device1394Output::write_samples 2\n");
732 // Check for maximum sample count exceeded
733         if(samples > OUTPUT_SAMPLES)
734         {
735                 printf("Device1394Output::write_samples samples=%d > OUTPUT_SAMPLES=%d\n",
736                         samples,
737                         OUTPUT_SAMPLES);
738                 return;
739         }
741 //printf("Device1394Output::write_samples 3\n");
742 // Take over buffer table
743         buffer_lock->lock("Device1394Output::write_samples 1");
744 // Wait for buffer to become available with timeout
745         while(audio_samples > OUTPUT_SAMPLES - samples && !result && !interrupted)
746         {
747                 buffer_lock->unlock();
748                 result = audio_lock->timed_lock(BUFFER_TIMEOUT);
749                 buffer_lock->lock("Device1394Output::write_samples 2");
750         }
752         if(!interrupted && audio_samples <= OUTPUT_SAMPLES - samples)
753         {
754 //printf("Device1394Output::write_samples 4 %d\n", audio_samples);
755                 memcpy(audio_buffer + audio_samples * channels * bits / 8,
756                         data,
757                         samples * channels * bits / 8);
758                 audio_samples += samples;
759         }
760         buffer_lock->unlock();
761         start_lock->unlock();
762 //printf("Device1394Output::write_samples 100\n");
765 long Device1394Output::get_audio_position()
767         position_lock->lock("Device1394Output::get_audio_position");
768         long result = audio_position;
769         if (get_dv1394())
770         {
771 // Take delay between placing in buffer and presentation 
772 // on device into account for dv1394
773                 result = position_presented[status.active_frame];
774         }
775         position_lock->unlock();
776         return result;
779 void Device1394Output::interrupt()
781         interrupted = 1;
782 // Break write_samples out of a lock
783         video_lock->unlock();
784         audio_lock->unlock();
785 // Playback should stop when the object is deleted.
788 void Device1394Output::flush()
790         
793 void Device1394Output::increment_counter(int *counter)
795         (*counter)++;
796         if(*counter >= total_buffers) *counter = 0;
799 void Device1394Output::decrement_counter(int *counter)
801         (*counter)--;
802         if(*counter < 0) *counter = total_buffers - 1;
805 void Device1394Output::set_ioctls()
807         // It would make sense to simply change the file that is included in
808         // order to change the IOCTLs, but it isn't reasonable to think that
809         // people will rebuild their software every time the update their
810         // kernel, hence this fix.
812         struct utsname buf;
814         // Get the kernel version so we can set the right ioctls
815         uname(&buf);
817         char *ptr = strchr(buf.release, '.');
818         int major = 2;
819         int minor = 6;
820         int point = 7;
821         if(ptr)
822         {
823                 *ptr++ = 0;
824                 major = atoi(buf.release);
825                 char *ptr2 = strchr(ptr, '.');
826                 if(ptr2)
827                 {
828                         *ptr2++ = 0;
829                         minor = atoi(ptr);
830                         point = atoi(ptr2);
831                 }
832         }
834         if(major >= 2 && minor >= 6 && point >= 0 ||
835                 major >= 2 && minor >= 4 && point >= 23)
836         {
837                 // video1394
838                 video1394_listen_channel = VIDEO1394_IOC_LISTEN_CHANNEL;
839                 video1394_unlisten_channel = VIDEO1394_IOC_UNLISTEN_CHANNEL;
840                 video1394_listen_queue_buffer = VIDEO1394_IOC_LISTEN_QUEUE_BUFFER;
841                 video1394_listen_wait_buffer = VIDEO1394_IOC_LISTEN_WAIT_BUFFER;
842                 video1394_talk_channel = VIDEO1394_IOC_TALK_CHANNEL;
843                 video1394_untalk_channel = VIDEO1394_IOC_UNTALK_CHANNEL;
844                 video1394_talk_queue_buffer = VIDEO1394_IOC_TALK_QUEUE_BUFFER;
845                 video1394_talk_wait_buffer = VIDEO1394_IOC_TALK_WAIT_BUFFER;
846                 video1394_listen_poll_buffer = VIDEO1394_IOC_LISTEN_POLL_BUFFER;
848                 // raw1394
849                 // Nothing uses this right now, so I didn't include it.
850         }
851         else     // we are using an older kernel
852         {
853       // video1394
854       video1394_listen_channel = VIDEO1394_LISTEN_CHANNEL;
855       video1394_unlisten_channel = VIDEO1394_UNLISTEN_CHANNEL;
856       video1394_listen_queue_buffer = VIDEO1394_LISTEN_QUEUE_BUFFER;
857       video1394_listen_wait_buffer = VIDEO1394_LISTEN_WAIT_BUFFER;
858       video1394_talk_channel = VIDEO1394_TALK_CHANNEL;
859       video1394_untalk_channel = VIDEO1394_UNTALK_CHANNEL;
860       video1394_talk_queue_buffer = VIDEO1394_TALK_QUEUE_BUFFER;
861       video1394_talk_wait_buffer = VIDEO1394_TALK_WAIT_BUFFER;
862       video1394_listen_poll_buffer = VIDEO1394_LISTEN_POLL_BUFFER;
863         }
877 #endif // HAVE_FIREWIRE